]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4151-am-abort.sh
test-lib: refactor $GIT_SKIP_TESTS matching
[thirdparty/git.git] / t / t4151-am-abort.sh
CommitLineData
3e5057a8
NS
1#!/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 &&
95f8ebbf 17 for i in 2 3 4 5 6
3e5057a8
NS
18 do
19 echo $i >>file-1 &&
9944d1a0
OM
20 echo $i >otherfile-$i &&
21 git add otherfile-$i &&
3e5057a8
NS
22 test_tick &&
23 git commit -a -m $i || break
24 done &&
a567fdcb 25 git format-patch --no-numbered initial &&
3e5057a8
NS
26 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
95f8ebbf 37 test_must_fail git am$with3 000[1245]-*.patch &&
3e5057a8
NS
38 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
95f8ebbf 46 test_expect_success "am$with3 --skip continue after failed am$with3" '
3604e7c5 47 test_must_fail git am$with3 --skip >output &&
dff1a983
ÆAB
48 test_i18ngrep "^Applying" output >output.applying &&
49 test_i18ngrep "^Applying: 6$" output.applying &&
50 test_i18ncmp file-2-expect file-2 &&
3ca399d4 51 test ! -f .git/MERGE_RR
95f8ebbf
OM
52 '
53
3e5057a8 54 test_expect_success "am --abort goes back after failed am$with3" '
3604e7c5 55 git am --abort &&
3e5057a8
NS
56 git rev-parse HEAD >actual &&
57 git rev-parse initial >expect &&
58 test_cmp expect actual &&
59 test_cmp file-2-expect file-2 &&
60 git diff-index --exit-code --cached HEAD &&
3ca399d4 61 test ! -f .git/MERGE_RR
3e5057a8
NS
62 '
63
64done
65
7b3b7e37
JH
66test_expect_success 'am --abort will keep the local commits intact' '
67 test_must_fail git am 0004-*.patch &&
68 test_commit unrelated &&
69 git rev-parse HEAD >expect &&
70 git am --abort &&
71 git rev-parse HEAD >actual &&
72 test_cmp expect actual
73'
74
3e5057a8 75test_done