git-prompt: preserve value of $? in all cases

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>
This commit is contained in:
Tony Finch
2015-01-14 10:06:28 +00:00
committed by Junio C Hamano
parent eb443e3b39
commit 6babe76496

View File

@ -288,6 +288,7 @@ __git_eread ()
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
__git_ps1 () __git_ps1 ()
{ {
# preserve exit status
local exit=$? local exit=$?
local pcmode=no local pcmode=no
local detached=no local detached=no
@ -303,7 +304,7 @@ __git_ps1 ()
;; ;;
0|1) printf_format="${1:-$printf_format}" 0|1) printf_format="${1:-$printf_format}"
;; ;;
*) return *) return $exit
;; ;;
esac esac
@ -355,7 +356,7 @@ __git_ps1 ()
#In PC mode PS1 always needs to be set #In PC mode PS1 always needs to be set
PS1="$ps1pc_start$ps1pc_end" PS1="$ps1pc_start$ps1pc_end"
fi fi
return return $exit
fi fi
local short_sha local short_sha
@ -416,7 +417,7 @@ __git_ps1 ()
if [ $pcmode = yes ]; then if [ $pcmode = yes ]; then
PS1="$ps1pc_start$ps1pc_end" PS1="$ps1pc_start$ps1pc_end"
fi fi
return return $exit
fi fi
# is it a symbolic ref? # is it a symbolic ref?
b="${head#ref: }" b="${head#ref: }"
@ -513,6 +514,5 @@ __git_ps1 ()
printf -- "$printf_format" "$gitstring" printf -- "$printf_format" "$gitstring"
fi fi
# preserve exit status
return $exit return $exit
} }