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