test_expect_success 'pull renaming branch into unrenaming one' \
'
- git show-branch
- git pull . white && {
- echo "BAD: should have conflicted"
- return 1
- }
- git ls-files -s
- test "$(git ls-files -u B | wc -l)" -eq 3 || {
- echo "BAD: should have left stages for B"
- return 1
- }
- test "$(git ls-files -s N | wc -l)" -eq 1 || {
- echo "BAD: should have merged N"
- return 1
- }
+ git show-branch &&
+ test_expect_code 1 git pull . white &&
+ git ls-files -s &&
+ git ls-files -u B >b.stages &&
+ test_line_count = 3 b.stages &&
+ git ls-files -s N >n.stages &&
+ test_line_count = 1 n.stages &&
sed -ne "/^g/{
p
q
- }" B | grep master || {
- echo "BAD: should have listed our change first"
- return 1
- }
- test "$(git diff white N | wc -l)" -eq 0 || {
- echo "BAD: should have taken colored branch"
- return 1
- }
+ }" B | grep master &&
+ git diff --exit-code white N
'
test_expect_success 'pull renaming branch into another renaming one' \
'
- rm -f B
- git reset --hard
- git checkout red
- git pull . white && {
- echo "BAD: should have conflicted"
- return 1
- }
- test "$(git ls-files -u B | wc -l)" -eq 3 || {
- echo "BAD: should have left stages"
- return 1
- }
- test "$(git ls-files -s N | wc -l)" -eq 1 || {
- echo "BAD: should have merged N"
- return 1
- }
+ rm -f B &&
+ git reset --hard &&
+ git checkout red &&
+ test_expect_code 1 git pull . white &&
+ git ls-files -u B >b.stages &&
+ test_line_count = 3 b.stages &&
+ git ls-files -s N >n.stages &&
+ test_line_count = 1 n.stages &&
sed -ne "/^g/{
p
q
- }" B | grep red || {
- echo "BAD: should have listed our change first"
- return 1
- }
- test "$(git diff white N | wc -l)" -eq 0 || {
- echo "BAD: should have taken colored branch"
- return 1
- }
+ }" B | grep red &&
+ git diff --exit-code white N
'
test_expect_success 'pull unrenaming branch into renaming one' \
'
- git reset --hard
- git show-branch
- git pull . master && {
- echo "BAD: should have conflicted"
- return 1
- }
- test "$(git ls-files -u B | wc -l)" -eq 3 || {
- echo "BAD: should have left stages"
- return 1
- }
- test "$(git ls-files -s N | wc -l)" -eq 1 || {
- echo "BAD: should have merged N"
- return 1
- }
+ git reset --hard &&
+ git show-branch &&
+ test_expect_code 1 git pull . master &&
+ git ls-files -u B >b.stages &&
+ test_line_count = 3 b.stages &&
+ git ls-files -s N >n.stages &&
+ test_line_count = 1 n.stages &&
sed -ne "/^g/{
p
q
- }" B | grep red || {
- echo "BAD: should have listed our change first"
- return 1
- }
- test "$(git diff white N | wc -l)" -eq 0 || {
- echo "BAD: should have taken colored branch"
- return 1
- }
+ }" B | grep red &&
+ git diff --exit-code white N
'
test_expect_success 'pull conflicting renames' \
'
- git reset --hard
- git show-branch
- git pull . blue && {
- echo "BAD: should have conflicted"
- return 1
- }
- test "$(git ls-files -u A | wc -l)" -eq 1 || {
- echo "BAD: should have left a stage"
- return 1
- }
- test "$(git ls-files -u B | wc -l)" -eq 1 || {
- echo "BAD: should have left a stage"
- return 1
- }
- test "$(git ls-files -u C | wc -l)" -eq 1 || {
- echo "BAD: should have left a stage"
- return 1
- }
- test "$(git ls-files -s N | wc -l)" -eq 1 || {
- echo "BAD: should have merged N"
- return 1
- }
+ git reset --hard &&
+ git show-branch &&
+ test_expect_code 1 git pull . blue &&
+ git ls-files -u A >a.stages &&
+ test_line_count = 1 a.stages &&
+ git ls-files -u B >b.stages &&
+ test_line_count = 1 b.stages &&
+ git ls-files -u C >c.stages &&
+ test_line_count = 1 c.stages &&
+ git ls-files -s N >n.stages &&
+ test_line_count = 1 n.stages &&
sed -ne "/^g/{
p
q
- }" B | grep red || {
- echo "BAD: should have listed our change first"
- return 1
- }
- test "$(git diff white N | wc -l)" -eq 0 || {
- echo "BAD: should have taken colored branch"
- return 1
- }
+ }" B | grep red &&
+ git diff --exit-code white N
'
test_expect_success 'interference with untracked working tree file' '
-
- git reset --hard
- git show-branch
- echo >A this file should not matter
- git pull . white && {
- echo "BAD: should have conflicted"
- return 1
- }
- test -f A || {
- echo "BAD: should have left A intact"
- return 1
- }
+ git reset --hard &&
+ git show-branch &&
+ echo >A this file should not matter &&
+ test_expect_code 1 git pull . white &&
+ test_path_is_file A
'
test_expect_success 'interference with untracked working tree file' '
-
- git reset --hard
- git checkout white
- git show-branch
- rm -f A
- echo >A this file should not matter
- git pull . red && {
- echo "BAD: should have conflicted"
- return 1
- }
- test -f A || {
- echo "BAD: should have left A intact"
- return 1
- }
+ git reset --hard &&
+ git checkout white &&
+ git show-branch &&
+ rm -f A &&
+ echo >A this file should not matter &&
+ test_expect_code 1 git pull . red &&
+ test_path_is_file A
'
test_expect_success 'interference with untracked working tree file' '
-
- git reset --hard
- rm -f A M
- git checkout -f master
- git tag -f anchor
- git show-branch
- git pull . yellow || {
- echo "BAD: should have cleanly merged"
- return 1
- }
- test -f M && {
- echo "BAD: should have removed M"
- return 1
- }
+ git reset --hard &&
+ rm -f A M &&
+ git checkout -f master &&
+ git tag -f anchor &&
+ git show-branch &&
+ git pull . yellow &&
+ test_path_is_missing M &&
git reset --hard anchor
'
test_expect_success 'updated working tree file should prevent the merge' '
-
- git reset --hard
- rm -f A M
- git checkout -f master
- git tag -f anchor
- git show-branch
- echo >>M one line addition
- cat M >M.saved
- git pull . yellow && {
- echo "BAD: should have complained"
- return 1
- }
- test_cmp M M.saved || {
- echo "BAD: should have left M intact"
- return 1
- }
+ git reset --hard &&
+ rm -f A M &&
+ git checkout -f master &&
+ git tag -f anchor &&
+ git show-branch &&
+ echo >>M one line addition &&
+ cat M >M.saved &&
+ test_expect_code 128 git pull . yellow &&
+ test_cmp M M.saved &&
rm -f M.saved
'
test_expect_success 'updated working tree file should prevent the merge' '
-
- git reset --hard
- rm -f A M
- git checkout -f master
- git tag -f anchor
- git show-branch
- echo >>M one line addition
- cat M >M.saved
- git update-index M
- git pull . yellow && {
- echo "BAD: should have complained"
- return 1
- }
- test_cmp M M.saved || {
- echo "BAD: should have left M intact"
- return 1
- }
+ git reset --hard &&
+ rm -f A M &&
+ git checkout -f master &&
+ git tag -f anchor &&
+ git show-branch &&
+ echo >>M one line addition &&
+ cat M >M.saved &&
+ git update-index M &&
+ test_expect_code 128 git pull . yellow &&
+ test_cmp M M.saved &&
rm -f M.saved
'
test_expect_success 'interference with untracked working tree file' '
-
- git reset --hard
- rm -f A M
- git checkout -f yellow
- git tag -f anchor
- git show-branch
- echo >M this file should not matter
- git pull . master || {
- echo "BAD: should have cleanly merged"
- return 1
- }
- test -f M || {
- echo "BAD: should have left M intact"
- return 1
- }
- git ls-files -s | grep M && {
- echo "BAD: M must be untracked in the result"
- return 1
- }
+ git reset --hard &&
+ rm -f A M &&
+ git checkout -f yellow &&
+ git tag -f anchor &&
+ git show-branch &&
+ echo >M this file should not matter &&
+ git pull . master &&
+ test_path_is_file M &&
+ ! {
+ git ls-files -s |
+ grep M
+ } &&
git reset --hard anchor
'
test_expect_success 'merge of identical changes in a renamed file' '
- rm -f A M N
+ rm -f A M N &&
git reset --hard &&
git checkout change+rename &&
GIT_MERGE_VERBOSITY=3 git merge change | grep "^Skipped B" &&
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 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 &&
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 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 &&