@matheusbsbs / matheus-bagliano / commits / af6e175199
Fork 0

t6022: Add test combinations of {content conflict?, D/F conflict remains?}

Add testing of the various ways that a renamed file to a path involved in a directory/file conflict may be involved in. This includes whether or not there are conflicts of the contents of the renamed file (if the file was modified on both sides of history), and whether the directory from the other side of the merge will disappear as a result of the merge or not. 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 af6e17519978eed17c406206e1afc9f0501abf77
1 file changed +128
t/t6022-merge-rename.sh
+128
@@ -3,6 +3,11 @@
3 test_description='Merge-recursive merging renames'
4 . ./test-lib.sh
5
6 +modify () {
7 + sed -e "$1" <"$2" >"$2.x" &&
8 + mv "$2.x" "$2"
9 +}
10 +
11 test_expect_success setup \
12 '
13 cat >A <<\EOF &&
@@ -341,4 +346,127 @@ test_expect_success 'merge of identical changes in a renamed file' '
346 GIT_MERGE_VERBOSITY=3 git merge change+rename | grep "^Skipped B"
347 '
348
349 +test_expect_success 'setup for rename + d/f conflicts' '
350 + git reset --hard &&
351 + git checkout --orphan dir-in-way &&
352 + git rm -rf . &&
353 +
354 + mkdir sub &&
355 + mkdir dir &&
356 + printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >sub/file &&
357 + echo foo >dir/file-in-the-way &&
358 + git add -A &&
359 + git commit -m "Common commmit" &&
360 +
361 + echo 11 >>sub/file &&
362 + echo more >>dir/file-in-the-way &&
363 + git add -u &&
364 + git commit -m "Commit to merge, with dir in the way" &&
365 +
366 + git checkout -b dir-not-in-way &&
367 + git reset --soft HEAD^ &&
368 + git rm -rf dir &&
369 + git commit -m "Commit to merge, with dir removed" -- dir sub/file &&
370 +
371 + git checkout -b renamed-file-has-no-conflicts dir-in-way~1 &&
372 + git rm -rf dir &&
373 + git rm sub/file &&
374 + printf "1\n2\n3\n4\n5555\n6\n7\n8\n9\n10\n" >dir &&
375 + git add dir &&
376 + git commit -m "Independent change" &&
377 +
378 + git checkout -b renamed-file-has-conflicts dir-in-way~1 &&
379 + git rm -rf dir &&
380 + git mv sub/file dir &&
381 + echo 12 >>dir &&
382 + git add dir &&
383 + git commit -m "Conflicting change"
384 +'
385 +
386 +printf "1\n2\n3\n4\n5555\n6\n7\n8\n9\n10\n11\n" >expected
387 +
388 +test_expect_success 'Rename+D/F conflict; renamed file merges + dir not in way' '
389 + git reset --hard &&
390 + git checkout -q renamed-file-has-no-conflicts^0 &&
391 + git merge --strategy=recursive dir-not-in-way &&
392 + git diff --quiet &&
393 + test -f dir &&
394 + test_cmp expected dir
395 +'
396 +
397 +test_expect_failure 'Rename+D/F conflict; renamed file merges but dir in way' '
398 + git reset --hard &&
399 + rm -rf dir~* &&
400 + git checkout -q renamed-file-has-no-conflicts^0 &&
401 + test_must_fail git merge --strategy=recursive dir-in-way >output &&
402 +
403 + grep "CONFLICT (delete/modify): dir/file-in-the-way" output &&
404 + grep "Auto-merging dir" output &&
405 + grep "Adding as dir~HEAD instead" output &&
406 +
407 + test 2 = "$(git ls-files -u | wc -l)" &&
408 + test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
409 +
410 + test_must_fail git diff --quiet &&
411 + test_must_fail git diff --cached --quiet &&
412 +
413 + test -f dir/file-in-the-way &&
414 + test -f dir~HEAD &&
415 + test_cmp expected dir~HEAD
416 +'
417 +
418 +cat >expected <<\EOF &&
419 +1
420 +2
421 +3
422 +4
423 +5
424 +6
425 +7
426 +8
427 +9
428 +10
429 +<<<<<<< HEAD
430 +12
431 +=======
432 +11
433 +>>>>>>> dir-not-in-way
434 +EOF
435 +
436 +test_expect_failure 'Rename+D/F conflict; renamed file cannot merge, dir not in way' '
437 + git reset --hard &&
438 + rm -rf dir~* &&
439 + git checkout -q renamed-file-has-conflicts^0 &&
440 + test_must_fail git merge --strategy=recursive dir-not-in-way &&
441 +
442 + test 3 = "$(git ls-files -u | wc -l)" &&
443 + test 3 = "$(git ls-files -u dir | wc -l)" &&
444 +
445 + test_must_fail git diff --quiet &&
446 + test_must_fail git diff --cached --quiet &&
447 +
448 + test -f dir &&
449 + test_cmp expected dir
450 +'
451 +
452 +test_expect_failure 'Rename+D/F conflict; renamed file cannot merge and dir in the way' '
453 + modify s/dir-not-in-way/dir-in-way/ expected &&
454 +
455 + git reset --hard &&
456 + rm -rf dir~* &&
457 + git checkout -q renamed-file-has-conflicts^0 &&
458 + test_must_fail git merge --strategy=recursive dir-in-way &&
459 +
460 + test 5 = "$(git ls-files -u | wc -l)" &&
461 + test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
462 + test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
463 +
464 + test_must_fail git diff --quiet &&
465 + test_must_fail git diff --cached --quiet &&
466 +
467 + test -f dir/file-in-the-way &&
468 + test -f dir~HEAD &&
469 + test_cmp expected dir~HEAD
470 +'
471 +
472 test_done