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