From b180637a1946418ed3defcad7ab8d748e04b0dca Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Fri, 14 Nov 2014 16:38:11 -0800 Subject: [PATCH] only pop the stash if we pushed something --- zsh/zshrc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zsh/zshrc b/zsh/zshrc index 8f467ae..d94b7d1 100755 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -240,7 +240,13 @@ fi function gup() { BRANCH=$(git branch --no-color --list | grep '^\*' | awk '{print $2}') if [[ "$BRANCH" != "(detached" ]]; then - git stash && git fetch origin && git rebase "origin/$BRANCH" && git stash pop + STASH_OUTPUT=$(git stash) + if [[ "$STASH_OUTPUT" = "No local changes to save" ]]; then + POP_STASH=0 + else + POP_STASH=1 + fi + git fetch origin && git rebase "origin/$BRANCH" && ([[ $POP_STASH -eq 1 ]] && git stash pop) || true else echo "Cannot update in a detached HEAD state" fi