Skip to content

Commit 51d2d67

Browse files
justinrdonnellygitster
authored andcommitted
git-prompt: make long upstream state indicator consistent
Use a pipe as a separator before long upstream state indicator. This is consistent with long state indicators for sparse and in-progress operations (e.g. merge). For comparison, `__git_ps1` examples without upstream state indicator: (main) (main %) (main *%) (main|SPARSE) (main %|SPARSE) (main *%|SPARSE) (main|SPARSE|REBASE 1/2) (main %|SPARSE|REBASE 1/2) Note that if there are long state indicators, they appear after short state indicators if there are any, or after the branch name if there are no short state indicators. Each long state indicator begins with a pipe (`|`) as a separator. Before/after examples with long upstream state indicator: | Before | After | | ------------------------------- | ------------------------------- | | (main u=) | (main|u=) | | (main u= origin/main) | (main|u= origin/main) | | (main u+1) | (main|u+1) | | (main u+1 origin/main) | (main|u+1 origin/main) | | (main % u=) | (main %|u=) | | (main % u= origin/main) | (main %|u= origin/main) | | (main % u+1) | (main %|u+1) | | (main % u+1 origin/main) | (main %|u+1 origin/main) | | (main|SPARSE u=) | (main|SPARSE|u=) | | (main|SPARSE u= origin/main) | (main|SPARSE|u= origin/main) | | (main|SPARSE u+1) | (main|SPARSE|u+1) | | (main|SPARSE u+1 origin/main) | (main|SPARSE|u+1 origin/main) | | (main %|SPARSE u=) | (main %|SPARSE|u=) | | (main %|SPARSE u= origin/main) | (main %|SPARSE|u= origin/main) | | (main %|SPARSE u+1) | (main %|SPARSE|u+1) | | (main %|SPARSE u+1 origin/main) | (main %|SPARSE|u+1 origin/main) | Signed-off-by: Justin Donnelly <[email protected]> Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0ec7c23 commit 51d2d67

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

contrib/completion/git-prompt.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
__git_printf_supports_v=
110110
printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
111111

112-
# stores the divergence from upstream in $p (for short status) or $upstream (for verbose status)
112+
# stores the divergence from upstream in $p
113113
# used by GIT_PS1_SHOWUPSTREAM
114114
__git_ps1_show_upstream ()
115115
{
@@ -219,13 +219,13 @@ __git_ps1_show_upstream ()
219219
"") # no upstream
220220
upstream="" ;;
221221
"0 0") # equal to upstream
222-
upstream=" u=" ;;
222+
upstream="|u=" ;;
223223
"0 "*) # ahead of upstream
224-
upstream=" u+${count#0 }" ;;
224+
upstream="|u+${count#0 }" ;;
225225
*" 0") # behind upstream
226-
upstream=" u-${count% 0}" ;;
226+
upstream="|u-${count% 0}" ;;
227227
*) # diverged from upstream
228-
upstream=" u+${count#* }-${count% *}" ;;
228+
upstream="|u+${count#* }-${count% *}" ;;
229229
esac
230230
if [[ -n "$count" && -n "$name" ]]; then
231231
__git_ps1_upstream_name=$(git rev-parse \

0 commit comments

Comments
 (0)