t6022: New tests checking for unnecessary updates of files
This testcase was part of en/merge-recursive that was reverted in 6db4105 (Revert "Merge branch 'en/merge-recursive'" 2011-05-19). While the other changes in that series caused unfortunate breakage, this testcase is still useful; reinstate it. 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
f1a0f457b3d3cf3b4acea2addc1e26e7b931d474
1 file changed
+63
t/t6022-merge-rename.sh
+63
@@ -610,4 +610,67 @@ test_expect_success 'check handling of differently renamed file with D/F conflic
610
! test -f original
611
'
612
613
+test_expect_success 'setup avoid unnecessary update, normal rename' '
614
+ git reset --hard &&
615
+ git checkout --orphan avoid-unnecessary-update-1 &&
616
+ git rm -rf . &&
617
+ git clean -fdqx &&
618
+
619
+ printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >original &&
620
+ git add -A &&
621
+ git commit -m "Common commmit" &&
622
+
623
+ git mv original rename &&
624
+ echo 11 >>rename &&
625
+ git add -u &&
626
+ git commit -m "Renamed and modified" &&
627
+
628
+ git checkout -b merge-branch-1 HEAD~1 &&
629
+ echo "random content" >random-file &&
630
+ git add -A &&
631
+ git commit -m "Random, unrelated changes"
632
+'
633
+
634
+test_expect_failure 'avoid unnecessary update, normal rename' '
635
+ git checkout -q avoid-unnecessary-update-1^0 &&
636
+ test-chmtime =1000000000 rename &&
637
+ test-chmtime -v +0 rename >expect &&
638
+ git merge merge-branch-1 &&
639
+ test-chmtime -v +0 rename >actual &&
640
+ test_cmp expect actual # "rename" should have stayed intact
641
+'
642
+
643
+test_expect_success 'setup to test avoiding unnecessary update, with D/F conflict' '
644
+ git reset --hard &&
645
+ git checkout --orphan avoid-unnecessary-update-2 &&
646
+ git rm -rf . &&
647
+ git clean -fdqx &&
648
+
649
+ mkdir df &&
650
+ printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >df/file &&
651
+ git add -A &&
652
+ git commit -m "Common commmit" &&
653
+
654
+ git mv df/file temp &&
655
+ rm -rf df &&
656
+ git mv temp df &&
657
+ echo 11 >>df &&
658
+ git add -u &&
659
+ git commit -m "Renamed and modified" &&
660
+
661
+ git checkout -b merge-branch-2 HEAD~1 &&
662
+ >unrelated-change &&
663
+ git add unrelated-change &&
664
+ git commit -m "Only unrelated changes"
665
+'
666
+
667
+test_expect_failure 'avoid unnecessary update, with D/F conflict' '
668
+ git checkout -q avoid-unnecessary-update-2^0 &&
669
+ test-chmtime =1000000000 df &&
670
+ test-chmtime -v +0 df >expect &&
671
+ git merge merge-branch-2 &&
672
+ test-chmtime -v +0 df >actual &&
673
+ test_cmp expect actual # "df" should have stayed intact
674
+'
675
+
676
test_done