blob: 2b912d77283fbd3fc02a7d9d6bca660e4193b8c3 [file] [log] [blame]
Nanako Shiraishi3e5057a2008-07-16 19:39:10 +09001#!/bin/sh
2
3test_description='am --abort'
4
5. ./test-lib.sh
6
7test_expect_success setup '
8 for i in a b c d e f g
9 do
10 echo $i
11 done >file-1 &&
12 cp file-1 file-2 &&
13 test_tick &&
14 git add file-1 file-2 &&
15 git commit -m initial &&
16 git tag initial &&
Olivier Marin95f8ebb2008-07-21 15:39:06 +020017 for i in 2 3 4 5 6
Nanako Shiraishi3e5057a2008-07-16 19:39:10 +090018 do
19 echo $i >>file-1 &&
Olivier Marin9944d1a2008-07-24 14:44:40 +020020 echo $i >otherfile-$i &&
21 git add otherfile-$i &&
Nanako Shiraishi3e5057a2008-07-16 19:39:10 +090022 test_tick &&
23 git commit -a -m $i || break
24 done &&
Brian Gernhardta567fdc2008-10-02 16:55:39 -040025 git format-patch --no-numbered initial &&
Nanako Shiraishi3e5057a2008-07-16 19:39:10 +090026 git checkout -b side initial &&
27 echo local change >file-2-expect
28'
29
30for with3 in '' ' -3'
31do
32 test_expect_success "am$with3 stops at a patch that does not apply" '
33
34 git reset --hard initial &&
35 cp file-2-expect file-2 &&
36
Olivier Marin95f8ebb2008-07-21 15:39:06 +020037 test_must_fail git am$with3 000[1245]-*.patch &&
Nanako Shiraishi3e5057a2008-07-16 19:39:10 +090038 git log --pretty=tformat:%s >actual &&
39 for i in 3 2 initial
40 do
41 echo $i
42 done >expect &&
43 test_cmp expect actual
44 '
45
Olivier Marin95f8ebb2008-07-21 15:39:06 +020046 test_expect_success "am$with3 --skip continue after failed am$with3" '
Nanako Shiraishi3604e7c2008-09-03 17:59:29 +090047 test_must_fail git am$with3 --skip >output &&
Stephan Beyerc8fe1982008-07-23 18:46:36 +020048 test "$(grep "^Applying" output)" = "Applying: 6" &&
Olivier Marin95f8ebb2008-07-21 15:39:06 +020049 test_cmp file-2-expect file-2 &&
50 test ! -f .git/rr-cache/MERGE_RR
51 '
52
Nanako Shiraishi3e5057a2008-07-16 19:39:10 +090053 test_expect_success "am --abort goes back after failed am$with3" '
Nanako Shiraishi3604e7c2008-09-03 17:59:29 +090054 git am --abort &&
Nanako Shiraishi3e5057a2008-07-16 19:39:10 +090055 git rev-parse HEAD >actual &&
56 git rev-parse initial >expect &&
57 test_cmp expect actual &&
58 test_cmp file-2-expect file-2 &&
59 git diff-index --exit-code --cached HEAD &&
60 test ! -f .git/rr-cache/MERGE_RR
61 '
62
63done
64
65test_done