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
'pull.rebase not set' '
31 git reset --hard c0 &&
32 git pull . c1 2>err &&
33 test_i18ngrep ! "Pulling without specifying how to reconcile" err
36 test_expect_success
'pull.rebase not set and pull.ff=true' '
37 git reset --hard c0 &&
38 test_config pull.ff true &&
39 git pull . c1 2>err &&
40 test_i18ngrep ! "Pulling without specifying how to reconcile" err
43 test_expect_success
'pull.rebase not set and pull.ff=false' '
44 git reset --hard c0 &&
45 test_config pull.ff false &&
46 git pull . c1 2>err &&
47 test_i18ngrep ! "Pulling without specifying how to reconcile" err
50 test_expect_success
'pull.rebase not set and pull.ff=only' '
51 git reset --hard c0 &&
52 test_config pull.ff only &&
53 git pull . c1 2>err &&
54 test_i18ngrep ! "Pulling without specifying how to reconcile" err
57 test_expect_success
'pull.rebase not set and --rebase given' '
58 git reset --hard c0 &&
59 git pull --rebase . c1 2>err &&
60 test_i18ngrep ! "Pulling without specifying how to reconcile" err
63 test_expect_success
'pull.rebase not set and --no-rebase given' '
64 git reset --hard c0 &&
65 git pull --no-rebase . c1 2>err &&
66 test_i18ngrep ! "Pulling without specifying how to reconcile" err
69 test_expect_success
'pull.rebase not set and --ff given' '
70 git reset --hard c0 &&
71 git pull --ff . c1 2>err &&
72 test_i18ngrep ! "Pulling without specifying how to reconcile" err
75 test_expect_success
'pull.rebase not set and --no-ff given' '
76 git reset --hard c0 &&
77 git pull --no-ff . c1 2>err &&
78 test_i18ngrep ! "Pulling without specifying how to reconcile" err
81 test_expect_success
'pull.rebase not set and --ff-only given' '
82 git reset --hard c0 &&
83 git pull --ff-only . c1 2>err &&
84 test_i18ngrep ! "Pulling without specifying how to reconcile" err
87 test_expect_success
'pull.rebase not set (not-fast-forward)' '
88 git reset --hard c2 &&
89 git -c color.advice=always pull . c1 2>err &&
90 test_decode_color <err >decoded &&
91 test_i18ngrep "<YELLOW>hint: " decoded &&
92 test_i18ngrep "Pulling without specifying how to reconcile" decoded
95 test_expect_success
'pull.rebase not set and pull.ff=true (not-fast-forward)' '
96 git reset --hard c2 &&
97 test_config pull.ff true &&
98 git pull . c1 2>err &&
99 test_i18ngrep ! "Pulling without specifying how to reconcile" err
102 test_expect_success
'pull.rebase not set and pull.ff=false (not-fast-forward)' '
103 git reset --hard c2 &&
104 test_config pull.ff false &&
105 git pull . c1 2>err &&
106 test_i18ngrep ! "Pulling without specifying how to reconcile" err
109 test_expect_success
'pull.rebase not set and pull.ff=only (not-fast-forward)' '
110 git reset --hard c2 &&
111 test_config pull.ff only &&
112 test_must_fail git pull . c1 2>err &&
113 test_i18ngrep ! "Pulling without specifying how to reconcile" err
116 test_expect_success
'pull.rebase not set and --rebase given (not-fast-forward)' '
117 git reset --hard c2 &&
118 git pull --rebase . c1 2>err &&
119 test_i18ngrep ! "Pulling without specifying how to reconcile" err
122 test_expect_success
'pull.rebase not set and --no-rebase given (not-fast-forward)' '
123 git reset --hard c2 &&
124 git pull --no-rebase . c1 2>err &&
125 test_i18ngrep ! "Pulling without specifying how to reconcile" err
128 test_expect_success
'pull.rebase not set and --ff given (not-fast-forward)' '
129 git reset --hard c2 &&
130 git pull --ff . c1 2>err &&
131 test_i18ngrep ! "Pulling without specifying how to reconcile" err
134 test_expect_success
'pull.rebase not set and --no-ff given (not-fast-forward)' '
135 git reset --hard c2 &&
136 git pull --no-ff . c1 2>err &&
137 test_i18ngrep ! "Pulling without specifying how to reconcile" err
140 test_expect_success
'pull.rebase not set and --ff-only given (not-fast-forward)' '
141 git reset --hard c2 &&
142 test_must_fail git pull --ff-only . c1 2>err &&
143 test_i18ngrep ! "Pulling without specifying how to reconcile" err
146 test_expect_success
'merge c1 with c2' '
147 git reset --hard c1 &&
157 test_expect_success
'fast-forward pull succeeds with "true" in pull.ff' '
158 git reset --hard c0 &&
159 test_config pull.ff true &&
161 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
164 test_expect_success
'pull.ff=true overrides merge.ff=false' '
165 git reset --hard c0 &&
166 test_config merge.ff false &&
167 test_config pull.ff true &&
169 test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
172 test_expect_success
'fast-forward pull creates merge with "false" in pull.ff' '
173 git reset --hard c0 &&
174 test_config pull.ff false &&
176 test "$(git rev-parse HEAD^1)" = "$(git rev-parse c0)" &&
177 test "$(git rev-parse HEAD^2)" = "$(git rev-parse c1)"
180 test_expect_success
'pull prevents non-fast-forward with "only" in pull.ff' '
181 git reset --hard c1 &&
182 test_config pull.ff only &&
183 test_must_fail git pull . c3
186 test_expect_success
'merge c1 with c2 (ours in pull.twohead)' '
187 git reset --hard c1 &&
188 git config pull.twohead ours &&
194 test_expect_success
'merge c1 with c2 and c3 (recursive in pull.octopus)' '
195 git reset --hard c1 &&
196 git config pull.octopus "recursive" &&
197 test_must_fail git merge c2 c3 &&
198 test "$(git rev-parse c1)" = "$(git rev-parse HEAD)"
201 test_expect_success
'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' '
202 git reset --hard c1 &&
203 git config pull.octopus "recursive octopus" &&
205 test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
206 test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
207 test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
208 test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
209 git diff --exit-code &&
219 git diff-files
--name-only
220 git ls-files
--unmerged
227 # There are two conflicts here:
229 # 1) Because foo.c is renamed to bar.c, recursive will handle this,
232 # 2) One in conflict.c and that will always fail.
234 test_expect_success
'setup conflicted merge' '
235 git reset --hard c0 &&
236 echo A >conflict.c &&
237 git add conflict.c &&
238 echo contents >foo.c &&
242 echo B >conflict.c &&
243 git add conflict.c &&
244 git mv foo.c bar.c &&
247 git reset --hard c4 &&
248 echo C >conflict.c &&
249 git add conflict.c &&
250 echo secondline >> foo.c &&
256 # First do the merge with resolve and recursive then verify that
257 # recursive is chosen.
259 test_expect_success
'merge picks up the best result' '
260 git config --unset-all pull.twohead &&
261 git reset --hard c5 &&
262 test_must_fail git merge -s resolve c6 &&
263 resolve_count=$(conflict_count) &&
264 git reset --hard c5 &&
265 test_must_fail git merge -s recursive c6 &&
266 recursive_count=$(conflict_count) &&
267 git reset --hard c5 &&
268 test_must_fail git merge -s recursive -s resolve c6 &&
269 auto_count=$(conflict_count) &&
270 test $auto_count = $recursive_count &&
271 test $auto_count != $resolve_count
274 test_expect_success
'merge picks up the best result (from config)' '
275 git config pull.twohead "recursive resolve" &&
276 git reset --hard c5 &&
277 test_must_fail git merge -s resolve c6 &&
278 resolve_count=$(conflict_count) &&
279 git reset --hard c5 &&
280 test_must_fail git merge -s recursive c6 &&
281 recursive_count=$(conflict_count) &&
282 git reset --hard c5 &&
283 test_must_fail git merge c6 &&
284 auto_count=$(conflict_count) &&
285 test $auto_count = $recursive_count &&
286 test $auto_count != $resolve_count
289 test_expect_success
'merge errors out on invalid strategy' '
290 git config pull.twohead "foobar" &&
291 git reset --hard c5 &&
292 test_must_fail git merge c6
295 test_expect_success
'merge errors out on invalid strategy' '
296 git config --unset-all pull.twohead &&
297 git reset --hard c5 &&
298 test_must_fail git merge -s "resolve recursive" c6