summaryrefslogtreecommitdiff
path: root/contrib/completion/git-prompt.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-01-14 20:35:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-01-14 20:35:49 (GMT)
commit9920c718254d946e685ef1295ff9ea0c14bac9cf (patch)
treea0deed91f07bfb9532f5f91a52199f9a5d838ff8 /contrib/completion/git-prompt.sh
parente1ef7d177c3fcfdd25df9c4b67d36012bedebd74 (diff)
parent6babe76496db332d589c1a2e0a2344fe41ca1dd5 (diff)
downloadgit-9920c718254d946e685ef1295ff9ea0c14bac9cf.zip
git-9920c718254d946e685ef1295ff9ea0c14bac9cf.tar.gz
git-9920c718254d946e685ef1295ff9ea0c14bac9cf.tar.bz2
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
Diffstat (limited to 'contrib/completion/git-prompt.sh')
-rw-r--r--contrib/completion/git-prompt.sh10
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index c0f62b5..214e859 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -293,6 +293,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
@@ -312,7 +313,7 @@ __git_ps1 ()
;;
0|1) printf_format="${1:-$printf_format}"
;;
- *) return
+ *) return $exit
;;
esac
@@ -360,7 +361,7 @@ __git_ps1 ()
rev_parse_exit_code="$?"
if [ -z "$repo_info" ]; then
- return
+ return $exit
fi
local short_sha
@@ -380,7 +381,7 @@ __git_ps1 ()
[ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
git check-ignore -q .
then
- return
+ return $exit
fi
local r=""
@@ -426,7 +427,7 @@ __git_ps1 ()
else
local head=""
if ! __git_eread "$g/HEAD" head; then
- return
+ return $exit
fi
# is it a symbolic ref?
b="${head#ref: }"
@@ -523,6 +524,5 @@ __git_ps1 ()
printf -- "$printf_format" "$gitstring"
fi
- # preserve exit status
return $exit
}