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 <ava...@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

Reply via email to