t6022: ignoring untracked files by merge-recursive when they do not matter
Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Oct 27, 2006 at 16:07 UTC
5b329a5f5e3625cdc204e3d274c89646816f384c
1 file changed
+142
-23
t/t6022-merge-rename.sh
+142
-23
@@ -42,15 +42,20 @@ O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
42
EOF
43
44
git add A M &&
45
-git commit -m initial &&
45
+git commit -m "initial has A and M" &&
46
git branch white &&
47
git branch red &&
48
git branch blue &&
49
+git branch yellow &&
50
51
sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
52
mv A+ A &&
53
git commit -a -m "master updates A" &&
54
55
+git checkout yellow &&
56
+rm -f M &&
57
+git commit -a -m "yellow removes M" &&
58
+
59
git checkout white &&
60
sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
61
sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
@@ -79,27 +84,27 @@ test_expect_success 'pull renaming branch into unrenaming one' \
84
git show-branch
85
git pull . white && {
86
echo "BAD: should have conflicted"
82
- exit 1
87
+ return 1
88
}
89
git ls-files -s
90
test "$(git ls-files -u B | wc -l)" -eq 3 || {
91
echo "BAD: should have left stages for B"
87
- exit 1
92
+ return 1
93
}
94
test "$(git ls-files -s N | wc -l)" -eq 1 || {
95
echo "BAD: should have merged N"
91
- exit 1
96
+ return 1
97
}
98
sed -ne "/^g/{
99
p
100
q
101
}" B | grep master || {
102
echo "BAD: should have listed our change first"
98
- exit 1
103
+ return 1
104
}
105
test "$(git diff white N | wc -l)" -eq 0 || {
106
echo "BAD: should have taken colored branch"
102
- exit 1
107
+ return 1
108
}
109
'
110
@@ -110,26 +115,26 @@ test_expect_success 'pull renaming branch into another renaming one' \
115
git checkout red
116
git pull . white && {
117
echo "BAD: should have conflicted"
113
- exit 1
118
+ return 1
119
}
120
test "$(git ls-files -u B | wc -l)" -eq 3 || {
121
echo "BAD: should have left stages"
117
- exit 1
122
+ return 1
123
}
124
test "$(git ls-files -s N | wc -l)" -eq 1 || {
125
echo "BAD: should have merged N"
121
- exit 1
126
+ return 1
127
}
128
sed -ne "/^g/{
129
p
130
q
131
}" B | grep red || {
132
echo "BAD: should have listed our change first"
128
- exit 1
133
+ return 1
134
}
135
test "$(git diff white N | wc -l)" -eq 0 || {
136
echo "BAD: should have taken colored branch"
132
- exit 1
137
+ return 1
138
}
139
'
140
@@ -139,26 +144,26 @@ test_expect_success 'pull unrenaming branch into renaming one' \
144
git show-branch
145
git pull . master && {
146
echo "BAD: should have conflicted"
142
- exit 1
147
+ return 1
148
}
149
test "$(git ls-files -u B | wc -l)" -eq 3 || {
150
echo "BAD: should have left stages"
146
- exit 1
151
+ return 1
152
}
153
test "$(git ls-files -s N | wc -l)" -eq 1 || {
154
echo "BAD: should have merged N"
150
- exit 1
155
+ return 1
156
}
157
sed -ne "/^g/{
158
p
159
q
160
}" B | grep red || {
161
echo "BAD: should have listed our change first"
157
- exit 1
162
+ return 1
163
}
164
test "$(git diff white N | wc -l)" -eq 0 || {
165
echo "BAD: should have taken colored branch"
161
- exit 1
166
+ return 1
167
}
168
'
169
@@ -168,35 +173,149 @@ test_expect_success 'pull conflicting renames' \
173
git show-branch
174
git pull . blue && {
175
echo "BAD: should have conflicted"
171
- exit 1
176
+ return 1
177
}
178
test "$(git ls-files -u A | wc -l)" -eq 1 || {
179
echo "BAD: should have left a stage"
175
- exit 1
180
+ return 1
181
}
182
test "$(git ls-files -u B | wc -l)" -eq 1 || {
183
echo "BAD: should have left a stage"
179
- exit 1
184
+ return 1
185
}
186
test "$(git ls-files -u C | wc -l)" -eq 1 || {
187
echo "BAD: should have left a stage"
183
- exit 1
188
+ return 1
189
}
190
test "$(git ls-files -s N | wc -l)" -eq 1 || {
191
echo "BAD: should have merged N"
187
- exit 1
192
+ return 1
193
}
194
sed -ne "/^g/{
195
p
196
q
197
}" B | grep red || {
198
echo "BAD: should have listed our change first"
194
- exit 1
199
+ return 1
200
}
201
test "$(git diff white N | wc -l)" -eq 0 || {
202
echo "BAD: should have taken colored branch"
198
- exit 1
203
+ return 1
204
+ }
205
+'
206
+
207
+test_expect_success 'interference with untracked working tree file' '
208
+
209
+ git reset --hard
210
+ git show-branch
211
+ echo >A this file should not matter
212
+ git pull . white && {
213
+ echo "BAD: should have conflicted"
214
+ return 1
215
+ }
216
+ test -f A || {
217
+ echo "BAD: should have left A intact"
218
+ return 1
219
+ }
220
+'
221
+
222
+test_expect_success 'interference with untracked working tree file' '
223
+
224
+ git reset --hard
225
+ git checkout white
226
+ git show-branch
227
+ rm -f A
228
+ echo >A this file should not matter
229
+ git pull . red && {
230
+ echo "BAD: should have conflicted"
231
+ return 1
232
+ }
233
+ test -f A || {
234
+ echo "BAD: should have left A intact"
235
+ return 1
236
+ }
237
+'
238
+
239
+test_expect_success 'interference with untracked working tree file' '
240
+
241
+ git reset --hard
242
+ rm -f A M
243
+ git checkout -f master
244
+ git tag -f anchor
245
+ git show-branch
246
+ git pull . yellow || {
247
+ echo "BAD: should have cleanly merged"
248
+ return 1
249
+ }
250
+ test -f M && {
251
+ echo "BAD: should have removed M"
252
+ return 1
253
+ }
254
+ git reset --hard anchor
255
+'
256
+
257
+test_expect_success 'updated working tree file should prevent the merge' '
258
+
259
+ git reset --hard
260
+ rm -f A M
261
+ git checkout -f master
262
+ git tag -f anchor
263
+ git show-branch
264
+ echo >>M one line addition
265
+ cat M >M.saved
266
+ git pull . yellow && {
267
+ echo "BAD: should have complained"
268
+ return 1
269
+ }
270
+ diff M M.saved || {
271
+ echo "BAD: should have left M intact"
272
+ return 1
273
+ }
274
+ rm -f M.saved
275
+'
276
+
277
+test_expect_success 'updated working tree file should prevent the merge' '
278
+
279
+ git reset --hard
280
+ rm -f A M
281
+ git checkout -f master
282
+ git tag -f anchor
283
+ git show-branch
284
+ echo >>M one line addition
285
+ cat M >M.saved
286
+ git update-index M
287
+ git pull . yellow && {
288
+ echo "BAD: should have complained"
289
+ return 1
290
+ }
291
+ diff M M.saved || {
292
+ echo "BAD: should have left M intact"
293
+ return 1
294
+ }
295
+ rm -f M.saved
296
+'
297
+
298
+test_expect_success 'interference with untracked working tree file' '
299
+
300
+ git reset --hard
301
+ rm -f A M
302
+ git checkout -f yellow
303
+ git tag -f anchor
304
+ git show-branch
305
+ echo >M this file should not matter
306
+ git pull . master || {
307
+ echo "BAD: should have cleanly merged"
308
+ return 1
309
+ }
310
+ test -f M || {
311
+ echo "BAD: should have left M intact"
312
+ return 1
313
+ }
314
+ git ls-files -s | grep M && {
315
+ echo "BAD: M must be untracked in the result"
316
+ return 1
317
}
318
+ git reset --hard anchor
319
'
320
321
test_done