merge-recursive: Delay content merging for renames
Move the handling of content merging for renames from process_renames() to process_df_entry(). 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:29 UTC
882fd11aff6f0e8add77e75924678cce875a0eaf
2 files changed
+16
-37
merge-recursive.c
+15
-36
@@ -1073,7 +1073,6 @@ static int process_renames(struct merge_options *o,
1073
1074
if (try_merge) {
1075
struct diff_filespec *one, *a, *b;
1076
- struct merge_file_info mfi;
1076
src_other.path = (char *)ren1_src;
1077
1078
one = ren1->pair->one;
@@ -1084,41 +1083,16 @@ static int process_renames(struct merge_options *o,
1083
b = ren1->pair->two;
1084
a = &src_other;
1085
}
1087
- mfi = merge_file(o, one, a, b,
1088
- o->branch1, o->branch2);
1089
-
1090
- if (mfi.clean &&
1091
- sha_eq(mfi.sha, ren1->pair->two->sha1) &&
1092
- mfi.mode == ren1->pair->two->mode) {
1093
- /*
1094
- * This message is part of
1095
- * t6022 test. If you change
1096
- * it update the test too.
1097
- */
1098
- output(o, 3, "Skipped %s (merged same as existing)", ren1_dst);
1099
-
1100
- /* There may be higher stage entries left
1101
- * in the index (e.g. due to a D/F
1102
- * conflict) that need to be resolved.
1103
- */
1104
- if (!ren1->dst_entry->stages[2].mode !=
1105
- !ren1->dst_entry->stages[3].mode)
1106
- ren1->dst_entry->processed = 0;
1107
- } else {
1108
- if (mfi.merge || !mfi.clean)
1109
- output(o, 1, "Renaming %s => %s", ren1_src, ren1_dst);
1110
- if (mfi.merge)
1111
- output(o, 2, "Auto-merging %s", ren1_dst);
1112
- if (!mfi.clean) {
1113
- output(o, 1, "CONFLICT (rename/modify): Merge conflict in %s",
1114
- ren1_dst);
1115
- clean_merge = 0;
1116
-
1117
- if (!o->call_depth)
1118
- update_stages(ren1_dst,
1119
- one, a, b, 1);
1120
- }
1121
- update_file(o, mfi.clean, mfi.sha, mfi.mode, ren1_dst);
1086
+ update_stages_and_entry(ren1_dst, ren1->dst_entry, one, a, b, 1);
1087
+ if (string_list_has_string(&o->current_directory_set, ren1_dst)) {
1088
+ setup_rename_df_conflict_info(RENAME_NORMAL,
1089
+ ren1->pair,
1090
+ NULL,
1091
+ branch1,
1092
+ NULL,
1093
+ ren1->dst_entry,
1094
+ NULL);
1095
+ remove_file(o, 0, ren1_dst, 0);
1096
}
1097
}
1098
}
@@ -1358,6 +1332,11 @@ static int process_df_entry(struct merge_options *o,
1332
struct rename_df_conflict_info *conflict_info = entry->rename_df_conflict_info;
1333
char *src;
1334
switch (conflict_info->rename_type) {
1335
+ case RENAME_NORMAL:
1336
+ clean_merge = merge_content(o, path,
1337
+ o_sha, o_mode, a_sha, a_mode, b_sha, b_mode,
1338
+ conflict_info->branch1);
1339
+ break;
1340
case RENAME_DELETE:
1341
clean_merge = 0;
1342
conflict_rename_delete(o, conflict_info->pair1,
t/t6022-merge-rename.sh
+1
-1
@@ -455,7 +455,7 @@ cat >expected <<\EOF &&
455
>>>>>>> dir-not-in-way
456
EOF
457
458
-test_expect_failure 'Rename+D/F conflict; renamed file cannot merge, dir not in way' '
458
+test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in way' '
459
git reset --hard &&
460
rm -rf dir~* &&
461
git checkout -q renamed-file-has-conflicts^0 &&