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

[PATCH 3/4] merge-recursive: remove final remaining caller of merge_file_one()

From
Elijah Newren <newren@gmail.com>
Date
Sep 19, 2018, 16:14 UTC
Message-ID
<20180919161434.3272-4-newren@gmail.com>
In-Reply-To
<20180919161434.3272-1-newren@gmail.com>

The function names merge_file_one() and merge_file_1() aren't particularly intuitive function names, especially since there is no associated merge_file() function that these are related to. The previous commit showed that merge_file_one() was prone to be called when merge_file_1() should be, and since it is just a thin wrapper around merge_file_1() anyway and only has one caller left, let's just remove merge_file_one() entirely.

(It also turns out that the one remaining caller of merge_file_one() has very broken code that needs to be completely rewritten, but that's the subject of a future patch series; for now, we're just translating it into a merge_file_1() call.)

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-recursive.c | 44 +++++++++++++++++---------------------------
 1 file changed, 17 insertions(+), 27 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index 9e4e3da672..2654a8a485 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1366,27 +1366,6 @@ static int merge_file_1(struct merge_options *o,
 	return 0;
 }
 
-static int merge_file_one(struct merge_options *o,
-			  const char *path,
-			  const struct object_id *o_oid, int o_mode,
-			  const struct object_id *a_oid, int a_mode,
-			  const struct object_id *b_oid, int b_mode,
-			  const char *branch1,
-			  const char *branch2,
-			  struct merge_file_info *mfi)
-{
-	struct diff_filespec one, a, b;
-
-	one.path = a.path = b.path = (char *)path;
-	oidcpy(&one.oid, o_oid);
-	one.mode = o_mode;
-	oidcpy(&a.oid, a_oid);
-	a.mode = a_mode;
-	oidcpy(&b.oid, b_oid);
-	b.mode = b_mode;
-	return merge_file_1(o, &one, &a, &b, path, branch1, branch2, mfi);
-}
-
 static int handle_rename_via_dir(struct merge_options *o,
 				 struct diff_filepair *pair,
 				 const char *rename_branch,
@@ -2730,12 +2709,23 @@ static int process_renames(struct merge_options *o,
 				       ren1_dst, branch2);
 				if (o->call_depth) {
 					struct merge_file_info mfi;
-					if (merge_file_one(o, ren1_dst, &null_oid, 0,
-							   &ren1->pair->two->oid,
-							   ren1->pair->two->mode,
-							   &dst_other.oid,
-							   dst_other.mode,
-							   branch1, branch2, &mfi)) {
+					struct diff_filespec one, a, b;
+
+					oidcpy(&one.oid, &null_oid);
+					one.mode = 0;
+					one.path = ren1->pair->two->path;
+
+					oidcpy(&a.oid, &ren1->pair->two->oid);
+					a.mode = ren1->pair->two->mode;
+					a.path = one.path;
+
+					oidcpy(&b.oid, &dst_other.oid);
+					b.mode = dst_other.mode;
+					b.path = one.path;
+
+					if (merge_file_1(o, &one, &a, &b, ren1_dst,
+							 branch1, branch2,
+							 &mfi)) {
 						clean_merge = -1;
 						goto cleanup_and_return;
 					}
-- 
2.19.0.12.gc6760fd9a9
Previous: Stefan BellerNext: Elijah Newren
Message 4 of 6 in “Cleanup of merge_*() functions in merge-recursive”
  1. 0/4 Cleanup of merge_*() functions in merge-recursiveElijah Newren, Sep 19, 2018
  2. 4/4 merge-recursive: rename merge_file_1() and merge_content()Elijah Newren, Sep 19, 2018
  3. Stefan BellerSep 19, 2018
  4. 3/4 merge-recursive: remove final remaining caller of merge_file_one()Elijah Newren, Sep 19, 2018
  5. 2/4 merge-recursive: avoid wrapper function when unnecessary and wastefulElijah Newren, Sep 19, 2018
  6. 1/4 merge-recursive: set paths correctly when three-way merging contentElijah Newren, Sep 19, 2018

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.