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