diff options
author | Joakim Petersen <joak-pet@online.no> | 2022-06-10 03:47:37 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-06-10 19:41:49 +0300 |
commit | 0e5d9ef395467619b621540a7fdefbfc8062f2ac (patch) | |
tree | edee32c9959ccfbeedb3118f60050ade9aa2dade /contrib/completion/git-prompt.sh | |
parent | 9470605a1b03dac8fc4f801132e36964b4fbb8c3 (diff) |
git-prompt: fix expansion of branch colour codes
Because of the wrapping of the branch name variable $b, the colour codes
in the variable don't get applied, but are instead printed directly in
the output. Move the wrapping of $b to before colour codes are inserted
to correct this. Revert move of branch name colour codes in tests, as
the branch name is now coloured after the wrapping instead of before.
Signed-off-by: Joakim Petersen <joak-pet@online.no>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/completion/git-prompt.sh')
-rw-r--r-- | contrib/completion/git-prompt.sh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index cb01c2fd5d..1435548e00 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -556,9 +556,14 @@ __git_ps1 () fi fi - b=${b##refs/heads/} local z="${GIT_PS1_STATESEPARATOR-" "}" + b=${b##refs/heads/} + if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then + __git_ps1_branch_name=$b + b="\${__git_ps1_branch_name}" + fi + # NO color option unless in PROMPT_COMMAND mode or it's Zsh if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then @@ -566,11 +571,6 @@ __git_ps1 () fi fi - if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then - __git_ps1_branch_name=$b - b="\${__git_ps1_branch_name}" - fi - local f="$h$w$i$s$u$p" local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}" |