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

[PATCH 2/3] diff: clean up external-diff argv setup

From
Jeff King <peff@peff.net>
Date
Jan 6, 2023, 11:04 UTC
Message-ID
<Y7gAMoEpF4k3hc92@coredump.intra.peff.net>
In-Reply-To
<Y7f/YiVu1TgbucDI@coredump.intra.peff.net>

Since the previous commit, setting up the tempfile for an external diff uses df->path from the diff_filespec, rather than the logical name. This means add_external_diff_name() does not need to take a "name" parameter at all, and we can drop it. And that in turn lets us simplify the conditional for handling renames (when the "other" name is non-NULL).

Signed-off-by: Jeff King <peff@peff.net>
---
 diff.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/diff.c b/diff.c
index 59039773a1..72bed1d0a3 100644
--- a/diff.c
+++ b/diff.c
@@ -4278,7 +4278,6 @@ static struct diff_tempfile *prepare_temp_file(struct repository *r,
 
 static void add_external_diff_name(struct repository *r,
 				   struct strvec *argv,
-				   const char *name,
 				   struct diff_filespec *df)
 {
 	struct diff_tempfile *temp = prepare_temp_file(r, df->path, df);
@@ -4308,11 +4307,9 @@ static void run_external_diff(const char *pgm,
 	strvec_push(&cmd.args, name);
 
 	if (one && two) {
-		add_external_diff_name(o->repo, &cmd.args, name, one);
-		if (!other)
-			add_external_diff_name(o->repo, &cmd.args, name, two);
-		else {
-			add_external_diff_name(o->repo, &cmd.args, other, two);
+		add_external_diff_name(o->repo, &cmd.args, one);
+		add_external_diff_name(o->repo, &cmd.args, two);
+		if (other) {
 			strvec_push(&cmd.args, other);
 			strvec_push(&cmd.args, xfrm_msg);
 		}
-- 
2.39.0.463.g3774f23bc9
Previous: Jeff KingNext: Jeff King
Message 6 of 7 in “Problem with git diff --relative, diff.external, run from a sub-directory”
  1. Carl BaldwinJan 4, 2023
  2. 0/3 fixing "diff --relative" with external diffJeff King, Jan 6, 2023
  3. 1/3 diff: use filespec path to set up tempfiles for ext-diffJeff King, Jan 6, 2023
  4. Junio C HamanoJan 6, 2023
  5. Jeff KingJan 6, 2023
  6. 2/3 diff: clean up external-diff argv setupJeff King, Jan 6, 2023
  7. 3/3 diff: drop "name" parameter from prepare_temp_file()Jeff King, Jan 6, 2023

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.