3 test_description='am --interactive tests'
6 test_expect_success 'set up patches to apply' '
7 test_commit unrelated &&
8 test_commit no-conflict &&
9 test_commit conflict-patch file patch &&
10 git format-patch --stdout -2 >mbox &&
12 git reset --hard unrelated &&
13 test_commit conflict-master file master base
16 # Sanity check our setup.
17 test_expect_success 'applying all patches generates conflict' '
18 test_must_fail git am mbox &&
19 echo resolved >file &&
24 test_expect_success 'interactive am can apply a single patch' '
25 git reset --hard base &&
26 # apply the first, but not the second
27 test_write_lines y n | git am -i mbox &&
29 echo no-conflict >expect &&
30 git log -1 --format=%s >actual &&
31 test_cmp expect actual
34 test_expect_success 'interactive am can resolve conflict' '
35 git reset --hard base &&
36 # apply both; the second one will conflict
37 test_write_lines y y | test_must_fail git am -i mbox &&
38 echo resolved >file &&
40 # interactive "--resolved" will ask us if we want to apply the result
41 echo y | git am -i --resolved &&
43 echo conflict-patch >expect &&
44 git log -1 --format=%s >actual &&
45 test_cmp expect actual &&
47 echo resolved >expect &&
48 git cat-file blob HEAD:file >actual &&
49 test_cmp expect actual