diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-06-17 12:53:37 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-06-28 09:33:06 -0700 |
commit | 4465690cd838017208d297a7f77d00ec51ccf7fd (patch) | |
tree | b29d8151acaf639d85609480ce00815a9ea2b84a /builtin/show-branch.c | |
parent | show-branch tests: modernize test code (diff) | |
download | tgif-4465690cd838017208d297a7f77d00ec51ccf7fd.tar.xz |
show-branch: don't <COLOR></RESET> for space characters
Change the colored output introduced in ab07ba2a24 (show-branch: color
the commit status signs, 2009-04-22) to not color and reset each
individual space character we use for padding. The intent is to color
just the "!", "+" etc. characters.
This makes the output easier to test, so let's do that now. The test
would be much more verbose without a color/reset for each space
character. Since the coloring cycles through colors we previously had
a "rainbow of space characters".
In theory this breaks things for anyone who's relying on the exact
colored output of show-branch, in practice I'd think anyone parsing it
isn't actively turning on the colored output.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/show-branch.c')
-rw-r--r-- | builtin/show-branch.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/builtin/show-branch.c b/builtin/show-branch.c index d6d2dabeca..d77ce7aeb3 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -939,9 +939,12 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) mark = '*'; else mark = '+'; - printf("%s%c%s", - get_color_code(i), - mark, get_color_reset_code()); + if (mark == ' ') + putchar(mark); + else + printf("%s%c%s", + get_color_code(i), + mark, get_color_reset_code()); } putchar(' '); } |