merge-recursive: Move rename/delete handling into dedicated function
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@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Sep 20, 2010 at 02:28 UTC
6ef2cb008f132e4649ef925a8e1950d3138054d5
1 file changed
+20
-11
merge-recursive.c
+20
-11
@@ -730,6 +730,25 @@ static struct merge_file_info merge_file(struct merge_options *o,
730
return result;
731
}
732
733
+static void conflict_rename_delete(struct merge_options *o,
734
+ struct diff_filepair *pair,
735
+ const char *rename_branch,
736
+ const char *other_branch)
737
+{
738
+ char *dest_name = pair->two->path;
739
+
740
+ output(o, 1, "CONFLICT (rename/delete): Rename %s->%s in %s "
741
+ "and deleted in %s",
742
+ pair->one->path, pair->two->path, rename_branch,
743
+ other_branch);
744
+ if (!o->call_depth)
745
+ update_stages(dest_name, NULL,
746
+ rename_branch == o->branch1 ? pair->two : NULL,
747
+ rename_branch == o->branch1 ? NULL : pair->two,
748
+ 1);
749
+ update_file(o, 0, pair->two->sha1, pair->two->mode, dest_name);
750
+}
751
+
752
static void conflict_rename_rename_1to2(struct merge_options *o,
753
struct rename *ren1,
754
const char *branch1,
@@ -936,17 +955,7 @@ static int process_renames(struct merge_options *o,
955
956
if (sha_eq(src_other.sha1, null_sha1)) {
957
clean_merge = 0;
939
- output(o, 1, "CONFLICT (rename/delete): Rename %s->%s in %s "
940
- "and deleted in %s",
941
- ren1_src, ren1_dst, branch1,
942
- branch2);
943
- update_file(o, 0, ren1->pair->two->sha1, ren1->pair->two->mode, ren1_dst);
944
- if (!o->call_depth)
945
- update_stages(ren1_dst, NULL,
946
- branch1 == o->branch1 ?
947
- ren1->pair->two : NULL,
948
- branch1 == o->branch1 ?
949
- NULL : ren1->pair->two, 1);
958
+ conflict_rename_delete(o, ren1->pair, branch1, branch2);
959
} else if ((dst_other.mode == ren1->pair->two->mode) &&
960
sha_eq(dst_other.sha1, ren1->pair->two->sha1)) {
961
/* Added file on the other side