[PATCH 17/37] merge-recursive: Move rename/delete handling into dedicated function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This move is in preparation for the function growing and being called from
multiple places in order to handle D/F conflicts.

Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
---
 merge-recursive.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index f7591a3..87be24c 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -731,6 +731,25 @@ static struct merge_file_info merge_file(struct merge_options *o,
 	return result;
 }
 
+static void conflict_rename_delete(struct merge_options *o,
+				   struct diff_filepair *pair,
+				   const char *rename_branch,
+				   const char *other_branch)
+{
+	char *dest_name = pair->two->path;
+
+	output(o, 1, "CONFLICT (rename/delete): Rename %s->%s in %s "
+	       "and deleted in %s",
+	       pair->one->path, pair->two->path, rename_branch,
+	       other_branch);
+	if (!o->call_depth)
+		update_stages(dest_name, NULL,
+			      rename_branch == o->branch1 ? pair->two : NULL,
+			      rename_branch == o->branch1 ? NULL : pair->two,
+			      1);
+	update_file(o, 0, pair->two->sha1, pair->two->mode, dest_name);
+}
+
 static void conflict_rename_rename_1to2(struct merge_options *o,
 					struct rename *ren1,
 					const char *branch1,
@@ -937,17 +956,7 @@ static int process_renames(struct merge_options *o,
 
 			if (sha_eq(src_other.sha1, null_sha1)) {
 				clean_merge = 0;
-				output(o, 1, "CONFLICT (rename/delete): Rename %s->%s in %s "
-				       "and deleted in %s",
-				       ren1_src, ren1_dst, branch1,
-				       branch2);
-				update_file(o, 0, ren1->pair->two->sha1, ren1->pair->two->mode, ren1_dst);
-				if (!o->call_depth)
-					update_stages(ren1_dst, NULL,
-							branch1 == o->branch1 ?
-							ren1->pair->two : NULL,
-							branch1 == o->branch1 ?
-							NULL : ren1->pair->two, 1);
+				conflict_rename_delete(o, ren1->pair, branch1, branch2);
 			} else if ((dst_other.mode == ren1->pair->two->mode) &&
 				   sha_eq(dst_other.sha1, ren1->pair->two->sha1)) {
 				/* Added file on the other side
-- 
1.7.3.271.g16009

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]