builtin/am: allow disabling conflict advice
[alt-git.git] / t / t4257-am-interactive.sh
blobf26d7fd2dbd35ce40534a5d76f9903361f4b7904
1 #!/bin/sh
3 test_description='am --interactive tests'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
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 &&
14 git reset --hard unrelated &&
15 test_commit conflict-main file main base
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
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 &&
31 echo no-conflict >expect &&
32 git log -1 --format=%s >actual &&
33 test_cmp expect actual
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 &&
45 echo conflict-patch >expect &&
46 git log -1 --format=%s >actual &&
47 test_cmp expect actual &&
49 echo resolved >expect &&
50 git cat-file blob HEAD:file >actual &&
51 test_cmp expect actual
54 test_done