@matheusbsbs / matheus-bagliano / commits / 3398f2f583
Fork 0

t6022: Add tests for reversing order of merges when D/F conflicts present

When merging two branches with some path involved in a D/F conflict, the choice of which branch to merge into the other matters for (at least) two reasons: (1) whether the working copy has a directory full of files that is in the way of a file, or a file exists that is in the way of a directory of files, (2) when the directory full of files does not disappear due to the merge, what files at the same paths should be renamed to (e.g. filename~HEAD vs. filename~otherbranch). Add some tests that reverse the merge order of two other tests, and which verify the contents are as expected (namely, that the results are identical other than modified-for-uniqueness filenames involving branch names). Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Sep 20, 2010 at 02:28 UTC 3398f2f58317e1a22093a0149a5eae1fe208b024
1 file changed +58
t/t6022-merge-rename.sh
+58
@@ -415,6 +415,28 @@ test_expect_failure 'Rename+D/F conflict; renamed file merges but dir in way' '
415 test_cmp expected dir~HEAD
416 '
417
418 +test_expect_failure 'Same as previous, but merged other way' '
419 + git reset --hard &&
420 + rm -rf dir~* &&
421 + git checkout -q dir-in-way^0 &&
422 + test_must_fail git merge --strategy=recursive renamed-file-has-no-conflicts >output 2>errors &&
423 +
424 + ! grep "error: refusing to lose untracked file at" errors &&
425 + grep "CONFLICT (delete/modify): dir/file-in-the-way" output &&
426 + grep "Auto-merging dir" output &&
427 + grep "Adding as dir~renamed-file-has-no-conflicts instead" output &&
428 +
429 + test 2 = "$(git ls-files -u | wc -l)" &&
430 + test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
431 +
432 + test_must_fail git diff --quiet &&
433 + test_must_fail git diff --cached --quiet &&
434 +
435 + test -f dir/file-in-the-way &&
436 + test -f dir~renamed-file-has-no-conflicts &&
437 + test_cmp expected dir~renamed-file-has-no-conflicts
438 +'
439 +
440 cat >expected <<\EOF &&
441 1
442 2
@@ -469,4 +491,40 @@ test_expect_failure 'Rename+D/F conflict; renamed file cannot merge and dir in t
491 test_cmp expected dir~HEAD
492 '
493
494 +cat >expected <<\EOF &&
495 +1
496 +2
497 +3
498 +4
499 +5
500 +6
501 +7
502 +8
503 +9
504 +10
505 +<<<<<<< HEAD
506 +11
507 +=======
508 +12
509 +>>>>>>> renamed-file-has-conflicts
510 +EOF
511 +
512 +test_expect_failure 'Same as previous, but merged other way' '
513 + git reset --hard &&
514 + rm -rf dir~* &&
515 + git checkout -q dir-in-way^0 &&
516 + test_must_fail git merge --strategy=recursive renamed-file-has-conflicts &&
517 +
518 + test 5 = "$(git ls-files -u | wc -l)" &&
519 + test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
520 + test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
521 +
522 + test_must_fail git diff --quiet &&
523 + test_must_fail git diff --cached --quiet &&
524 +
525 + test -f dir/file-in-the-way &&
526 + test -f dir~renamed-file-has-conflicts &&
527 + test_cmp expected dir~renamed-file-has-conflicts
528 +'
529 +
530 test_done