git-prompt: make upstream state indicator location consistent
commit0ec7c23cdc6bde5af3039c59e21507adf7579a99
authorJustin Donnelly <justinrdonnelly@gmail.com>
Sun, 27 Feb 2022 19:57:10 +0000 (27 19:57 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Mar 2022 20:07:40 +0000 (23 13:07 -0700)
tree8e84398b0655b1cac82bf6a951c825fabd373d6a
parent4d9dc2c57a36027a619c3b846cce5f02206d9a06
git-prompt: make upstream state indicator location consistent

Make upstream state indicator location more consistent with similar
state indicators (e.g. sparse). Group the short upstream state indicator
(`=`, `<`, `>`, or `<>`) with other short state indicators immediately
after the branch name. Previously short and long upstream state
indicators appeared after all other state indicators.

Use a separator (`SP` or `GIT_PS1_STATESEPARATOR`) between branch name
and short upstream state indicator. Previously the short upstream state
indicator would sometimes appear directly adjacent to the branch name
instead of being separated.

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 short state indicators, they appear together
after the branch name and separated from it by `SP` or
`GIT_PS1_STATESEPARATOR`.

Before/after examples with short upstream state indicator:
| Before           | After            |
| ---------------- | ---------------- |
| (main=)          | (main =)         |
| (main|SPARSE=)   | (main =|SPARSE)  |
| (main %|SPARSE=) | (main %=|SPARSE) |

Signed-off-by: Justin Donnelly <justinrdonnelly@gmail.com>
Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-prompt.sh