summaryrefslogtreecommitdiff
path: root/contrib/completion
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/completion')
-rw-r--r--contrib/completion/git-prompt.sh25
1 files changed, 13 insertions, 12 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 3997e099aa..613389a53b 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -109,7 +109,7 @@
__git_printf_supports_v=
printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
-# stores the divergence from upstream in $p
+# stores the divergence from upstream in $p (for short status) or $upstream (for verbose status)
# used by GIT_PS1_SHOWUPSTREAM
__git_ps1_show_upstream ()
{
@@ -214,26 +214,26 @@ __git_ps1_show_upstream ()
*) # diverged from upstream
p="<>" ;;
esac
- else
+ else # verbose, set upstream instead of p
case "$count" in
"") # no upstream
- p="" ;;
+ upstream="" ;;
"0 0") # equal to upstream
- p=" u=" ;;
+ upstream=" u=" ;;
"0 "*) # ahead of upstream
- p=" u+${count#0 }" ;;
+ upstream=" u+${count#0 }" ;;
*" 0") # behind upstream
- p=" u-${count% 0}" ;;
+ upstream=" u-${count% 0}" ;;
*) # diverged from upstream
- p=" u+${count#* }-${count% *}" ;;
+ upstream=" u+${count#* }-${count% *}" ;;
esac
if [[ -n "$count" && -n "$name" ]]; then
__git_ps1_upstream_name=$(git rev-parse \
--abbrev-ref "$upstream_type" 2>/dev/null)
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
- p="$p \${__git_ps1_upstream_name}"
+ upstream="$upstream \${__git_ps1_upstream_name}"
else
- p="$p ${__git_ps1_upstream_name}"
+ upstream="$upstream ${__git_ps1_upstream_name}"
# not needed anymore; keep user's
# environment clean
unset __git_ps1_upstream_name
@@ -512,7 +512,8 @@ __git_ps1 ()
local u=""
local h=""
local c=""
- local p=""
+ local p="" # short version of upstream state indicator
+ local upstream="" # verbose version of upstream state indicator
if [ "true" = "$inside_gitdir" ]; then
if [ "true" = "$bare_repo" ]; then
@@ -568,8 +569,8 @@ __git_ps1 ()
b="\${__git_ps1_branch_name}"
fi
- local f="$h$w$i$s$u"
- local gitstring="$c$b${f:+$z$f}${sparse}$r$p"
+ local f="$h$w$i$s$u$p"
+ local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}"
if [ $pcmode = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then