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

[PATCH] diff-tree: obey the color.ui configuration

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Dec 29, 2017, 22:51 UTC
Message-ID
<20171229225121.13805-1-avarab@gmail.com>
In-Reply-To
<87zi616vgf.fsf@evledraar.gmail.com>

Before git-bisect exits it calls `diff-tree --pretty --stat $commit` on the bad commit. This would always print the "commit" line with coloring despite color.ui being set to "never".

Teach diff-tree to look at the git_color_config() configuration. I initially tried to add this to git_diff_basic_config itself, but it makes other unrelated things fail, and this is a more isolated change that solves the issue.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

No idea how to test this, in particular trying to pipe the output of color.ui=never v.s. color.ui=auto to a file as "auto" will disable coloring when it detects a pipe, but this fixes the issue.

 builtin/diff-tree.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index b775a75647..0311c01a87 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -97,6 +97,15 @@ static void diff_tree_tweak_rev(struct rev_info *rev, struct setup_revision_opt
 	}
 }
 
+
+static int diff_tree_config(const char *var, const char *value, void *cb)
+{
+	if (git_color_config(var, value, cb) < 0)
+		return -1;
+
+	return git_diff_basic_config(var, value, cb);
+}
+
 int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 {
 	char line[1000];
@@ -108,7 +117,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 	if (argc == 2 && !strcmp(argv[1], "-h"))
 		usage(diff_tree_usage);
 
-	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
+	git_config(diff_tree_config, NULL); /* no "diff" UI options */
 	init_revisions(opt, prefix);
 	if (read_cache() < 0)
 		die(_("index file corrupt"));
-- 
2.15.1.424.g9478a66081
Previous: Ævar Arnfjörð BjarmasonNext: Todd Zullinger
Message 3 of 10 in “[BUG] git bisect colour output contrary to configuration”
  1. ZeframDec 29, 2017
  2. Ævar Arnfjörð BjarmasonDec 29, 2017
  3. diff-tree: obey the color.ui configurationÆvar Arnfjörð Bjarmason, Dec 29, 2017
  4. Todd ZullingerDec 29, 2017
  5. Jeff KingDec 30, 2017
  6. Ævar Arnfjörð BjarmasonDec 30, 2017
  7. Jeff KingDec 30, 2017
  8. Ævar Arnfjörð BjarmasonDec 30, 2017
  9. Jeff KingDec 30, 2017
  10. Christian CouderDec 30, 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.