]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pretty: let %C(auto) reset all attributes
authorRené Scharfe <l.s.r@web.de>
Sat, 17 Sep 2016 18:25:24 +0000 (20:25 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Sep 2016 17:50:32 +0000 (10:50 -0700)
Reset colors and attributes upon %C(auto) to enable full automatic
control over them; otherwise attributes like bold or reverse could
still be in effect from previous %C placeholders.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty.c
t/t6006-rev-list-format.sh

index 3908e8f100b4b26ff417890e1aceca54ce5310fd..b86c5bb907ee8607d054f8afde6ab15f8c90a183 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -1062,6 +1062,8 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
        case 'C':
                if (starts_with(placeholder + 1, "(auto)")) {
                        c->auto_color = want_color(c->pretty_ctx->color);
+                       if (c->auto_color)
+                               strbuf_addstr(sb, GIT_COLOR_RESET);
                        return 7; /* consumed 7 bytes, "C(auto)" */
                } else {
                        int ret = parse_color(sb, placeholder, c);
index a1dcdb81d789cfa2d0e8fcc178311a807a608771..f6020cd2aa9b726f11ef0b93ecb2ce8227a1017c 100755 (executable)
@@ -225,7 +225,7 @@ test_expect_success '%C(auto,...) respects --color=auto (stdout not tty)' '
 
 test_expect_success '%C(auto) respects --color' '
        git log --color --format="%C(auto)%H" -1 >actual &&
-       printf "\\033[33m%s\\033[m\\n" $(git rev-parse HEAD) >expect &&
+       printf "\\033[m\\033[33m%s\\033[m\\n" $(git rev-parse HEAD) >expect &&
        test_cmp expect actual
 '