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

[PATCH 1/3] bisect: use string arguments to feed internal diff-tree

From
Jeff King <peff@peff.net>
Date
Feb 22, 2019, 06:20 UTC
Message-ID
<20190222062037.GA10248@sigill.intra.peff.net>
In-Reply-To
<20190222061949.GA9875@sigill.intra.peff.net>

Commit e22278c0a0 (bisect: display first bad commit without forking a new process, 2009-05-28) converted our external call to diff-tree to an internal use of the log_tree_commit(). But rather than individually setting options in the rev_info struct (and explaining in comments how they map to command-line options), we can just pass the command-line options to setup_revisions().

This is shorter, easier to change, and less likely to break if revision.c internals change.

Note that we unconditionally set the output format to "raw". The conditional in the original code didn't actually do anything useful, since nobody had an opportunity to set the format to anything.

Signed-off-by: Jeff King <peff@peff.net>
---
 bisect.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/bisect.c b/bisect.c
index 3af955c4bc..8c81859835 100644
--- a/bisect.c
+++ b/bisect.c
@@ -896,24 +896,15 @@ static void show_diff_tree(struct repository *r,
 			   const char *prefix,
 			   struct commit *commit)
 {
+	const char *argv[] = {
+		"diff-tree", "--pretty", "--no-abbrev", "--raw", NULL
+	};
 	struct rev_info opt;
 
-	/* diff-tree init */
 	repo_init_revisions(r, &opt, prefix);
 	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
-	opt.abbrev = 0;
-	opt.diff = 1;
 
-	/* This is what "--pretty" does */
-	opt.verbose_header = 1;
-	opt.use_terminator = 0;
-	opt.commit_format = CMIT_FMT_DEFAULT;
-
-	/* diff-tree init */
-	if (!opt.diffopt.output_format)
-		opt.diffopt.output_format = DIFF_FORMAT_RAW;
-
-	setup_revisions(0, NULL, &opt, NULL);
+	setup_revisions(ARRAY_SIZE(argv) - 1, argv, &opt, NULL);
 	log_tree_commit(&opt, commit);
 }
 
-- 
2.21.0.rc2.577.g06bbe9cbd1
Previous: Jeff KingNext: Jeff King
Message 4 of 14 in “git bisect - good vs bad output is different.”
  1. Bartosz BaranowskiFeb 21, 2019
  2. Junio C HamanoFeb 21, 2019
  3. 0/3 prettier bisect outputJeff King, Feb 22, 2019
  4. 1/3 bisect: use string arguments to feed internal diff-treeJeff King, Feb 22, 2019
  5. 2/3 bisect: fix internal diff-tree config loadingJeff King, Feb 22, 2019
  6. Christian CouderMar 3, 2019
  7. Jeff KingMar 5, 2019
  8. 3/3 bisect: make diff-tree output prettierJeff King, Feb 22, 2019
  9. Junio C HamanoFeb 22, 2019
  10. Jeff KingFeb 23, 2019
  11. Christian CouderMar 3, 2019
  12. Junio C HamanoFeb 22, 2019
  13. Christian CouderMar 3, 2019
  14. Jeff KingMar 5, 2019

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.