Skip to content

Commit

Permalink
git-prompt: preserve value of $? in all cases
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Finch <dot@dotat.at>
Reviewed-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Tony Finch authored and Junio C Hamano committed Jan 14, 2015
1 parent eb443e3 commit 6babe76
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions contrib/completion/git-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ __git_eread ()
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
__git_ps1 ()
{
# preserve exit status
local exit=$?
local pcmode=no
local detached=no
Expand All @@ -303,7 +304,7 @@ __git_ps1 ()
;;
0|1) printf_format="${1:-$printf_format}"
;;
*) return
*) return $exit
;;
esac

Expand Down Expand Up @@ -355,7 +356,7 @@ __git_ps1 ()
#In PC mode PS1 always needs to be set
PS1="$ps1pc_start$ps1pc_end"
fi
return
return $exit
fi

local short_sha
Expand Down Expand Up @@ -416,7 +417,7 @@ __git_ps1 ()
if [ $pcmode = yes ]; then
PS1="$ps1pc_start$ps1pc_end"
fi
return
return $exit
fi
# is it a symbolic ref?
b="${head#ref: }"
Expand Down Expand Up @@ -513,6 +514,5 @@ __git_ps1 ()
printf -- "$printf_format" "$gitstring"
fi

# preserve exit status
return $exit
}

0 comments on commit 6babe76

Please sign in to comment.