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

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

From
Jeff King <peff@peff.net>
Date
Dec 30, 2017, 18:15 UTC
Message-ID
<20171230181557.GA30351@sigill.intra.peff.net>
In-Reply-To
<87po6w6yul.fsf@evledraar.gmail.com>
On Sat, Dec 30, 2017 at 04:04:50PM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 22 quoted lines
> > I do like the idea of using "show", though. We know the point is to show
> > the output to the user, so we don't mind at all if the behavior or
> > output of show changes in future versions (unless we consider the final
> > output of bisect to be machine-readable, but I certainly don't).
> 
> Not knowing the internal APIs for that well, is this basically a matter
> of copy/pasting (or factoring out into a function), some of this:
> 
>     git grep -W cmd_show -- builtin/log.c
> 
> I.e. boilerplate + calling cmd_log_walk() to yield a result similar to
> e22278c0a0 ("bisect: display first bad commit without forking a new
> process", 2009-05-28).
> 
> Or is it preferred to just fake up argc/argv and call cmd_show()
> directly? I haven't seen many examples of that in the codebase:
> 
>     git grep -W '(return|=)\s*cmd.*argc' -- '*.c'
> 
> But I don't see why it wouldn't work, the cmd_show() doesn't call exit()
> itself, and we're right about to call exit anyway when our current
> diff-tree invocation is called.

Hmm, I just assumed we were actually calling diff-tree. But looking at that code in bisect, it literally is calling log_tree_commit(), which is the same thing that git-show is doing.

So yet another option is to just set up our options similarly:
diff --git a/bisect.c b/bisect.c
index 0fca17c02b..1eadecd42a 100644
--- a/bisect.c
+++ b/bisect.c
@@ -893,9 +893,11 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
 
 	/* diff-tree init */
 	init_revisions(&opt, prefix);
-	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
+	git_config(git_diff_ui_config, NULL);
 	opt.abbrev = 0;
 	opt.diff = 1;
+	opt.combine_merges = 1;
+	opt.dense_combined_merges = 1;
 
 	/* This is what "--pretty" does */
 	opt.verbose_header = 1;

Though I do kind of like the idea of just delegating to git-show.
There's no real need for us to have our own logic.

I think calling cmd_show() from bisect.c is supposed to be forbidden
(library code shouldn't call up to builtin code). I was going to suggest
just using run_command() to call git-show. After all, we do this only
once at the very end of the bisection (which is pretty heavy-weight, as
it surely has forked a lot of processes to do the actual testing).

But that would be directly undoing Christian's e22278c0a0 (bisect:
display first bad commit without forking a new process, 2009-05-28). I'm
of the opinion that would be OK, but maybe Christian has input. :)

-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Christian Couder
Message 9 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.