]>
Commit | Line | Data |
---|---|---|
a85d1b69 LH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Lars Hjemli | |
4 | # | |
5 | ||
47a528ad | 6 | test_description='git merge |
a85d1b69 | 7 | |
4c073457 JN |
8 | Testing basic merge operations/option parsing. |
9 | ||
10 | ! [c0] commit 0 | |
11 | ! [c1] commit 1 | |
12 | ! [c2] commit 2 | |
13 | ! [c3] commit 3 | |
14 | ! [c4] c4 | |
15 | ! [c5] c5 | |
16 | ! [c6] c6 | |
17 | * [master] Merge commit 'c1' | |
18 | -------- | |
19 | - [master] Merge commit 'c1' | |
20 | + * [c1] commit 1 | |
21 | + [c6] c6 | |
22 | + [c5] c5 | |
23 | ++ [c4] c4 | |
24 | ++++ [c3] commit 3 | |
25 | + [c2] commit 2 | |
26 | +++++++* [c0] commit 0 | |
27 | ' | |
a85d1b69 LH |
28 | |
29 | . ./test-lib.sh | |
30 | ||
73151df0 JN |
31 | printf '%s\n' 1 2 3 4 5 6 7 8 9 >file |
32 | printf '%s\n' '1 X' 2 3 4 5 6 7 8 9 >file.1 | |
33 | printf '%s\n' 1 2 3 4 '5 X' 6 7 8 9 >file.5 | |
34 | printf '%s\n' 1 2 3 4 5 6 7 8 '9 X' >file.9 | |
35 | printf '%s\n' '1 X' 2 3 4 5 6 7 8 9 >result.1 | |
36 | printf '%s\n' '1 X' 2 3 4 '5 X' 6 7 8 9 >result.1-5 | |
37 | printf '%s\n' '1 X' 2 3 4 '5 X' 6 7 8 '9 X' >result.1-5-9 | |
36a45b4f | 38 | >empty |
4c073457 | 39 | |
73151df0 | 40 | create_merge_msgs () { |
57b58db7 JH |
41 | echo "Merge tag 'c2'" >msg.1-5 && |
42 | echo "Merge tags 'c2' and 'c3'" >msg.1-5-9 && | |
73151df0 JN |
43 | { |
44 | echo "Squashed commit of the following:" && | |
45 | echo && | |
46 | git log --no-merges ^HEAD c1 | |
47 | } >squash.1 && | |
48 | { | |
49 | echo "Squashed commit of the following:" && | |
50 | echo && | |
51 | git log --no-merges ^HEAD c2 | |
52 | } >squash.1-5 && | |
53 | { | |
54 | echo "Squashed commit of the following:" && | |
55 | echo && | |
56 | git log --no-merges ^HEAD c2 c3 | |
57 | } >squash.1-5-9 && | |
58 | echo >msg.nolog && | |
59 | { | |
57b58db7 | 60 | echo "* tag 'c3':" && |
73151df0 JN |
61 | echo " commit 3" && |
62 | echo | |
63 | } >msg.log | |
64 | } | |
4c073457 | 65 | |
73151df0 JN |
66 | verify_merge () { |
67 | test_cmp "$2" "$1" && | |
68 | git update-index --refresh && | |
69 | git diff --exit-code && | |
70 | if test -n "$3" | |
71 | then | |
72 | git show -s --pretty=format:%s HEAD >msg.act && | |
73 | test_cmp "$3" msg.act | |
74 | fi | |
75 | } | |
4c073457 | 76 | |
73151df0 JN |
77 | verify_head () { |
78 | echo "$1" >head.expected && | |
79 | git rev-parse HEAD >head.actual && | |
80 | test_cmp head.expected head.actual | |
81 | } | |
4c073457 | 82 | |
73151df0 JN |
83 | verify_parents () { |
84 | printf '%s\n' "$@" >parents.expected && | |
85 | >parents.actual && | |
86 | i=1 && | |
87 | while test $i -le $# | |
88 | do | |
89 | git rev-parse HEAD^$i >>parents.actual && | |
90 | i=$(expr $i + 1) || | |
91 | return 1 | |
92 | done && | |
3fc0dbf0 | 93 | test_must_fail git rev-parse --verify "HEAD^$i" && |
73151df0 JN |
94 | test_cmp parents.expected parents.actual |
95 | } | |
a85d1b69 | 96 | |
73151df0 JN |
97 | verify_mergeheads () { |
98 | printf '%s\n' "$@" >mergehead.expected && | |
99 | test_cmp mergehead.expected .git/MERGE_HEAD | |
100 | } | |
a85d1b69 | 101 | |
73151df0 JN |
102 | verify_no_mergehead () { |
103 | ! test -e .git/MERGE_HEAD | |
104 | } | |
a85d1b69 LH |
105 | |
106 | test_expect_success 'setup' ' | |
107 | git add file && | |
108 | test_tick && | |
109 | git commit -m "commit 0" && | |
110 | git tag c0 && | |
111 | c0=$(git rev-parse HEAD) && | |
112 | cp file.1 file && | |
113 | git add file && | |
114 | test_tick && | |
115 | git commit -m "commit 1" && | |
116 | git tag c1 && | |
117 | c1=$(git rev-parse HEAD) && | |
118 | git reset --hard "$c0" && | |
119 | cp file.5 file && | |
120 | git add file && | |
121 | test_tick && | |
122 | git commit -m "commit 2" && | |
123 | git tag c2 && | |
124 | c2=$(git rev-parse HEAD) && | |
125 | git reset --hard "$c0" && | |
126 | cp file.9 file && | |
127 | git add file && | |
128 | test_tick && | |
129 | git commit -m "commit 3" && | |
130 | git tag c3 && | |
131 | c3=$(git rev-parse HEAD) | |
132 | git reset --hard "$c0" && | |
133 | create_merge_msgs | |
134 | ' | |
135 | ||
df516fb5 | 136 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 | 137 | |
74f5b7fb | 138 | test_expect_success 'test option parsing' ' |
01941bd5 JS |
139 | test_must_fail git merge -$ c1 && |
140 | test_must_fail git merge --no-such c1 && | |
141 | test_must_fail git merge -s foobar c1 && | |
142 | test_must_fail git merge -s=foobar c1 && | |
143 | test_must_fail git merge -m && | |
144 | test_must_fail git merge | |
a85d1b69 LH |
145 | ' |
146 | ||
da53eec6 NTND |
147 | test_expect_success 'merge -h with invalid index' ' |
148 | mkdir broken && | |
149 | ( | |
150 | cd broken && | |
151 | git init && | |
152 | >.git/index && | |
153 | test_expect_code 129 git merge -h 2>usage | |
154 | ) && | |
155 | grep "[Uu]sage: git merge" broken/usage | |
156 | ' | |
157 | ||
dce61e72 MV |
158 | test_expect_success 'reject non-strategy with a git-merge-foo name' ' |
159 | test_must_fail git merge -s index c1 | |
160 | ' | |
161 | ||
a85d1b69 | 162 | test_expect_success 'merge c0 with c1' ' |
ff372c78 JN |
163 | echo "OBJID HEAD@{0}: merge c1: Fast-forward" >reflog.expected && |
164 | ||
a85d1b69 LH |
165 | git reset --hard c0 && |
166 | git merge c1 && | |
167 | verify_merge file result.1 && | |
ff372c78 JN |
168 | verify_head "$c1" && |
169 | ||
170 | git reflog -1 >reflog.actual && | |
171 | sed "s/$_x05[0-9a-f]*/OBJID/g" reflog.actual >reflog.fuzzy && | |
172 | test_cmp reflog.expected reflog.fuzzy | |
a85d1b69 LH |
173 | ' |
174 | ||
df516fb5 | 175 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 | 176 | |
13474835 BG |
177 | test_expect_success 'merge c0 with c1 with --ff-only' ' |
178 | git reset --hard c0 && | |
179 | git merge --ff-only c1 && | |
180 | git merge --ff-only HEAD c0 c1 && | |
181 | verify_merge file result.1 && | |
182 | verify_head "$c1" | |
183 | ' | |
184 | ||
df516fb5 | 185 | test_debug 'git log --graph --decorate --oneline --all' |
94d63ce2 JN |
186 | |
187 | test_expect_success 'merge from unborn branch' ' | |
188 | git checkout -f master && | |
189 | test_might_fail git branch -D kid && | |
190 | ||
191 | echo "OBJID HEAD@{0}: initial pull" >reflog.expected && | |
192 | ||
193 | git checkout --orphan kid && | |
194 | test_when_finished "git checkout -f master" && | |
195 | git rm -fr . && | |
196 | test_tick && | |
197 | git merge --ff-only c1 && | |
198 | verify_merge file result.1 && | |
199 | verify_head "$c1" && | |
200 | ||
201 | git reflog -1 >reflog.actual && | |
202 | sed "s/$_x05[0-9a-f][0-9a-f]/OBJID/g" reflog.actual >reflog.fuzzy && | |
203 | test_cmp reflog.expected reflog.fuzzy | |
204 | ' | |
205 | ||
206 | test_debug 'git log --graph --decorate --oneline --all' | |
13474835 | 207 | |
a85d1b69 LH |
208 | test_expect_success 'merge c1 with c2' ' |
209 | git reset --hard c1 && | |
210 | test_tick && | |
211 | git merge c2 && | |
212 | verify_merge file result.1-5 msg.1-5 && | |
213 | verify_parents $c1 $c2 | |
214 | ' | |
215 | ||
df516fb5 | 216 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 LH |
217 | |
218 | test_expect_success 'merge c1 with c2 and c3' ' | |
219 | git reset --hard c1 && | |
220 | test_tick && | |
221 | git merge c2 c3 && | |
222 | verify_merge file result.1-5-9 msg.1-5-9 && | |
223 | verify_parents $c1 $c2 $c3 | |
224 | ' | |
225 | ||
df516fb5 | 226 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 | 227 | |
f23e8dec | 228 | test_expect_success 'merges with --ff-only' ' |
13474835 BG |
229 | git reset --hard c1 && |
230 | test_tick && | |
231 | test_must_fail git merge --ff-only c2 && | |
232 | test_must_fail git merge --ff-only c3 && | |
f23e8dec JH |
233 | test_must_fail git merge --ff-only c2 c3 && |
234 | git reset --hard c0 && | |
235 | git merge c3 && | |
236 | verify_head $c3 | |
237 | ' | |
238 | ||
239 | test_expect_success 'merges with merge.ff=only' ' | |
240 | git reset --hard c1 && | |
241 | test_tick && | |
242 | test_when_finished "git config --unset merge.ff" && | |
243 | git config merge.ff only && | |
244 | test_must_fail git merge c2 && | |
245 | test_must_fail git merge c3 && | |
246 | test_must_fail git merge c2 c3 && | |
247 | git reset --hard c0 && | |
248 | git merge c3 && | |
249 | verify_head $c3 | |
13474835 BG |
250 | ' |
251 | ||
a85d1b69 LH |
252 | test_expect_success 'merge c0 with c1 (no-commit)' ' |
253 | git reset --hard c0 && | |
254 | git merge --no-commit c1 && | |
255 | verify_merge file result.1 && | |
256 | verify_head $c1 | |
257 | ' | |
258 | ||
df516fb5 | 259 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 LH |
260 | |
261 | test_expect_success 'merge c1 with c2 (no-commit)' ' | |
262 | git reset --hard c1 && | |
263 | git merge --no-commit c2 && | |
264 | verify_merge file result.1-5 && | |
265 | verify_head $c1 && | |
266 | verify_mergeheads $c2 | |
267 | ' | |
268 | ||
df516fb5 | 269 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 LH |
270 | |
271 | test_expect_success 'merge c1 with c2 and c3 (no-commit)' ' | |
272 | git reset --hard c1 && | |
273 | git merge --no-commit c2 c3 && | |
274 | verify_merge file result.1-5-9 && | |
275 | verify_head $c1 && | |
276 | verify_mergeheads $c2 $c3 | |
277 | ' | |
278 | ||
df516fb5 | 279 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 LH |
280 | |
281 | test_expect_success 'merge c0 with c1 (squash)' ' | |
282 | git reset --hard c0 && | |
283 | git merge --squash c1 && | |
284 | verify_merge file result.1 && | |
285 | verify_head $c0 && | |
286 | verify_no_mergehead && | |
4c073457 | 287 | test_cmp squash.1 .git/SQUASH_MSG |
a85d1b69 LH |
288 | ' |
289 | ||
df516fb5 | 290 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 | 291 | |
13474835 BG |
292 | test_expect_success 'merge c0 with c1 (squash, ff-only)' ' |
293 | git reset --hard c0 && | |
294 | git merge --squash --ff-only c1 && | |
295 | verify_merge file result.1 && | |
296 | verify_head $c0 && | |
297 | verify_no_mergehead && | |
4c073457 | 298 | test_cmp squash.1 .git/SQUASH_MSG |
13474835 BG |
299 | ' |
300 | ||
df516fb5 | 301 | test_debug 'git log --graph --decorate --oneline --all' |
13474835 | 302 | |
a85d1b69 LH |
303 | test_expect_success 'merge c1 with c2 (squash)' ' |
304 | git reset --hard c1 && | |
305 | git merge --squash c2 && | |
306 | verify_merge file result.1-5 && | |
307 | verify_head $c1 && | |
308 | verify_no_mergehead && | |
4c073457 | 309 | test_cmp squash.1-5 .git/SQUASH_MSG |
a85d1b69 LH |
310 | ' |
311 | ||
df516fb5 | 312 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 | 313 | |
13474835 BG |
314 | test_expect_success 'unsuccesful merge of c1 with c2 (squash, ff-only)' ' |
315 | git reset --hard c1 && | |
316 | test_must_fail git merge --squash --ff-only c2 | |
317 | ' | |
318 | ||
df516fb5 | 319 | test_debug 'git log --graph --decorate --oneline --all' |
13474835 | 320 | |
a85d1b69 LH |
321 | test_expect_success 'merge c1 with c2 and c3 (squash)' ' |
322 | git reset --hard c1 && | |
323 | git merge --squash c2 c3 && | |
324 | verify_merge file result.1-5-9 && | |
325 | verify_head $c1 && | |
326 | verify_no_mergehead && | |
4c073457 | 327 | test_cmp squash.1-5-9 .git/SQUASH_MSG |
a85d1b69 LH |
328 | ' |
329 | ||
df516fb5 | 330 | test_debug 'git log --graph --decorate --oneline --all' |
a85d1b69 | 331 | |
aec7b362 LH |
332 | test_expect_success 'merge c1 with c2 (no-commit in config)' ' |
333 | git reset --hard c1 && | |
334 | git config branch.master.mergeoptions "--no-commit" && | |
335 | git merge c2 && | |
336 | verify_merge file result.1-5 && | |
337 | verify_head $c1 && | |
338 | verify_mergeheads $c2 | |
339 | ' | |
340 | ||
df516fb5 | 341 | test_debug 'git log --graph --decorate --oneline --all' |
aec7b362 | 342 | |
0d8fc3ef JH |
343 | test_expect_success 'merge c1 with c2 (log in config)' ' |
344 | git config branch.master.mergeoptions "" && | |
345 | git reset --hard c1 && | |
346 | git merge --log c2 && | |
347 | git show -s --pretty=tformat:%s%n%b >expect && | |
348 | ||
349 | git config branch.master.mergeoptions --log && | |
350 | git reset --hard c1 && | |
351 | git merge c2 && | |
352 | git show -s --pretty=tformat:%s%n%b >actual && | |
353 | ||
354 | test_cmp expect actual | |
355 | ' | |
356 | ||
357 | test_expect_success 'merge c1 with c2 (log in config gets overridden)' ' | |
541d1fa8 JH |
358 | test_when_finished "git config --remove-section branch.master" && |
359 | test_when_finished "git config --remove-section merge" && | |
360 | test_might_fail git config --remove-section branch.master && | |
361 | test_might_fail git config --remove-section merge && | |
362 | ||
0d8fc3ef JH |
363 | git reset --hard c1 && |
364 | git merge c2 && | |
365 | git show -s --pretty=tformat:%s%n%b >expect && | |
366 | ||
367 | git config branch.master.mergeoptions "--no-log" && | |
368 | git config merge.log true && | |
369 | git reset --hard c1 && | |
370 | git merge c2 && | |
371 | git show -s --pretty=tformat:%s%n%b >actual && | |
372 | ||
373 | test_cmp expect actual | |
374 | ' | |
375 | ||
aec7b362 LH |
376 | test_expect_success 'merge c1 with c2 (squash in config)' ' |
377 | git reset --hard c1 && | |
378 | git config branch.master.mergeoptions "--squash" && | |
379 | git merge c2 && | |
380 | verify_merge file result.1-5 && | |
381 | verify_head $c1 && | |
382 | verify_no_mergehead && | |
4c073457 | 383 | test_cmp squash.1-5 .git/SQUASH_MSG |
aec7b362 LH |
384 | ' |
385 | ||
df516fb5 | 386 | test_debug 'git log --graph --decorate --oneline --all' |
aec7b362 | 387 | |
d8abe148 | 388 | test_expect_success 'override config option -n with --summary' ' |
aec7b362 LH |
389 | git reset --hard c1 && |
390 | git config branch.master.mergeoptions "-n" && | |
391 | test_tick && | |
392 | git merge --summary c2 >diffstat.txt && | |
393 | verify_merge file result.1-5 msg.1-5 && | |
394 | verify_parents $c1 $c2 && | |
aadbe44f | 395 | if ! grep "^ file | *2 +-$" diffstat.txt |
aec7b362 | 396 | then |
d8abe148 SG |
397 | echo "[OOPS] diffstat was not generated with --summary" |
398 | false | |
399 | fi | |
400 | ' | |
401 | ||
402 | test_expect_success 'override config option -n with --stat' ' | |
403 | git reset --hard c1 && | |
404 | git config branch.master.mergeoptions "-n" && | |
405 | test_tick && | |
406 | git merge --stat c2 >diffstat.txt && | |
407 | verify_merge file result.1-5 msg.1-5 && | |
408 | verify_parents $c1 $c2 && | |
409 | if ! grep "^ file | *2 +-$" diffstat.txt | |
410 | then | |
411 | echo "[OOPS] diffstat was not generated with --stat" | |
412 | false | |
aec7b362 LH |
413 | fi |
414 | ' | |
415 | ||
df516fb5 | 416 | test_debug 'git log --graph --decorate --oneline --all' |
aec7b362 | 417 | |
d8abe148 | 418 | test_expect_success 'override config option --stat' ' |
aec7b362 | 419 | git reset --hard c1 && |
d8abe148 | 420 | git config branch.master.mergeoptions "--stat" && |
aec7b362 LH |
421 | test_tick && |
422 | git merge -n c2 >diffstat.txt && | |
423 | verify_merge file result.1-5 msg.1-5 && | |
424 | verify_parents $c1 $c2 && | |
aadbe44f | 425 | if grep "^ file | *2 +-$" diffstat.txt |
aec7b362 LH |
426 | then |
427 | echo "[OOPS] diffstat was generated" | |
428 | false | |
429 | fi | |
430 | ' | |
431 | ||
df516fb5 | 432 | test_debug 'git log --graph --decorate --oneline --all' |
aec7b362 | 433 | |
d08af0ad LH |
434 | test_expect_success 'merge c1 with c2 (override --no-commit)' ' |
435 | git reset --hard c1 && | |
436 | git config branch.master.mergeoptions "--no-commit" && | |
437 | test_tick && | |
438 | git merge --commit c2 && | |
439 | verify_merge file result.1-5 msg.1-5 && | |
440 | verify_parents $c1 $c2 | |
441 | ' | |
442 | ||
df516fb5 | 443 | test_debug 'git log --graph --decorate --oneline --all' |
d08af0ad LH |
444 | |
445 | test_expect_success 'merge c1 with c2 (override --squash)' ' | |
446 | git reset --hard c1 && | |
447 | git config branch.master.mergeoptions "--squash" && | |
448 | test_tick && | |
449 | git merge --no-squash c2 && | |
450 | verify_merge file result.1-5 msg.1-5 && | |
451 | verify_parents $c1 $c2 | |
452 | ' | |
453 | ||
df516fb5 | 454 | test_debug 'git log --graph --decorate --oneline --all' |
d08af0ad | 455 | |
d66424c4 LH |
456 | test_expect_success 'merge c0 with c1 (no-ff)' ' |
457 | git reset --hard c0 && | |
e6d1f76c | 458 | git config branch.master.mergeoptions "" && |
d66424c4 LH |
459 | test_tick && |
460 | git merge --no-ff c1 && | |
461 | verify_merge file result.1 && | |
462 | verify_parents $c0 $c1 | |
463 | ' | |
464 | ||
df516fb5 | 465 | test_debug 'git log --graph --decorate --oneline --all' |
d66424c4 | 466 | |
f23e8dec JH |
467 | test_expect_success 'merge c0 with c1 (merge.ff=false)' ' |
468 | git reset --hard c0 && | |
469 | git config merge.ff false && | |
470 | test_tick && | |
471 | git merge c1 && | |
472 | git config --remove-section merge && | |
473 | verify_merge file result.1 && | |
474 | verify_parents $c0 $c1 | |
475 | ' | |
476 | test_debug 'git log --graph --decorate --oneline --all' | |
477 | ||
478 | test_expect_success 'combine branch.master.mergeoptions with merge.ff' ' | |
479 | git reset --hard c0 && | |
8c5cea00 JN |
480 | git config branch.master.mergeoptions --ff && |
481 | git config merge.ff false && | |
f23e8dec JH |
482 | test_tick && |
483 | git merge c1 && | |
484 | git config --remove-section "branch.master" && | |
485 | git config --remove-section "merge" && | |
486 | verify_merge file result.1 && | |
487 | verify_parents "$c0" | |
488 | ' | |
489 | ||
8c5cea00 JN |
490 | test_expect_success 'tolerate unknown values for merge.ff' ' |
491 | git reset --hard c0 && | |
492 | git config merge.ff something-new && | |
493 | test_tick && | |
494 | git merge c1 2>message && | |
495 | git config --remove-section "merge" && | |
496 | verify_head "$c1" && | |
497 | test_cmp empty message | |
498 | ' | |
499 | ||
e6d1f76c | 500 | test_expect_success 'combining --squash and --no-ff is refused' ' |
8c5cea00 | 501 | git reset --hard c0 && |
e6d1f76c GP |
502 | test_must_fail git merge --squash --no-ff c1 && |
503 | test_must_fail git merge --no-ff --squash c1 | |
504 | ' | |
505 | ||
13474835 BG |
506 | test_expect_success 'combining --ff-only and --no-ff is refused' ' |
507 | test_must_fail git merge --ff-only --no-ff c1 && | |
508 | test_must_fail git merge --no-ff --ff-only c1 | |
509 | ' | |
510 | ||
d66424c4 LH |
511 | test_expect_success 'merge c0 with c1 (ff overrides no-ff)' ' |
512 | git reset --hard c0 && | |
513 | git config branch.master.mergeoptions "--no-ff" && | |
514 | git merge --ff c1 && | |
515 | verify_merge file result.1 && | |
516 | verify_head $c1 | |
517 | ' | |
518 | ||
efb779f8 SG |
519 | test_expect_success 'merge log message' ' |
520 | git reset --hard c0 && | |
521 | git merge --no-log c2 && | |
522 | git show -s --pretty=format:%b HEAD >msg.act && | |
4c073457 | 523 | test_cmp msg.nolog msg.act && |
4393c237 | 524 | |
efb779f8 SG |
525 | git merge --log c3 && |
526 | git show -s --pretty=format:%b HEAD >msg.act && | |
4c073457 | 527 | test_cmp msg.log msg.act && |
4393c237 JH |
528 | |
529 | git reset --hard HEAD^ && | |
530 | git config merge.log yes && | |
531 | git merge c3 && | |
532 | git show -s --pretty=format:%b HEAD >msg.act && | |
4c073457 | 533 | test_cmp msg.log msg.act |
efb779f8 SG |
534 | ' |
535 | ||
df516fb5 | 536 | test_debug 'git log --graph --decorate --oneline --all' |
d66424c4 | 537 | |
3d1dd472 SHJ |
538 | test_expect_success 'merge c1 with c0, c2, c0, and c1' ' |
539 | git reset --hard c1 && | |
540 | git config branch.master.mergeoptions "" && | |
541 | test_tick && | |
542 | git merge c0 c2 c0 c1 && | |
543 | verify_merge file result.1-5 && | |
544 | verify_parents $c1 $c2 | |
545 | ' | |
546 | ||
df516fb5 | 547 | test_debug 'git log --graph --decorate --oneline --all' |
3d1dd472 | 548 | |
711f6b29 JH |
549 | test_expect_success 'merge c1 with c0, c2, c0, and c1' ' |
550 | git reset --hard c1 && | |
551 | git config branch.master.mergeoptions "" && | |
552 | test_tick && | |
553 | git merge c0 c2 c0 c1 && | |
554 | verify_merge file result.1-5 && | |
555 | verify_parents $c1 $c2 | |
556 | ' | |
557 | ||
df516fb5 | 558 | test_debug 'git log --graph --decorate --oneline --all' |
711f6b29 JH |
559 | |
560 | test_expect_success 'merge c1 with c1 and c2' ' | |
561 | git reset --hard c1 && | |
562 | git config branch.master.mergeoptions "" && | |
563 | test_tick && | |
564 | git merge c1 c2 && | |
565 | verify_merge file result.1-5 && | |
566 | verify_parents $c1 $c2 | |
567 | ' | |
568 | ||
df516fb5 | 569 | test_debug 'git log --graph --decorate --oneline --all' |
711f6b29 | 570 | |
9ca8f607 JH |
571 | test_expect_success 'merge fast-forward in a dirty tree' ' |
572 | git reset --hard c0 && | |
573 | mv file file1 && | |
574 | cat file1 >file && | |
575 | rm -f file1 && | |
576 | git merge c2 | |
577 | ' | |
578 | ||
df516fb5 | 579 | test_debug 'git log --graph --decorate --oneline --all' |
9ca8f607 | 580 | |
c9ea118e | 581 | test_expect_success 'in-index merge' ' |
446247db | 582 | git reset --hard c0 && |
4c073457 | 583 | git merge --no-ff -s resolve c1 >out && |
c9ea118e | 584 | test_i18ngrep "Wonderful." out && |
446247db JH |
585 | verify_parents $c0 $c1 |
586 | ' | |
587 | ||
df516fb5 | 588 | test_debug 'git log --graph --decorate --oneline --all' |
446247db | 589 | |
668f26ff MV |
590 | test_expect_success 'refresh the index before merging' ' |
591 | git reset --hard c1 && | |
016e5ff2 | 592 | cp file file.n && mv -f file.n file && |
668f26ff MV |
593 | git merge c3 |
594 | ' | |
595 | ||
b81f925f JN |
596 | cat >expected.branch <<\EOF |
597 | Merge branch 'c5-branch' (early part) | |
598 | EOF | |
599 | cat >expected.tag <<\EOF | |
600 | Merge commit 'c5~1' | |
4e6d4bc0 MV |
601 | EOF |
602 | ||
603 | test_expect_success 'merge early part of c2' ' | |
604 | git reset --hard c3 && | |
4c073457 | 605 | echo c4 >c4.c && |
4e6d4bc0 MV |
606 | git add c4.c && |
607 | git commit -m c4 && | |
608 | git tag c4 && | |
4c073457 | 609 | echo c5 >c5.c && |
4e6d4bc0 MV |
610 | git add c5.c && |
611 | git commit -m c5 && | |
612 | git tag c5 && | |
613 | git reset --hard c3 && | |
4c073457 | 614 | echo c6 >c6.c && |
4e6d4bc0 MV |
615 | git add c6.c && |
616 | git commit -m c6 && | |
617 | git tag c6 && | |
b81f925f JN |
618 | git branch -f c5-branch c5 && |
619 | git merge c5-branch~1 && | |
620 | git show -s --pretty=format:%s HEAD >actual.branch && | |
621 | git reset --keep HEAD^ && | |
4e6d4bc0 | 622 | git merge c5~1 && |
b81f925f JN |
623 | git show -s --pretty=format:%s HEAD >actual.tag && |
624 | test_cmp expected.branch actual.branch && | |
625 | test_cmp expected.tag actual.tag | |
4e6d4bc0 MV |
626 | ' |
627 | ||
df516fb5 | 628 | test_debug 'git log --graph --decorate --oneline --all' |
668f26ff | 629 | |
cf10f9fd MV |
630 | test_expect_success 'merge --no-ff --no-commit && commit' ' |
631 | git reset --hard c0 && | |
632 | git merge --no-ff --no-commit c1 && | |
633 | EDITOR=: git commit && | |
634 | verify_parents $c0 $c1 | |
635 | ' | |
636 | ||
df516fb5 | 637 | test_debug 'git log --graph --decorate --oneline --all' |
cf10f9fd MV |
638 | |
639 | test_expect_success 'amending no-ff merge commit' ' | |
640 | EDITOR=: git commit --amend && | |
641 | verify_parents $c0 $c1 | |
642 | ' | |
643 | ||
df516fb5 | 644 | test_debug 'git log --graph --decorate --oneline --all' |
cf10f9fd | 645 | |
66f4b98a JS |
646 | cat >editor <<\EOF |
647 | #!/bin/sh | |
648 | # Add a new message string that was not in the template | |
649 | ( | |
650 | echo "Merge work done on the side branch c1" | |
651 | echo | |
652 | cat <"$1" | |
653 | ) >"$1.tmp" && mv "$1.tmp" "$1" | |
654 | # strip comments and blank lines from end of message | |
655 | sed -e '/^#/d' < "$1" | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' > expected | |
656 | EOF | |
657 | chmod 755 editor | |
658 | ||
659 | test_expect_success 'merge --no-ff --edit' ' | |
660 | git reset --hard c0 && | |
661 | EDITOR=./editor git merge --no-ff --edit c1 && | |
662 | verify_parents $c0 $c1 && | |
663 | git cat-file commit HEAD >raw && | |
664 | grep "work done on the side branch" raw && | |
665 | sed "1,/^$/d" >actual raw && | |
666 | test_cmp actual expected | |
667 | ' | |
668 | ||
a85d1b69 | 669 | test_done |