@matheusbsbs / matheus-bagliano / commits / 5a2580d62f
Fork 0

merge_recursive: Fix renames across paths below D/F conflicts

The rename logic in process_renames() handles renames and merging of file contents and then marks files as processed. However, there may be higher stage entries left in the index for other reasons (e.g., due to D/F conflicts). By checking for such cases and marking the entry as not processed, it allows process_entry() later to look at it and handle those higher stages. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jul 9, 2010 at 07:10 UTC 5a2580d62f9aaa30f0acd10df9dbe7a581dd77d9
3 files changed +15 -4
merge-recursive.c
+13 -2
@@ -1019,14 +1019,25 @@ static int process_renames(struct merge_options *o,
1019
1020 if (mfi.clean &&
1021 sha_eq(mfi.sha, ren1->pair->two->sha1) &&
1022 - mfi.mode == ren1->pair->two->mode)
1022 + mfi.mode == ren1->pair->two->mode) {
1023 /*
1024 * This messaged is part of
1025 * t6022 test. If you change
1026 * it update the test too.
1027 */
1028 output(o, 3, "Skipped %s (merged same as existing)", ren1_dst);
1029 - else {
1029 +
1030 + /* There may be higher stage entries left
1031 + * in the index (e.g. due to a D/F
1032 + * conflict) that need to be resolved.
1033 + */
1034 + for (i = 1; i <= 3; i++) {
1035 + if (!ren1->dst_entry->stages[i].mode)
1036 + continue;
1037 + ren1->dst_entry->processed = 0;
1038 + break;
1039 + }
1040 + } else {
1041 if (mfi.merge || !mfi.clean)
1042 output(o, 1, "Renaming %s => %s", ren1_src, ren1_dst);
1043 if (mfi.merge)
t/t3509-cherry-pick-merge-df.sh
+1 -1
@@ -26,7 +26,7 @@ test_expect_success 'Setup rename across paths each below D/F conflicts' '
26 git commit -m f1
27 '
28
29 -test_expect_failure 'Cherry-pick succeeds with rename across D/F conflicts' '
29 +test_expect_success 'Cherry-pick succeeds with rename across D/F conflicts' '
30 git reset --hard &&
31 git checkout master^0 &&
32 git cherry-pick branch
t/t6020-merge-df.sh
+1 -1
@@ -22,7 +22,7 @@ git commit -m "File: dir"'
22
23 test_expect_code 1 'Merge with d/f conflicts' 'git merge "merge msg" B master'
24
25 -test_expect_failure 'F/D conflict' '
25 +test_expect_success 'F/D conflict' '
26 git reset --hard &&
27 git checkout master &&
28 rm .git/index &&