Skip to content

Commit b521fd1

Browse files
peffgitster
authored andcommitted
tag: respect color.ui config
Since 11b087a (ref-filter: consult want_color() before emitting colors, 2017-07-13), we expect that setting "color.ui" to "always" will enable color tag formats even without a tty. As that commit was built on top of 136c8c8 (color: check color.ui in git_default_config(), 2017-07-13) from the same series, we didn't need to touch tag's config parsing at all. However, since we reverted 136c8c8, we now need to explicitly call git_color_default_config() to make this work. Let's do so, and also restore the test dropped in 0c88bf5 (provide --color option for all ref-filter users, 2017-10-03). That commit swapped out our "color.ui=always" test for "--color" in preparation for "always" going away. But since it is here to stay, we should test both cases. Note that for-each-ref also lost its color.ui support as part of reverting 136c8c8. But as a plumbing command, it should _not_ respect the color.ui config. Since it also gained a --color option in 0c88bf5, that's the correct way to ask it for color. We'll continue to test that, and confirm that "color.ui" is not respected. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 33c643b commit b521fd1

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)
158158

159159
if (starts_with(var, "column."))
160160
return git_column_config(var, value, "tag", &colopts);
161-
return git_default_config(var, value, cb);
161+
return git_color_default_config(var, value, cb);
162162
}
163163

164164
static void write_tag_body(int fd, const struct object_id *oid)

t/t6300-for-each-ref.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ test_expect_success '--color can override tty check' '
441441
test_cmp expected.color actual
442442
'
443443

444+
test_expect_success 'color.ui=always does not override tty check' '
445+
git -c color.ui=always for-each-ref --format="$color_format" >actual &&
446+
test_cmp expected.bare actual
447+
'
448+
444449
cat >expected <<\EOF
445450
heads/master
446451
tags/master

t/t7004-tag.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,12 @@ test_expect_success '--color overrides auto-color' '
19251925
test_cmp expect.color actual
19261926
'
19271927

1928+
test_expect_success 'color.ui=always overrides auto-color' '
1929+
git -c color.ui=always tag $color_args >actual.raw &&
1930+
test_decode_color <actual.raw >actual &&
1931+
test_cmp expect.color actual
1932+
'
1933+
19281934
test_expect_success 'setup --merged test tags' '
19291935
git tag mergetest-1 HEAD~2 &&
19301936
git tag mergetest-2 HEAD~1 &&

0 commit comments

Comments
 (0)