3 test_description
='git merge
5 Testing pull.* configuration parsing.'
9 test_expect_success
'setup' '
18 git reset --hard c0 &&
23 git reset --hard c0 &&
30 test_expect_success
'merge c1 with c2' '
31 git reset --hard c1 &&
41 test_expect_success
'merge c1 with c2 (ours in pull.twohead)' '
42 git reset --hard c1 &&
43 git config pull.twohead ours &&
49 test_expect_success
'merge c1 with c2 and c3 (recursive in pull.octopus)' '
50 git reset --hard c1 &&
51 git config pull.octopus "recursive" &&
52 test_must_fail git merge c2 c3 &&
53 test "$(git rev-parse c1)" = "$(git rev-parse HEAD)"
56 test_expect_success
'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' '
57 git reset --hard c1 &&
58 git config pull.octopus "recursive octopus" &&
60 test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
61 test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
62 test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
63 test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
64 git diff --exit-code &&
74 git diff-files
--name-only
75 git ls-files
--unmerged
82 # There are two conflicts here:
84 # 1) Because foo.c is renamed to bar.c, recursive will handle this,
87 # 2) One in conflict.c and that will always fail.
89 test_expect_success
'setup conflicted merge' '
90 git reset --hard c0 &&
93 echo contents >foo.c &&
102 git reset --hard c4 &&
103 echo C >conflict.c &&
104 git add conflict.c &&
105 echo secondline >> foo.c &&
111 # First do the merge with resolve and recursive then verify that
112 # recusive is chosen.
114 test_expect_success
'merge picks up the best result' '
115 git config --unset-all pull.twohead &&
116 git reset --hard c5 &&
117 test_must_fail git merge -s resolve c6 &&
118 resolve_count=$(conflict_count) &&
119 git reset --hard c5 &&
120 test_must_fail git merge -s recursive c6 &&
121 recursive_count=$(conflict_count) &&
122 git reset --hard c5 &&
123 test_must_fail git merge -s recursive -s resolve c6 &&
124 auto_count=$(conflict_count) &&
125 test $auto_count = $recursive_count &&
126 test $auto_count != $resolve_count
129 test_expect_success
'merge picks up the best result (from config)' '
130 git config pull.twohead "recursive resolve" &&
131 git reset --hard c5 &&
132 test_must_fail git merge -s resolve c6 &&
133 resolve_count=$(conflict_count) &&
134 git reset --hard c5 &&
135 test_must_fail git merge -s recursive c6 &&
136 recursive_count=$(conflict_count) &&
137 git reset --hard c5 &&
138 test_must_fail git merge c6 &&
139 auto_count=$(conflict_count) &&
140 test $auto_count = $recursive_count &&
141 test $auto_count != $resolve_count
144 test_expect_success
'merge errors out on invalid strategy' '
145 git config pull.twohead "foobar" &&
146 git reset --hard c5 &&
147 test_must_fail git merge c6
150 test_expect_success
'merge errors out on invalid strategy' '
151 git config --unset-all pull.twohead &&
152 git reset --hard c5 &&
153 test_must_fail git merge -s "resolve recursive" c6