git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/4] tag: respect color.ui config

From
Jeff King <peff@peff.net>
Date
Oct 13, 2017, 17:26 UTC
Message-ID
<20171013172601.spqiyuutxs4fmlgz@sigill.intra.peff.net>
In-Reply-To
<20171013172020.adc2fkddgp3g2ses@sigill.intra.peff.net>

Since 11b087adfd (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 136c8c8b8f (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 136c8c8b8f, 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 0c88bf5050 (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 136c8c8b8f. But as a plumbing command, it should _not_ respect the color.ui config. Since it also gained a --color option in 0c88bf5050, 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 <peff@peff.net>
---
 builtin/tag.c           | 2 +-
 t/t6300-for-each-ref.sh | 5 +++++
 t/t7004-tag.sh          | 6 ++++++
 3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/builtin/tag.c b/builtin/tag.c
index 695cb0778e..b38329b593 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -158,7 +158,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)
 
 	if (starts_with(var, "column."))
 		return git_column_config(var, value, "tag", &colopts);
-	return git_default_config(var, value, cb);
+	return git_color_default_config(var, value, cb);
 }
 
 static void write_tag_body(int fd, const struct object_id *oid)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 416ff7d0b8..3aa534933e 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -442,6 +442,11 @@ test_expect_success '--color can override tty check' '
 	test_cmp expected.color actual
 '
 
+test_expect_success 'color.ui=always does not override tty check' '
+	git -c color.ui=always for-each-ref --format="$color_format" >actual &&
+	test_cmp expected.bare actual
+'
+
 cat >expected <<\EOF
 heads/master
 tags/master
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 4e62c505fc..a9af2de996 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1918,6 +1918,12 @@ test_expect_success '--color overrides auto-color' '
 	test_cmp expect.color actual
 '
 
+test_expect_success 'color.ui=always overrides auto-color' '
+	git -c color.ui=always tag $color_args >actual.raw &&
+	test_decode_color <actual.raw >actual &&
+	test_cmp expect.color actual
+'
+
 test_expect_success 'setup --merged test tags' '
 	git tag mergetest-1 HEAD~2 &&
 	git tag mergetest-2 HEAD~1 &&
-- 
2.15.0.rc1.395.ga4290b5804
Previous: Jeff KingNext: Junio C Hamano
Message 34 of 42 in “What happened to "git status --color=(always|auto|never)"?”
  1. Nazri RamliyOct 9, 2017
  2. Jonathan NiederOct 10, 2017
  3. Nazri RamliyOct 10, 2017
  4. Jonathan NiederOct 10, 2017
  5. Nazri RamliyOct 10, 2017
  6. Jeff KingOct 10, 2017
  7. Junio C HamanoOct 10, 2017
  8. Jeff KingOct 10, 2017
  9. Jonathan NiederOct 10, 2017
  10. Jeff KingOct 10, 2017
  11. Junio C HamanoOct 11, 2017
  12. 0/2 Piling more kludge on top of color.uiJunio C Hamano, Oct 12, 2017
  13. 2/2 color: discourage use of ui.color=alwaysJunio C Hamano, Oct 12, 2017
  14. Jonathan NiederOct 12, 2017
  15. Jeff KingOct 12, 2017
  16. Junio C HamanoOct 13, 2017
  17. 1/2 color: downgrade "always" to "auto" only for on-disk configurationJunio C Hamano, Oct 12, 2017
  18. Jonathan NiederOct 12, 2017
  19. Junio C HamanoOct 12, 2017
  20. Jonathan NiederOct 12, 2017
  21. Junio C HamanoOct 12, 2017
  22. Junio C HamanoOct 12, 2017
  23. Jeff KingOct 12, 2017
  24. Jeff KingOct 12, 2017
  25. Jeff KingOct 12, 2017
  26. Junio C HamanoOct 13, 2017
  27. Jeff KingOct 13, 2017
  28. Junio C HamanoOct 13, 2017
  29. Jeff KingOct 13, 2017
  30. 0/4 peeling back color.ui=always hacksJeff King, Oct 13, 2017
  31. 1/4 Revert "color: make "always" the same as "auto" in config"Jeff King, Oct 13, 2017
  32. 2/4 Revert "t6006: drop "always" color config tests"Jeff King, Oct 13, 2017
  33. 3/4 Revert "color: check color.ui in git_default_config()"Jeff King, Oct 13, 2017
  34. 4/4 tag: respect color.ui configJeff King, Oct 13, 2017
  35. Junio C HamanoOct 14, 2017
  36. Jeff KingOct 16, 2017
  37. Junio C HamanoOct 17, 2017
  38. Junio C HamanoOct 17, 2017
  39. Jeff KingOct 18, 2017
  40. Junio C HamanoOct 18, 2017
  41. Jonathan NiederOct 17, 2017
  42. Jeff KingOct 18, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.