提交 9920c718 编写于 作者: J Junio C Hamano

Merge branch 'tf/prompt-preserve-exit-status'

Using the exit status of the last command in the prompt, e.g.
PS1='$(__git_ps1) $? ', did not work well because the helper
function stomped on the exit status.

* tf/prompt-preserve-exit-status:
  git-prompt: preserve value of $? in all cases
...@@ -293,6 +293,7 @@ __git_eread () ...@@ -293,6 +293,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
...@@ -312,7 +313,7 @@ __git_ps1 () ...@@ -312,7 +313,7 @@ __git_ps1 ()
;; ;;
0|1) printf_format="${1:-$printf_format}" 0|1) printf_format="${1:-$printf_format}"
;; ;;
*) return *) return $exit
;; ;;
esac esac
...@@ -360,7 +361,7 @@ __git_ps1 () ...@@ -360,7 +361,7 @@ __git_ps1 ()
rev_parse_exit_code="$?" rev_parse_exit_code="$?"
if [ -z "$repo_info" ]; then if [ -z "$repo_info" ]; then
return return $exit
fi fi
local short_sha local short_sha
...@@ -380,7 +381,7 @@ __git_ps1 () ...@@ -380,7 +381,7 @@ __git_ps1 ()
[ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] && [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
git check-ignore -q . git check-ignore -q .
then then
return return $exit
fi fi
local r="" local r=""
...@@ -426,7 +427,7 @@ __git_ps1 () ...@@ -426,7 +427,7 @@ __git_ps1 ()
else else
local head="" local head=""
if ! __git_eread "$g/HEAD" head; then if ! __git_eread "$g/HEAD" head; then
return return $exit
fi fi
# is it a symbolic ref? # is it a symbolic ref?
b="${head#ref: }" b="${head#ref: }"
...@@ -523,6 +524,5 @@ __git_ps1 () ...@@ -523,6 +524,5 @@ __git_ps1 ()
printf -- "$printf_format" "$gitstring" printf -- "$printf_format" "$gitstring"
fi fi
# preserve exit status
return $exit return $exit
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册