@@ -678,4 +678,54 @@ test_expect_success 'merge-recursive remembers the names of all base trees' '
678678 test_cmp expect actual
679679'
680680
681+ test_expect_success ' merge-recursive internal merge resolves to the sameness' '
682+ git reset --hard HEAD &&
683+
684+ # We are going to create a history leading to two criss-cross
685+ # branches A and B. The common ancestor at the bottom, O0,
686+ # has two child commits O1 and O2, both of which will be merge
687+ # base between A and B, like so:
688+ #
689+ # O1---A
690+ # / \ /
691+ # O0 .
692+ # \ / \
693+ # O2---B
694+ #
695+ # The recently added "check to see if the index is different from
696+ # the tree into which something else is getting merged" check must
697+ # NOT kick in when an inner merge between O1 and O2 is made. Both
698+ # O1 and O2 happen to have the same tree as O0 in this test to
699+ # trigger the bug---whether the inner merge is made by merging O2
700+ # into O1 or O1 into O2, their common ancestor O0 and the branch
701+ # being merged have the same tree. We should not trigger the "is
702+ # the index dirty?" check in this case.
703+
704+ echo "zero" >file &&
705+ git add file &&
706+ test_tick &&
707+ git commit -m "O0" &&
708+ O0=$(git rev-parse HEAD) &&
709+
710+ test_tick &&
711+ git commit --allow-empty -m "O1" &&
712+ O1=$(git rev-parse HEAD) &&
713+
714+ git reset --hard $O0 &&
715+ test_tick &&
716+ git commit --allow-empty -m "O2" &&
717+ O2=$(git rev-parse HEAD) &&
718+
719+ test_tick &&
720+ git merge -s ours $O1 &&
721+ B=$(git rev-parse HEAD) &&
722+
723+ git reset --hard $O1 &&
724+ test_tick &&
725+ git merge -s ours $O2 &&
726+ A=$(git rev-parse HEAD) &&
727+
728+ git merge $B
729+ '
730+
681731test_done
0 commit comments