]>
Commit | Line | Data |
---|---|---|
7663e438 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='am --interactive tests' | |
b2e5d75d ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
7663e438 JK |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success 'set up patches to apply' ' | |
9 | test_commit unrelated && | |
10 | test_commit no-conflict && | |
11 | test_commit conflict-patch file patch && | |
12 | git format-patch --stdout -2 >mbox && | |
13 | ||
14 | git reset --hard unrelated && | |
8f37854b | 15 | test_commit conflict-main file main base |
7663e438 JK |
16 | ' |
17 | ||
18 | # Sanity check our setup. | |
19 | test_expect_success 'applying all patches generates conflict' ' | |
20 | test_must_fail git am mbox && | |
21 | echo resolved >file && | |
22 | git add -u && | |
23 | git am --resolved | |
24 | ' | |
25 | ||
26 | test_expect_success 'interactive am can apply a single patch' ' | |
27 | git reset --hard base && | |
28 | # apply the first, but not the second | |
29 | test_write_lines y n | git am -i mbox && | |
30 | ||
31 | echo no-conflict >expect && | |
32 | git log -1 --format=%s >actual && | |
33 | test_cmp expect actual | |
34 | ' | |
35 | ||
36 | test_expect_success 'interactive am can resolve conflict' ' | |
37 | git reset --hard base && | |
38 | # apply both; the second one will conflict | |
39 | test_write_lines y y | test_must_fail git am -i mbox && | |
40 | echo resolved >file && | |
41 | git add -u && | |
42 | # interactive "--resolved" will ask us if we want to apply the result | |
43 | echo y | git am -i --resolved && | |
44 | ||
45 | echo conflict-patch >expect && | |
46 | git log -1 --format=%s >actual && | |
47 | test_cmp expect actual && | |
48 | ||
49 | echo resolved >expect && | |
50 | git cat-file blob HEAD:file >actual && | |
51 | test_cmp expect actual | |
52 | ' | |
53 | ||
54 | test_done |