Skip to content

Commit 882fd11

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b130ad commit 882fd11

File tree

2 files changed

+16
-37
lines changed

2 files changed

+16
-37
lines changed

merge-recursive.c

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,6 @@ static int process_renames(struct merge_options *o,
10731073

10741074
if (try_merge) {
10751075
struct diff_filespec *one, *a, *b;
1076-
struct merge_file_info mfi;
10771076
src_other.path = (char *)ren1_src;
10781077

10791078
one = ren1->pair->one;
@@ -1084,41 +1083,16 @@ static int process_renames(struct merge_options *o,
10841083
b = ren1->pair->two;
10851084
a = &src_other;
10861085
}
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);
11221096
}
11231097
}
11241098
}
@@ -1358,6 +1332,11 @@ static int process_df_entry(struct merge_options *o,
13581332
struct rename_df_conflict_info *conflict_info = entry->rename_df_conflict_info;
13591333
char *src;
13601334
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;
13611340
case RENAME_DELETE:
13621341
clean_merge = 0;
13631342
conflict_rename_delete(o, conflict_info->pair1,

t/t6022-merge-rename.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ cat >expected <<\EOF &&
455455
>>>>>>> dir-not-in-way
456456
EOF
457457

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' '
459459
git reset --hard &&
460460
rm -rf dir~* &&
461461
git checkout -q renamed-file-has-conflicts^0 &&

0 commit comments

Comments
 (0)