t6036: criss-cross with weird content can fool git into clean merge

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 96b079e5c94b6881335ab1cd9a3d88ee877da96e
1 file changed +83
t/t6036-recursive-corner-cases.sh
+83
@@ -314,4 +314,87 @@ test_expect_failure 'git detects conflict merging criss-cross+modify/delete, rev
314 test $(git rev-parse :3:file) = $(git rev-parse B:file)
315 '
316
317 +#
318 +# criss-cross + modify/modify with very contrived file contents:
319 +#
320 +# B D
321 +# o---o
322 +# / \ / \
323 +# A o X ? F
324 +# \ / \ /
325 +# o---o
326 +# C E
327 +#
328 +# Commit A: file with contents 'A\n'
329 +# Commit B: file with contents 'B\n'
330 +# Commit C: file with contents 'C\n'
331 +# Commit D: file with contents 'D\n'
332 +# Commit E: file with contents:
333 +# <<<<<<< Temporary merge branch 1
334 +# C
335 +# =======
336 +# B
337 +# >>>>>>> Temporary merge branch 2
338 +#
339 +# Now, when we merge commits D & E, does git detect the conflict?
340 +
341 +test_expect_success 'setup differently handled merges of content conflict' '
342 + git clean -fdqx &&
343 + rm -rf .git &&
344 + git init &&
345 +
346 + echo A >file &&
347 + git add file &&
348 + test_tick &&
349 + git commit -m A &&
350 +
351 + git branch B &&
352 + git checkout -b C &&
353 + echo C >file &&
354 + git add file &&
355 + test_tick &&
356 + git commit -m C &&
357 +
358 + git checkout B &&
359 + echo B >file &&
360 + git add file &&
361 + test_tick &&
362 + git commit -m B &&
363 +
364 + git checkout B^0 &&
365 + test_must_fail git merge C &&
366 + echo D >file &&
367 + git add file &&
368 + test_tick &&
369 + git commit -m D &&
370 + git tag D &&
371 +
372 + git checkout C^0 &&
373 + test_must_fail git merge B &&
374 + cat <<EOF >file &&
375 +<<<<<<< Temporary merge branch 1
376 +C
377 +=======
378 +B
379 +>>>>>>> Temporary merge branch 2
380 +EOF
381 + git add file &&
382 + test_tick &&
383 + git commit -m E &&
384 + git tag E
385 +'
386 +
387 +test_expect_failure 'git detects conflict w/ criss-cross+contrived resolution' '
388 + git checkout D^0 &&
389 +
390 + test_must_fail git merge -s recursive E^0 &&
391 +
392 + test 3 -eq $(git ls-files -s | wc -l) &&
393 + test 3 -eq $(git ls-files -u | wc -l) &&
394 + test 0 -eq $(git ls-files -o | wc -l) &&
395 +
396 + test $(git rev-parse :2:file) = $(git rev-parse D:file) &&
397 + test $(git rev-parse :3:file) = $(git rev-parse E:file)
398 +'
399 +
400 test_done