| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git am with options and not losing them' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | tm="$TEST_DIRECTORY/t4252" |
| 8 | |
| 9 | test_expect_success setup ' |
| 10 | cp "$tm/file-1-0" file-1 && |
| 11 | cp "$tm/file-2-0" file-2 && |
| 12 | git add file-1 file-2 && |
| 13 | test_tick && |
| 14 | git commit -m initial && |
| 15 | git tag initial |
| 16 | ' |
| 17 | |
| 18 | test_expect_success 'interrupted am --whitespace=fix' ' |
| 19 | rm -rf .git/rebase-apply && |
| 20 | git reset --hard initial && |
| 21 | test_must_fail git am --whitespace=fix "$tm"/am-test-1-? && |
| 22 | git am --skip && |
| 23 | test_grep 3 file-1 && |
| 24 | test_grep "^Six$" file-2 |
| 25 | ' |
| 26 | |
| 27 | test_expect_success 'interrupted am -C1' ' |
| 28 | rm -rf .git/rebase-apply && |
| 29 | git reset --hard initial && |
| 30 | test_must_fail git am -C1 "$tm"/am-test-2-? && |
| 31 | git am --skip && |
| 32 | test_grep 3 file-1 && |
| 33 | test_grep "^Three$" file-2 |
| 34 | ' |
| 35 | |
| 36 | test_expect_success 'interrupted am -p2' ' |
| 37 | rm -rf .git/rebase-apply && |
| 38 | git reset --hard initial && |
| 39 | test_must_fail git am -p2 "$tm"/am-test-3-? && |
| 40 | git am --skip && |
| 41 | test_grep 3 file-1 && |
| 42 | test_grep "^Three$" file-2 |
| 43 | ' |
| 44 | |
| 45 | test_expect_success 'interrupted am -C1 -p2' ' |
| 46 | rm -rf .git/rebase-apply && |
| 47 | git reset --hard initial && |
| 48 | test_must_fail git am -p2 -C1 "$tm"/am-test-4-? && |
| 49 | git am --skip && |
| 50 | test_grep 3 file-1 && |
| 51 | test_grep "^Three$" file-2 |
| 52 | ' |
| 53 | |
| 54 | test_expect_success 'interrupted am --directory="frotz nitfol"' ' |
| 55 | rm -rf .git/rebase-apply && |
| 56 | git reset --hard initial && |
| 57 | test_must_fail git am --directory="frotz nitfol" "$tm"/am-test-5-? && |
| 58 | git am --skip && |
| 59 | test_grep One "frotz nitfol/file-5" |
| 60 | ' |
| 61 | |
| 62 | test_expect_success 'apply to a funny path' ' |
| 63 | with_sq="with'\''sq" && |
| 64 | rm -fr .git/rebase-apply && |
| 65 | git reset --hard initial && |
| 66 | git am --directory="$with_sq" "$tm"/am-test-5-2 && |
| 67 | test -f "$with_sq/file-5" |
| 68 | ' |
| 69 | |
| 70 | test_expect_success 'am --reject' ' |
| 71 | rm -rf .git/rebase-apply && |
| 72 | git reset --hard initial && |
| 73 | test_must_fail git am --reject "$tm"/am-test-6-1 && |
| 74 | test_grep "@@ -1,3 +1,3 @@" file-2.rej && |
| 75 | test_must_fail git diff-files --exit-code --quiet file-2 && |
| 76 | test_grep "[-]-reject" .git/rebase-apply/apply-opt |
| 77 | ' |
| 78 | |
| 79 | test_done |