t6042: Add a pair of cases where undetected renames cause issues
An undetected rename can cause a silent success where a conflict should have been detected, or can cause an erroneous conflict state where the merge should have been resolvable. Add testcases for both. 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
7b4ed5941c0d2143cb4467a9e265993121b62ce7
1 file changed
+61
t/t6042-merge-rename-corner-cases.sh
+61
@@ -72,4 +72,65 @@ test_expect_failure 'rename/modify/add-source conflict resolvable' '
72
test $(git rev-parse C:a) = $(git rev-parse a)
73
'
74
75
+test_expect_success 'setup resolvable conflict missed if rename missed' '
76
+ git rm -rf . &&
77
+ git clean -fdqx &&
78
+ rm -rf .git &&
79
+ git init &&
80
+
81
+ printf "1\n2\n3\n4\n5\n" >a &&
82
+ echo foo >b &&
83
+ git add a b &&
84
+ git commit -m A &&
85
+ git tag A &&
86
+
87
+ git checkout -b B A &&
88
+ git mv a c &&
89
+ echo "Completely different content" >a &&
90
+ git add a &&
91
+ git commit -m B &&
92
+
93
+ git checkout -b C A &&
94
+ echo 6 >>a &&
95
+ git add a &&
96
+ git commit -m C
97
+'
98
+
99
+test_expect_failure 'conflict caused if rename not detected' '
100
+ git checkout -q C^0 &&
101
+ git merge -s recursive B^0 &&
102
+
103
+ test 3 -eq $(git ls-files -s | wc -l) &&
104
+ test 0 -eq $(git ls-files -u | wc -l) &&
105
+ test 0 -eq $(git ls-files -o | wc -l) &&
106
+
107
+ test 6 -eq $(wc -l < c) &&
108
+ test $(git rev-parse HEAD:a) = $(git rev-parse B:a) &&
109
+ test $(git rev-parse HEAD:b) = $(git rev-parse A:b)
110
+'
111
+
112
+test_expect_success 'setup conflict resolved wrong if rename missed' '
113
+ git reset --hard &&
114
+ git clean -f &&
115
+
116
+ git checkout -b D A &&
117
+ echo 7 >>a &&
118
+ git add a &&
119
+ git mv a c &&
120
+ echo "Completely different content" >a &&
121
+ git add a &&
122
+ git commit -m D &&
123
+
124
+ git checkout -b E A &&
125
+ git rm a &&
126
+ echo "Completely different content" >>a &&
127
+ git add a &&
128
+ git commit -m E
129
+'
130
+
131
+test_expect_failure 'missed conflict if rename not detected' '
132
+ git checkout -q E^0 &&
133
+ test_must_fail git merge -s recursive D^0
134
+'
135
+
136
test_done