for-each-ref: avoid color leakage

To make sure that an invocation like the following doesn't leak color,

  $ git for-each-ref --format='%(subject)%(color:green)'

auto-reset at the end of the format string when the last color token
seen in the format string isn't a color-reset.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ramkumar Ramachandra
2013-11-18 23:09:13 +05:30
committed by Junio C Hamano
parent fddb74c947
commit db64eb655b
2 changed files with 24 additions and 6 deletions

View File

@ -356,7 +356,7 @@ $(git rev-parse --short refs/tags/two) $(get_color green)two$(get_color reset)
EOF
test_expect_success 'Check %(color:...) ' '
git for-each-ref --format="%(objectname:short) %(color:green)%(refname:short)%(color:reset)" >actual &&
git for-each-ref --format="%(objectname:short) %(color:green)%(refname:short)" >actual &&
test_cmp expected actual
'