Skip to content

Commit

Permalink
git-prompt.sh: do not print duplicate clean color code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eduardo R. D'Avila authored and Junio C Hamano committed Jun 26, 2013
1 parent f3bd62d commit 15981f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contrib/completion/git-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ __git_ps1_colorize_gitstring ()
branch_color="$bad_color"
fi
c="$branch_color$c"
b="$b$c_clear"

z="$c_clear$z"
if [ "$w" = "*" ]; then
w="$bad_color$w"
fi
Expand Down
8 changes: 4 additions & 4 deletions t/t9903-bash-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ test_expect_success 'prompt - pc mode' '
'

test_expect_success 'prompt - bash color pc mode - branch name' '
printf "BEFORE: (${c_green}master${c_clear}${c_clear}):AFTER" >expected &&
printf "BEFORE: (${c_green}master${c_clear}):AFTER" >expected &&
(
GIT_PS1_SHOWCOLORHINTS=y &&
__git_ps1 "BEFORE:" ":AFTER" >"$actual"
Expand All @@ -561,7 +561,7 @@ test_expect_success 'prompt - bash color pc mode - branch name' '
'

test_expect_success 'prompt - bash color pc mode - detached head' '
printf "BEFORE: (${c_red}(%s...)${c_clear}${c_clear}):AFTER" $(git log -1 --format="%h" b1^) >expected &&
printf "BEFORE: (${c_red}(%s...)${c_clear}):AFTER" $(git log -1 --format="%h" b1^) >expected &&
git checkout b1^ &&
test_when_finished "git checkout master" &&
(
Expand Down Expand Up @@ -627,7 +627,7 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - befo
'

test_expect_success 'prompt - bash color pc mode - inside .git directory' '
printf "BEFORE: (${c_green}GIT_DIR!${c_clear}${c_clear}):AFTER" >expected &&
printf "BEFORE: (${c_green}GIT_DIR!${c_clear}):AFTER" >expected &&
echo "dirty" >file &&
test_when_finished "git reset --hard" &&
(
Expand Down Expand Up @@ -666,7 +666,7 @@ test_expect_success 'prompt - bash color pc mode - untracked files status indica
'

test_expect_success 'prompt - zsh color pc mode' '
printf "BEFORE: (%%F{green}master%%f%%f):AFTER" >expected &&
printf "BEFORE: (%%F{green}master%%f):AFTER" >expected &&
(
ZSH_VERSION=5.0.0 &&
GIT_PS1_SHOWCOLORHINTS=y &&
Expand Down

0 comments on commit 15981f4

Please sign in to comment.