Skip to content

Commit f76a3b8

Browse files
joak-petgitster
authored andcommitted
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. Signed-off-by: Joakim Petersen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9470605 commit f76a3b8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

contrib/completion/git-prompt.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,21 +556,21 @@ __git_ps1 ()
556556
fi
557557
fi
558558

559-
b=${b##refs/heads/}
560559
local z="${GIT_PS1_STATESEPARATOR-" "}"
561560

561+
b=${b##refs/heads/}
562+
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
563+
__git_ps1_branch_name=$b
564+
b="\${__git_ps1_branch_name}"
565+
fi
566+
562567
# NO color option unless in PROMPT_COMMAND mode or it's Zsh
563568
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
564569
if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
565570
__git_ps1_colorize_gitstring
566571
fi
567572
fi
568573

569-
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
570-
__git_ps1_branch_name=$b
571-
b="\${__git_ps1_branch_name}"
572-
fi
573-
574574
local f="$h$w$i$s$u$p"
575575
local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}"
576576

0 commit comments

Comments
 (0)