t6036: criss-cross + rename/rename(1to2)/add-source + modify/modify

This is another challenging testcase trying to exercise the virtual merge base creation in the rename/rename(1to2) code. A testcase is added that we should be able to merge cleanly, but which requires a virtual merge base to be created that is aware of rename/rename(1to2)/add-source conflicts and can handle those. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Aug 11, 2011 at 23:19 UTC 0b35deb378ee471f64e1b376d722e0bdd97d5e36
1 file changed +77
t/t6036-recursive-corner-cases.sh
+77
@@ -644,4 +644,81 @@ test_expect_failure 'handle rename/rename(1to2)/modify followed by what looks li
644 test $(git rev-parse HEAD:newname) = $(git rev-parse E:newname)
645 '
646
647 +#
648 +# criss-cross with rename/rename(1to2)/add-source + resolvable modify/modify:
649 +#
650 +# B D
651 +# o---o
652 +# / \ / \
653 +# A o X ? F
654 +# \ / \ /
655 +# o---o
656 +# C E
657 +#
658 +# Commit A: new file: a
659 +# Commit B: rename a->b
660 +# Commit C: rename a->c, add different a
661 +# Commit D: merge B&C, keeping b&c and (new) a modified at beginning
662 +# Commit E: merge B&C, keeping b&c and (new) a modified at end
663 +#
664 +# Merging commits D & E should result in no conflict; doing so correctly
665 +# requires getting the virtual merge base (from merging B&C) right, handling
666 +# renaming carefully (both in the virtual merge base and later), and getting
667 +# content merge handled.
668 +
669 +test_expect_success 'setup criss-cross + rename/rename/add + modify/modify' '
670 + git rm -rf . &&
671 + git clean -fdqx &&
672 + rm -rf .git &&
673 + git init &&
674 +
675 + printf "lots\nof\nwords\nand\ncontent\n" >a &&
676 + git add a &&
677 + git commit -m A &&
678 + git tag A &&
679 +
680 + git checkout -b B A &&
681 + git mv a b &&
682 + git commit -m B &&
683 +
684 + git checkout -b C A &&
685 + git mv a c &&
686 + printf "2\n3\n4\n5\n6\n7\n" >a &&
687 + git add a &&
688 + git commit -m C &&
689 +
690 + git checkout B^0 &&
691 + git merge --no-commit -s ours C^0 &&
692 + git checkout C -- a c &&
693 + mv a old_a &&
694 + echo 1 >a &&
695 + cat old_a >>a &&
696 + rm old_a &&
697 + git add -u &&
698 + git commit -m "Merge commit C^0 into HEAD" &&
699 + git tag D &&
700 +
701 + git checkout C^0 &&
702 + git merge --no-commit -s ours B^0 &&
703 + git checkout B -- b &&
704 + echo 8 >>a &&
705 + git add -u &&
706 + git commit -m "Merge commit B^0 into HEAD" &&
707 + git tag E
708 +'
709 +
710 +test_expect_failure 'detect rename/rename/add-source for virtual merge-base' '
711 + git checkout D^0 &&
712 +
713 + git merge -s recursive E^0 &&
714 +
715 + test 3 -eq $(git ls-files -s | wc -l) &&
716 + test 0 -eq $(git ls-files -u | wc -l) &&
717 + test 0 -eq $(git ls-files -o | wc -l) &&
718 +
719 + test $(git rev-parse HEAD:b) = $(git rev-parse A:a) &&
720 + test $(git rev-parse HEAD:c) = $(git rev-parse A:a) &&
721 + test "$(cat a)" = "$(printf "1\n2\n3\n4\n5\n6\n7\n8\n")"
722 +'
723 +
724 test_done