|
109 | 109 | __git_printf_supports_v=
|
110 | 110 | printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
|
111 | 111 |
|
112 |
| -# stores the divergence from upstream in $p |
| 112 | +# stores the divergence from upstream in $p (for short status) or $upstream (for verbose status) |
113 | 113 | # used by GIT_PS1_SHOWUPSTREAM
|
114 | 114 | __git_ps1_show_upstream ()
|
115 | 115 | {
|
@@ -214,26 +214,26 @@ __git_ps1_show_upstream ()
|
214 | 214 | *) # diverged from upstream
|
215 | 215 | p="<>" ;;
|
216 | 216 | esac
|
217 |
| - else |
| 217 | + else # verbose, set upstream instead of p |
218 | 218 | case "$count" in
|
219 | 219 | "") # no upstream
|
220 |
| - p="" ;; |
| 220 | + upstream="" ;; |
221 | 221 | "0 0") # equal to upstream
|
222 |
| - p=" u=" ;; |
| 222 | + upstream=" u=" ;; |
223 | 223 | "0 "*) # ahead of upstream
|
224 |
| - p=" u+${count#0 }" ;; |
| 224 | + upstream=" u+${count#0 }" ;; |
225 | 225 | *" 0") # behind upstream
|
226 |
| - p=" u-${count% 0}" ;; |
| 226 | + upstream=" u-${count% 0}" ;; |
227 | 227 | *) # diverged from upstream
|
228 |
| - p=" u+${count#* }-${count% *}" ;; |
| 228 | + upstream=" u+${count#* }-${count% *}" ;; |
229 | 229 | esac
|
230 | 230 | if [[ -n "$count" && -n "$name" ]]; then
|
231 | 231 | __git_ps1_upstream_name=$(git rev-parse \
|
232 | 232 | --abbrev-ref "$upstream_type" 2>/dev/null)
|
233 | 233 | if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
|
234 |
| - p="$p \${__git_ps1_upstream_name}" |
| 234 | + upstream="$upstream \${__git_ps1_upstream_name}" |
235 | 235 | else
|
236 |
| - p="$p ${__git_ps1_upstream_name}" |
| 236 | + upstream="$upstream ${__git_ps1_upstream_name}" |
237 | 237 | # not needed anymore; keep user's
|
238 | 238 | # environment clean
|
239 | 239 | unset __git_ps1_upstream_name
|
@@ -512,7 +512,8 @@ __git_ps1 ()
|
512 | 512 | local u=""
|
513 | 513 | local h=""
|
514 | 514 | local c=""
|
515 |
| - local p="" |
| 515 | + local p="" # short version of upstream state indicator |
| 516 | + local upstream="" # verbose version of upstream state indicator |
516 | 517 |
|
517 | 518 | if [ "true" = "$inside_gitdir" ]; then
|
518 | 519 | if [ "true" = "$bare_repo" ]; then
|
@@ -568,8 +569,8 @@ __git_ps1 ()
|
568 | 569 | b="\${__git_ps1_branch_name}"
|
569 | 570 | fi
|
570 | 571 |
|
571 |
| - local f="$h$w$i$s$u" |
572 |
| - local gitstring="$c$b${f:+$z$f}${sparse}$r$p" |
| 572 | + local f="$h$w$i$s$u$p" |
| 573 | + local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}" |
573 | 574 |
|
574 | 575 | if [ $pcmode = yes ]; then
|
575 | 576 | if [ "${__git_printf_supports_v-}" != yes ]; then
|
|
0 commit comments