git-prompt.sh: do not print duplicate clean color code

Do not print a duplicate clean color code when there is no other indicators other than the current branch in colored prompt. Acked-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Eduardo R. D'Avila <erdavila@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eduardo R. D'Avila committed Jun 26, 2013 at 00:05 UTC 15981f4eec9c6a7c12b9c0fbe98e68228c46edb7
2 files changed +5 -5
contrib/completion/git-prompt.sh
+1 -1
@@ -253,8 +253,8 @@ __git_ps1_colorize_gitstring ()
253 branch_color="$bad_color"
254 fi
255 c="$branch_color$c"
256 - b="$b$c_clear"
256
257 + z="$c_clear$z"
258 if [ "$w" = "*" ]; then
259 w="$bad_color$w"
260 fi
t/t9903-bash-prompt.sh
+4 -4
@@ -551,7 +551,7 @@ test_expect_success 'prompt - pc mode' '
551 '
552
553 test_expect_success 'prompt - bash color pc mode - branch name' '
554 - printf "BEFORE: (${c_green}master${c_clear}${c_clear}):AFTER" >expected &&
554 + printf "BEFORE: (${c_green}master${c_clear}):AFTER" >expected &&
555 (
556 GIT_PS1_SHOWCOLORHINTS=y &&
557 __git_ps1 "BEFORE:" ":AFTER" >"$actual"
@@ -561,7 +561,7 @@ test_expect_success 'prompt - bash color pc mode - branch name' '
561 '
562
563 test_expect_success 'prompt - bash color pc mode - detached head' '
564 - printf "BEFORE: (${c_red}(%s...)${c_clear}${c_clear}):AFTER" $(git log -1 --format="%h" b1^) >expected &&
564 + printf "BEFORE: (${c_red}(%s...)${c_clear}):AFTER" $(git log -1 --format="%h" b1^) >expected &&
565 git checkout b1^ &&
566 test_when_finished "git checkout master" &&
567 (
@@ -627,7 +627,7 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - befo
627 '
628
629 test_expect_success 'prompt - bash color pc mode - inside .git directory' '
630 - printf "BEFORE: (${c_green}GIT_DIR!${c_clear}${c_clear}):AFTER" >expected &&
630 + printf "BEFORE: (${c_green}GIT_DIR!${c_clear}):AFTER" >expected &&
631 echo "dirty" >file &&
632 test_when_finished "git reset --hard" &&
633 (
@@ -666,7 +666,7 @@ test_expect_success 'prompt - bash color pc mode - untracked files status indica
666 '
667
668 test_expect_success 'prompt - zsh color pc mode' '
669 - printf "BEFORE: (%%F{green}master%%f%%f):AFTER" >expected &&
669 + printf "BEFORE: (%%F{green}master%%f):AFTER" >expected &&
670 (
671 ZSH_VERSION=5.0.0 &&
672 GIT_PS1_SHOWCOLORHINTS=y &&