t6022: Additional tests checking for unnecessary updates of files

I stumbled across a case, this one not involving a content merge, where git currently rewrites a file unnecessarily. A quick audit uncovered two additional situations (also not involving content merges) with the same problem. 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:20 UTC 3e333a6146ce6565de357e48e439bb94c622d3fe
1 file changed +91
t/t6022-merge-rename.sh
+91
@@ -673,6 +673,97 @@ test_expect_success 'avoid unnecessary update, with D/F conflict' '
673 test_cmp expect actual # "df" should have stayed intact
674 '
675
676 +test_expect_success 'setup avoid unnecessary update, dir->(file,nothing)' '
677 + git rm -rf . &&
678 + git clean -fdqx &&
679 + rm -rf .git &&
680 + git init &&
681 +
682 + >irrelevant &&
683 + mkdir df &&
684 + >df/file &&
685 + git add -A &&
686 + git commit -mA &&
687 +
688 + git checkout -b side
689 + git rm -rf df &&
690 + git commit -mB &&
691 +
692 + git checkout master &&
693 + git rm -rf df &&
694 + echo bla >df &&
695 + git add -A &&
696 + git commit -m "Add a newfile"
697 +'
698 +
699 +test_expect_failure 'avoid unnecessary update, dir->(file,nothing)' '
700 + git checkout -q master^0 &&
701 + test-chmtime =1000000000 df &&
702 + test-chmtime -v +0 df >expect &&
703 + git merge side &&
704 + test-chmtime -v +0 df >actual &&
705 + test_cmp expect actual # "df" should have stayed intact
706 +'
707 +
708 +test_expect_success 'setup avoid unnecessary update, modify/delete' '
709 + git rm -rf . &&
710 + git clean -fdqx &&
711 + rm -rf .git &&
712 + git init &&
713 +
714 + >irrelevant &&
715 + >file &&
716 + git add -A &&
717 + git commit -mA &&
718 +
719 + git checkout -b side
720 + git rm -f file &&
721 + git commit -m "Delete file" &&
722 +
723 + git checkout master &&
724 + echo bla >file &&
725 + git add -A &&
726 + git commit -m "Modify file"
727 +'
728 +
729 +test_expect_failure 'avoid unnecessary update, modify/delete' '
730 + git checkout -q master^0 &&
731 + test-chmtime =1000000000 file &&
732 + test-chmtime -v +0 file >expect &&
733 + test_must_fail git merge side &&
734 + test-chmtime -v +0 file >actual &&
735 + test_cmp expect actual # "file" should have stayed intact
736 +'
737 +
738 +test_expect_success 'setup avoid unnecessary update, rename/add-dest' '
739 + git rm -rf . &&
740 + git clean -fdqx &&
741 + rm -rf .git &&
742 + git init &&
743 +
744 + printf "1\n2\n3\n4\n5\n6\n7\n8\n" >file &&
745 + git add -A &&
746 + git commit -mA &&
747 +
748 + git checkout -b side
749 + cp file newfile &&
750 + git add -A &&
751 + git commit -m "Add file copy" &&
752 +
753 + git checkout master &&
754 + git mv file newfile &&
755 + git commit -m "Rename file"
756 +'
757 +
758 +test_expect_failure 'avoid unnecessary update, rename/add-dest' '
759 + git checkout -q master^0 &&
760 + test-chmtime =1000000000 newfile &&
761 + test-chmtime -v +0 newfile >expect &&
762 + git merge side &&
763 + test-chmtime -v +0 newfile >actual &&
764 + test_cmp expect actual # "file" should have stayed intact
765 +'
766 +
767 test_expect_success 'setup merge of rename + small change' '
768 git reset --hard &&
769 git checkout --orphan rename-plus-small-change &&