t6042: add testcase covering rename/add/delete conflict type
If a file is renamed on one side of history, and the other side of history both deletes the original file and adds a new unrelated file in the way of the rename, then we have what I call a rename/add/delete conflict. Add a testcase covering this scenario. Reported-by: Robert Dailey <rcdailey.lists@gmail.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Jul 2, 2018 at 06:30 UTC
11d9ade10e50848b10107d281fcfafb785bfb112
1 file changed
+66
t/t6042-merge-rename-corner-cases.sh
+66
@@ -693,4 +693,70 @@ test_expect_success 'rename/rename/add-dest merge still knows about conflicting
693
)
694
'
695
696
+# Testcase rad, rename/add/delete
697
+# Commit O: foo
698
+# Commit A: rm foo, add different bar
699
+# Commit B: rename foo->bar
700
+# Expected: CONFLICT (rename/add/delete), two-way merged bar
701
+
702
+test_expect_success 'rad-setup: rename/add/delete conflict' '
703
+ test_create_repo rad &&
704
+ (
705
+ cd rad &&
706
+ echo "original file" >foo &&
707
+ git add foo &&
708
+ git commit -m "original" &&
709
+
710
+ git branch O &&
711
+ git branch A &&
712
+ git branch B &&
713
+
714
+ git checkout A &&
715
+ git rm foo &&
716
+ echo "different file" >bar &&
717
+ git add bar &&
718
+ git commit -m "Remove foo, add bar" &&
719
+
720
+ git checkout B &&
721
+ git mv foo bar &&
722
+ git commit -m "rename foo to bar"
723
+ )
724
+'
725
+
726
+test_expect_failure 'rad-check: rename/add/delete conflict' '
727
+ (
728
+ cd rad &&
729
+
730
+ git checkout B^0 &&
731
+ test_must_fail git merge -s recursive A^0 >out 2>err &&
732
+
733
+ # Not sure whether the output should contain just one
734
+ # "CONFLICT (rename/add/delete)" line, or if it should break
735
+ # it into a pair of "CONFLICT (rename/delete)" and
736
+ # "CONFLICT (rename/add)"; allow for either.
737
+ test_i18ngrep "CONFLICT (rename.*add)" out &&
738
+ test_i18ngrep "CONFLICT (rename.*delete)" out &&
739
+ test_must_be_empty err &&
740
+
741
+ git ls-files -s >file_count &&
742
+ test_line_count = 2 file_count &&
743
+ git ls-files -u >file_count &&
744
+ test_line_count = 2 file_count &&
745
+ git ls-files -o >file_count &&
746
+ test_line_count = 2 file_count &&
747
+
748
+ git rev-parse >actual \
749
+ :2:bar :3:bar &&
750
+ git rev-parse >expect \
751
+ B:bar A:bar &&
752
+
753
+ test_cmp file_is_missing foo &&
754
+ # bar should have two-way merged contents of the different
755
+ # versions of bar; check that content from both sides is
756
+ # present.
757
+ grep original bar &&
758
+ grep different bar
759
+ )
760
+'
761
+
762
test_done