198
test $(git rev-parse HEAD:a) = $(git rev-parse C:a)
199
'
200
201
+test_expect_success 'setup content merge + rename/directory conflict' '
202
+ git rm -rf . &&
203
+ git clean -fdqx &&
204
+ rm -rf .git &&
205
+ git init &&
206
+
207
+ printf "1\n2\n3\n4\n5\n6\n" >file &&
208
+ git add file &&
209
+ test_tick &&
210
+ git commit -m base &&
211
+ git tag base &&
212
+
213
+ git checkout -b right &&
214
+ echo 7 >>file &&
215
+ mkdir newfile &&
216
+ echo junk >newfile/realfile &&
217
+ git add file newfile/realfile &&
218
+ test_tick &&
219
+ git commit -m right &&
220
+
221
+ git checkout -b left-conflict base &&
222
+ echo 8 >>file &&
223
+ git add file &&
224
+ git mv file newfile &&
225
+ test_tick &&
226
+ git commit -m left &&
227
+
228
+ git checkout -b left-clean base &&
229
+ echo 0 >newfile &&
230
+ cat file >>newfile &&
231
+ git add newfile &&
232
+ git rm file &&
233
+ test_tick &&
234
+ git commit -m left
235
+'
236
+
237
+test_expect_failure 'rename/directory conflict + clean content merge' '
238
+ git reset --hard &&
239
+ git reset --hard &&
240
+ git clean -fdqx &&
241
+
242
+ git checkout left-clean^0 &&
243
+
244
+ test_must_fail git merge -s recursive right^0 &&
245
+
246
+ test 2 -eq $(git ls-files -s | wc -l) &&
247
+ test 1 -eq $(git ls-files -u | wc -l) &&
248
+ test 1 -eq $(git ls-files -o | wc -l) &&
249
+
250
+ echo 0 >expect &&
251
+ git cat-file -p base:file >>expect &&
252
+ echo 7 >>expect &&
253
+ test_cmp expect newfile~HEAD &&
254
+
255
+ test $(git rev-parse :2:newfile) = $(git hash-object expect) &&
256
+
257
+ test -f newfile/realfile &&
258
+ test -f newfile~HEAD
259
+'
260
+
261
+test_expect_failure 'rename/directory conflict + content merge conflict' '
262
+ git reset --hard &&
263
+ git reset --hard &&
264
+ git clean -fdqx &&
265
+
266
+ git checkout left-conflict^0 &&
267
+
268
+ test_must_fail git merge -s recursive right^0 &&
269
+
270
+ test 4 -eq $(git ls-files -s | wc -l) &&
271
+ test 3 -eq $(git ls-files -u | wc -l) &&
272
+ test 1 -eq $(git ls-files -o | wc -l) &&
273
+
274
+ git cat-file -p left-conflict:newfile >left &&
275
+ git cat-file -p base:file >base &&
276
+ git cat-file -p right:file >right &&
277
+ test_must_fail git merge-file \
278
+ -L "HEAD:newfile" \
279
+ -L "" \
280
+ -L "right^0:file" \
281
+ left base right &&
282
+ test_cmp left newfile~HEAD &&
283
+
284
+ test $(git rev-parse :1:newfile) = $(git rev-parse base:file) &&
285
+ test $(git rev-parse :2:newfile) = $(git rev-parse left-conflict:newfile) &&
286
+ test $(git rev-parse :3:newfile) = $(git rev-parse right:file) &&
287
+
288
+ test -f newfile/realfile &&
289
+ test -f newfile~HEAD
290
+'
291
+
292
+test_expect_success 'setup content merge + rename/directory conflict w/ disappearing dir' '
293
+ git reset --hard &&
294
+ git rm -rf . &&
295
+ git clean -fdqx &&
296
+ rm -rf .git &&
297
+ git init &&
298
+
299
+ mkdir sub &&
300
+ printf "1\n2\n3\n4\n5\n6\n" >sub/file &&
301
+ git add sub/file &&
302
+ test_tick &&
303
+ git commit -m base &&
304
+ git tag base &&
305
+
306
+ git checkout -b right &&
307
+ echo 7 >>sub/file &&
308
+ git add sub/file &&
309
+ test_tick &&
310
+ git commit -m right &&
311
+
312
+ git checkout -b left base &&
313
+ echo 0 >newfile &&
314
+ cat sub/file >>newfile &&
315
+ git rm sub/file &&
316
+ mv newfile sub &&
317
+ git add sub &&
318
+ test_tick &&
319
+ git commit -m left
320
+'
321
+
322
+test_expect_success 'disappearing dir in rename/directory conflict handled' '
323
+ git reset --hard &&
324
+ git clean -fdqx &&
325
+
326
+ git checkout left^0 &&
327
+
328
+ git merge -s recursive right^0 &&
329
+
330
+ test 1 -eq $(git ls-files -s | wc -l) &&
331
+ test 0 -eq $(git ls-files -u | wc -l) &&
332
+ test 0 -eq $(git ls-files -o | wc -l) &&
333
+
334
+ echo 0 >expect &&
335
+ git cat-file -p base:sub/file >>expect &&
336
+ echo 7 >>expect &&
337
+ test_cmp expect sub &&
338
+
339
+ test -f sub
340
+'
341
+
342
test_done