Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 15981f4

Browse files
erdavilagitster
authored andcommitted
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 <[email protected]> Signed-off-by: Eduardo R. D'Avila <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f3bd62d commit 15981f4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

contrib/completion/git-prompt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ __git_ps1_colorize_gitstring ()
253253
branch_color="$bad_color"
254254
fi
255255
c="$branch_color$c"
256-
b="$b$c_clear"
257256

257+
z="$c_clear$z"
258258
if [ "$w" = "*" ]; then
259259
w="$bad_color$w"
260260
fi

t/t9903-bash-prompt.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ test_expect_success 'prompt - pc mode' '
551551
'
552552

553553
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 &&
555555
(
556556
GIT_PS1_SHOWCOLORHINTS=y &&
557557
__git_ps1 "BEFORE:" ":AFTER" >"$actual"
@@ -561,7 +561,7 @@ test_expect_success 'prompt - bash color pc mode - branch name' '
561561
'
562562

563563
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 &&
565565
git checkout b1^ &&
566566
test_when_finished "git checkout master" &&
567567
(
@@ -627,7 +627,7 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - befo
627627
'
628628

629629
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 &&
631631
echo "dirty" >file &&
632632
test_when_finished "git reset --hard" &&
633633
(
@@ -666,7 +666,7 @@ test_expect_success 'prompt - bash color pc mode - untracked files status indica
666666
'
667667

668668
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 &&
670670
(
671671
ZSH_VERSION=5.0.0 &&
672672
GIT_PS1_SHOWCOLORHINTS=y &&

0 commit comments

Comments
 (0)