test_cmp expected dir
'
-test_expect_failure 'Rename+D/F conflict; renamed file merges but dir in way' '
+test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' '
git reset --hard &&
rm -rf dir~* &&
git checkout -q renamed-file-has-no-conflicts^0 &&
grep "Auto-merging dir" output &&
grep "Adding as dir~HEAD instead" output &&
- test 2 = "$(git ls-files -u | wc -l)" &&
- test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
+ test 2 -eq "$(git ls-files -u | wc -l)" &&
+ test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
test_cmp expected dir~HEAD
'
-test_expect_failure 'Same as previous, but merged other way' '
+test_expect_success 'Same as previous, but merged other way' '
git reset --hard &&
rm -rf dir~* &&
git checkout -q dir-in-way^0 &&
grep "Auto-merging dir" output &&
grep "Adding as dir~renamed-file-has-no-conflicts instead" output &&
- test 2 = "$(git ls-files -u | wc -l)" &&
- test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
+ test 2 -eq "$(git ls-files -u | wc -l)" &&
+ test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
git checkout -q renamed-file-has-conflicts^0 &&
test_must_fail git merge --strategy=recursive dir-not-in-way &&
- test 3 = "$(git ls-files -u | wc -l)" &&
- test 3 = "$(git ls-files -u dir | wc -l)" &&
+ test 3 -eq "$(git ls-files -u | wc -l)" &&
+ test 3 -eq "$(git ls-files -u dir | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
test_cmp expected dir
'
-test_expect_failure 'Rename+D/F conflict; renamed file cannot merge and dir in the way' '
+test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in the way' '
modify s/dir-not-in-way/dir-in-way/ expected &&
git reset --hard &&
git checkout -q renamed-file-has-conflicts^0 &&
test_must_fail git merge --strategy=recursive dir-in-way &&
- test 5 = "$(git ls-files -u | wc -l)" &&
- test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
- test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
+ test 5 -eq "$(git ls-files -u | wc -l)" &&
+ test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
+ test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
>>>>>>> renamed-file-has-conflicts
EOF
-test_expect_failure 'Same as previous, but merged other way' '
+test_expect_success 'Same as previous, but merged other way' '
git reset --hard &&
rm -rf dir~* &&
git checkout -q dir-in-way^0 &&
test_must_fail git merge --strategy=recursive renamed-file-has-conflicts &&
- test 5 = "$(git ls-files -u | wc -l)" &&
- test 3 = "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
- test 2 = "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
+ test 5 -eq "$(git ls-files -u | wc -l)" &&
+ test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" &&
+ test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" &&
test_must_fail git diff --quiet &&
test_must_fail git diff --cached --quiet &&
git commit -m "Conflicts in the way"
'
-test_expect_failure 'both rename source and destination involved in D/F conflict' '
+test_expect_success 'both rename source and destination involved in D/F conflict' '
git reset --hard &&
rm -rf dir~* &&
git checkout -q rename-dest^0 &&
test_must_fail git merge --strategy=recursive source-conflict &&
- test 1 = "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u | wc -l)" &&
test_must_fail git diff --quiet &&
git commit -m "Rename one/file -> two"
'
-test_expect_failure 'pair rename to parent of other (D/F conflicts) w/ untracked dir' '
+test_expect_success 'pair rename to parent of other (D/F conflicts) w/ untracked dir' '
git checkout -q rename-one^0 &&
mkdir one &&
test_must_fail git merge --strategy=recursive rename-two &&
- test 2 = "$(git ls-files -u | wc -l)" &&
- test 1 = "$(git ls-files -u one | wc -l)" &&
- test 1 = "$(git ls-files -u two | wc -l)" &&
+ test 2 -eq "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u one | wc -l)" &&
+ test 1 -eq "$(git ls-files -u two | wc -l)" &&
test_must_fail git diff --quiet &&
- test 4 = $(find . | grep -v .git | wc -l) &&
+ test 4 -eq $(find . | grep -v .git | wc -l) &&
test -d one &&
test -f one~rename-two &&
git clean -fdqx &&
test_must_fail git merge --strategy=recursive rename-two &&
- test 2 = "$(git ls-files -u | wc -l)" &&
- test 1 = "$(git ls-files -u one | wc -l)" &&
- test 1 = "$(git ls-files -u two | wc -l)" &&
+ test 2 -eq "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u one | wc -l)" &&
+ test 1 -eq "$(git ls-files -u two | wc -l)" &&
test_must_fail git diff --quiet &&
- test 3 = $(find . | grep -v .git | wc -l) &&
+ test 3 -eq $(find . | grep -v .git | wc -l) &&
test -f one &&
test -f two &&
git checkout -q first-rename^0 &&
test_must_fail git merge --strategy=recursive second-rename &&
- test 5 = "$(git ls-files -s | wc -l)" &&
- test 3 = "$(git ls-files -u | wc -l)" &&
- test 1 = "$(git ls-files -u one | wc -l)" &&
- test 1 = "$(git ls-files -u two | wc -l)" &&
- test 1 = "$(git ls-files -u original | wc -l)" &&
- test 2 = "$(git ls-files -o | wc -l)" &&
+ test 5 -eq "$(git ls-files -s | wc -l)" &&
+ test 3 -eq "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u one | wc -l)" &&
+ test 1 -eq "$(git ls-files -u two | wc -l)" &&
+ test 1 -eq "$(git ls-files -u original | wc -l)" &&
+ test 2 -eq "$(git ls-files -o | wc -l)" &&
test -f one/file &&
test -f two/file &&
git commit -m "Rename to two"
'
-test_expect_failure 'check handling of differently renamed file with D/F conflicts' '
+test_expect_success 'check handling of differently renamed file with D/F conflicts' '
git checkout -q first-rename-redo^0 &&
test_must_fail git merge --strategy=recursive second-rename-redo &&
- test 3 = "$(git ls-files -u | wc -l)" &&
- test 1 = "$(git ls-files -u one | wc -l)" &&
- test 1 = "$(git ls-files -u two | wc -l)" &&
- test 1 = "$(git ls-files -u original | wc -l)" &&
- test 0 = "$(git ls-files -o | wc -l)" &&
+ test 3 -eq "$(git ls-files -u | wc -l)" &&
+ test 1 -eq "$(git ls-files -u one | wc -l)" &&
+ test 1 -eq "$(git ls-files -u two | wc -l)" &&
+ test 1 -eq "$(git ls-files -u original | wc -l)" &&
+ test 0 -eq "$(git ls-files -o | wc -l)" &&
test -f one &&
test -f two &&
! test -f original
'
+test_expect_success 'setup avoid unnecessary update, normal rename' '
+ git reset --hard &&
+ git checkout --orphan avoid-unnecessary-update-1 &&
+ git rm -rf . &&
+ git clean -fdqx &&
+
+ printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" >original &&
+ git add -A &&
+ git commit -m "Common commmit" &&
+
+ git mv original rename &&
+ echo 11 >>rename &&
+ git add -u &&
+ git commit -m "Renamed and modified" &&
+
+ git checkout -b merge-branch-1 HEAD~1 &&
+ echo "random content" >random-file &&
+ git add -A &&
+ git commit -m "Random, unrelated changes"
+'
+
+test_expect_failure 'avoid unnecessary update, normal rename' '
+ git checkout -q avoid-unnecessary-update-1^0 &&
+ test-chmtime =1000000000 rename &&
+ test-chmtime -v +0 rename >expect &&
+ git merge merge-branch-1 &&
+ test-chmtime -v +0 rename >actual &&
+ test_cmp expect actual # "rename" should have stayed intact
+'
+
test_done