Skip to content

Commit 6db4105

Browse files
committed
Revert "Merge branch 'en/merge-recursive'"
As the band-aid to merge-recursive seems to regress complex merges in an unpleasant way. The merge-recursive implementation needs to be rewritten in such a way that it resolves renames and D/F conflicts entirely in-core and not to touch working tree at all while doing so. But in the meantime, this reverts commit ac9666f that merged the topic in its entirety.
1 parent d192508 commit 6db4105

File tree

2 files changed

+6
-81
lines changed

2 files changed

+6
-81
lines changed

merge-recursive.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,10 @@ static void make_room_for_directories_of_df_conflicts(struct merge_options *o,
341341
* make room for the corresponding directory. Such paths will
342342
* later be processed in process_df_entry() at the end. If
343343
* the corresponding directory ends up being removed by the
344-
* merge, then the file will be reinstated at that time
345-
* (albeit with a different timestamp!); otherwise, if the
346-
* file is not supposed to be removed by the merge, the
347-
* contents of the file will be placed in another unique
348-
* filename.
344+
* merge, then the file will be reinstated at that time;
345+
* otherwise, if the file is not supposed to be removed by the
346+
* merge, the contents of the file will be placed in another
347+
* unique filename.
349348
*
350349
* NOTE: This function relies on the fact that entries for a
351350
* D/F conflict will appear adjacent in the index, with the
@@ -356,13 +355,6 @@ static void make_room_for_directories_of_df_conflicts(struct merge_options *o,
356355
int last_len = 0;
357356
int i;
358357

359-
/*
360-
* Do not do any of this crazyness during the recursive; we don't
361-
* even write anything to the working tree!
362-
*/
363-
if (o->call_depth)
364-
return;
365-
366358
for (i = 0; i < entries->nr; i++) {
367359
const char *path = entries->items[i].string;
368360
int len = strlen(path);
@@ -1265,13 +1257,9 @@ static int merge_content(struct merge_options *o,
12651257
}
12661258

12671259
if (mfi.clean && !df_conflict_remains &&
1268-
sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode &&
1269-
!o->call_depth && !lstat(path, &st)) {
1260+
sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode)
12701261
output(o, 3, "Skipped %s (merged same as existing)", path);
1271-
add_cacheinfo(mfi.mode, mfi.sha, path,
1272-
0 /*stage*/, 1 /*refresh*/, 0 /*options*/);
1273-
return mfi.clean;
1274-
} else
1262+
else
12751263
output(o, 2, "Auto-merging %s", path);
12761264

12771265
if (!mfi.clean) {

t/t6022-merge-rename.sh

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -609,67 +609,4 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
609609
! test -f original
610610
'
611611

612-
test_expect_success 'setup avoid unnecessary update, normal rename' '
613-
git reset --hard &&
614-
git checkout --orphan avoid-unnecessary-update-1 &&
615-
git rm -rf . &&
616-
git clean -fdqx &&
617-
618-
printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >original &&
619-
git add -A &&
620-
git commit -m "Common commmit" &&
621-
622-
git mv original rename &&
623-
echo 11 >>rename &&
624-
git add -u &&
625-
git commit -m "Renamed and modified" &&
626-
627-
git checkout -b merge-branch-1 HEAD~1 &&
628-
echo "random content" >random-file &&
629-
git add -A &&
630-
git commit -m "Random, unrelated changes"
631-
'
632-
633-
test_expect_success 'avoid unnecessary update, normal rename' '
634-
git checkout -q avoid-unnecessary-update-1^0 &&
635-
test-chmtime =1000000000 rename &&
636-
test-chmtime -v +0 rename >expect &&
637-
git merge merge-branch-1 &&
638-
test-chmtime -v +0 rename >actual &&
639-
test_cmp expect actual # "rename" should have stayed intact
640-
'
641-
642-
test_expect_success 'setup to test avoiding unnecessary update, with D/F conflict' '
643-
git reset --hard &&
644-
git checkout --orphan avoid-unnecessary-update-2 &&
645-
git rm -rf . &&
646-
git clean -fdqx &&
647-
648-
mkdir df &&
649-
printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >df/file &&
650-
git add -A &&
651-
git commit -m "Common commmit" &&
652-
653-
git mv df/file temp &&
654-
rm -rf df &&
655-
git mv temp df &&
656-
echo 11 >>df &&
657-
git add -u &&
658-
git commit -m "Renamed and modified" &&
659-
660-
git checkout -b merge-branch-2 HEAD~1 &&
661-
>unrelated-change &&
662-
git add unrelated-change &&
663-
git commit -m "Only unrelated changes"
664-
'
665-
666-
test_expect_failure 'avoid unnecessary update, with D/F conflict' '
667-
git checkout -q avoid-unnecessary-update-2^0 &&
668-
test-chmtime =1000000000 df &&
669-
test-chmtime -v +0 df >expect &&
670-
git merge merge-branch-2 &&
671-
test-chmtime -v +0 df >actual &&
672-
test_cmp expect actual # "df" should have stayed intact
673-
'
674-
675612
test_done

0 commit comments

Comments
 (0)