]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6200-fmt-merge-msg.sh
The third batch
[thirdparty/git.git] / t / t6200-fmt-merge-msg.sh
CommitLineData
30a95f30
JH
1#!/bin/sh
2#
3# Copyright (c) 2006, Junio C Hamano
4#
5
6test_description='fmt-merge-msg test'
7
1550bb6e 8GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
9export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
30a95f30 11. ./test-lib.sh
f1e3df31 12. "$TEST_DIRECTORY/lib-gpg.sh"
30a95f30 13
30a95f30
JH
14test_expect_success setup '
15 echo one >one &&
16 git add one &&
6183a6ad 17 test_tick &&
30a95f30
JH
18 git commit -m "Initial" &&
19
419fe5bc
SB
20 git clone . remote &&
21
30a95f30
JH
22 echo uno >one &&
23 echo dos >two &&
24 git add two &&
6183a6ad 25 test_tick &&
30a95f30
JH
26 git commit -a -m "Second" &&
27
28 git checkout -b left &&
29
6183a6ad
SB
30 echo "c1" >one &&
31 test_tick &&
30a95f30
JH
32 git commit -a -m "Common #1" &&
33
6183a6ad
SB
34 echo "c2" >one &&
35 test_tick &&
30a95f30
JH
36 git commit -a -m "Common #2" &&
37
38 git branch right &&
39
6183a6ad
SB
40 echo "l3" >two &&
41 test_tick &&
418a1435
JH
42 GIT_COMMITTER_NAME="Another Committer" \
43 GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #3" &&
30a95f30 44
6183a6ad
SB
45 echo "l4" >two &&
46 test_tick &&
418a1435
JH
47 GIT_COMMITTER_NAME="Another Committer" \
48 GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #4" &&
30a95f30 49
6183a6ad
SB
50 echo "l5" >two &&
51 test_tick &&
418a1435
JH
52 GIT_COMMITTER_NAME="Another Committer" \
53 GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #5" &&
6183a6ad 54 git tag tag-l5 &&
30a95f30
JH
55
56 git checkout right &&
57
6183a6ad 58 echo "r3" >three &&
30a95f30 59 git add three &&
6183a6ad 60 test_tick &&
30a95f30 61 git commit -a -m "Right #3" &&
6183a6ad 62 git tag tag-r3 &&
30a95f30 63
6183a6ad
SB
64 echo "r4" >three &&
65 test_tick &&
30a95f30
JH
66 git commit -a -m "Right #4" &&
67
6183a6ad
SB
68 echo "r5" >three &&
69 test_tick &&
30a95f30
JH
70 git commit -a -m "Right #5" &&
71
6d6f6e68 72 git checkout -b long &&
70b39fbe 73 test_commit_bulk --start=0 --message=%s --filename=one 30 &&
6d6f6e68 74
d834c96a 75 git show-branch &&
30a95f30 76
d834c96a
JN
77 apos="'\''"
78'
30a95f30 79
f1e3df31
HJI
80test_expect_success GPG 'set up a signed tag' '
81 git tag -s -m signed-tag-msg signed-good-tag left
82'
83
9d12546d
FS
84test_expect_success GPGSSH 'created ssh signed commit and tag' '
85 test_config gpg.format ssh &&
86 git checkout -b signed-ssh &&
87 touch file &&
88 git add file &&
89 git commit -m "ssh signed" -S"${GPGSSH_KEY_PRIMARY}" &&
90 git tag -s -u"${GPGSSH_KEY_PRIMARY}" -m signed-ssh-tag-msg signed-good-ssh-tag left &&
91 git tag -s -u"${GPGSSH_KEY_UNTRUSTED}" -m signed-ssh-tag-msg-untrusted signed-untrusted-ssh-tag left
92'
93
122842fd
FS
94test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed tags with keys having defined lifetimes' '
95 test_when_finished "test_unconfig commit.gpgsign" &&
96 test_config gpg.format ssh &&
97 git checkout -b signed-expiry-ssh &&
98 touch file &&
99 git add file &&
100
101 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
102 git tag -s -u "${GPGSSH_KEY_EXPIRED}" -m expired-signed expired-signed &&
103
104 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
105 git tag -s -u "${GPGSSH_KEY_NOTYETVALID}" -m notyetvalid-signed notyetvalid-signed &&
106
107 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
108 git tag -s -u "${GPGSSH_KEY_TIMEBOXEDVALID}" -m timeboxedvalid-signed timeboxedvalid-signed &&
109
110 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
111 git tag -s -u "${GPGSSH_KEY_TIMEBOXEDINVALID}" -m timeboxedinvalid-signed timeboxedinvalid-signed
112'
113
d834c96a 114test_expect_success 'message for merging local branch' '
21531927 115 echo "Merge branch ${apos}left${apos}" >expected &&
30a95f30 116
1550bb6e 117 git checkout main &&
30a95f30
JH
118 git fetch . left &&
119
120 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 121 test_cmp expected actual
30a95f30
JH
122'
123
f1e3df31 124test_expect_success GPG 'message for merging local tag signed by good key' '
1550bb6e 125 git checkout main &&
f1e3df31 126 git fetch . signed-good-tag &&
5a2c1c0d 127 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
f1e3df31 128 grep "^Merge tag ${apos}signed-good-tag${apos}" actual &&
c39fc06b 129 grep "^signed-tag-msg" actual &&
f1e3df31
HJI
130 grep "^# gpg: Signature made" actual &&
131 grep "^# gpg: Good signature from" actual
132'
133
134test_expect_success GPG 'message for merging local tag signed by unknown key' '
1550bb6e 135 git checkout main &&
f1e3df31 136 git fetch . signed-good-tag &&
5a2c1c0d 137 GNUPGHOME=. git fmt-merge-msg <.git/FETCH_HEAD >actual &&
f1e3df31 138 grep "^Merge tag ${apos}signed-good-tag${apos}" actual &&
c39fc06b 139 grep "^signed-tag-msg" actual &&
f1e3df31 140 grep "^# gpg: Signature made" actual &&
46022ca3 141 grep -E "^# gpg: Can${apos}t check signature: (public key not found|No public key)" actual
f1e3df31
HJI
142'
143
9d12546d
FS
144test_expect_success GPGSSH 'message for merging local tag signed by good ssh key' '
145 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
146 git checkout main &&
147 git fetch . signed-good-ssh-tag &&
5a2c1c0d 148 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
cafd3452 149 grep "^Merge tag ${apos}signed-good-ssh-tag${apos}" actual &&
c39fc06b 150 grep "^signed-ssh-tag-msg" actual &&
9d12546d
FS
151 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
152 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
153'
154
155test_expect_success GPGSSH 'message for merging local tag signed by unknown ssh key' '
156 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
157 git checkout main &&
158 git fetch . signed-untrusted-ssh-tag &&
5a2c1c0d 159 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
cafd3452 160 grep "^Merge tag ${apos}signed-untrusted-ssh-tag${apos}" actual &&
c39fc06b 161 grep "^signed-ssh-tag-msg-untrusted" actual &&
9d12546d
FS
162 grep "${GPGSSH_GOOD_SIGNATURE_UNTRUSTED}" actual &&
163 ! grep "${GPGSSH_BAD_SIGNATURE}" actual &&
164 grep "${GPGSSH_KEY_NOT_TRUSTED}" actual
165'
122842fd
FS
166
167test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'message for merging local tag signed by expired ssh key' '
168 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
169 git checkout main &&
170 git fetch . expired-signed &&
171 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
172 grep "^Merge tag ${apos}expired-signed${apos}" actual &&
c39fc06b 173 grep "^expired-signed" actual &&
122842fd
FS
174 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
175'
176
177test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'message for merging local tag signed by not yet valid ssh key' '
178 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
179 git checkout main &&
180 git fetch . notyetvalid-signed &&
181 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
182 grep "^Merge tag ${apos}notyetvalid-signed${apos}" actual &&
c39fc06b 183 grep "^notyetvalid-signed" actual &&
122842fd
FS
184 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
185'
186
187test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'message for merging local tag signed by valid timeboxed ssh key' '
188 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
189 git checkout main &&
190 git fetch . timeboxedvalid-signed &&
191 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
192 grep "^Merge tag ${apos}timeboxedvalid-signed${apos}" actual &&
c39fc06b 193 grep "^timeboxedvalid-signed" actual &&
122842fd
FS
194 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
195 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
196'
197
198test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'message for merging local tag signed by invalid timeboxed ssh key' '
199 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
200 git checkout main &&
201 git fetch . timeboxedinvalid-signed &&
202 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
203 grep "^Merge tag ${apos}timeboxedinvalid-signed${apos}" actual &&
c39fc06b 204 grep "^timeboxedinvalid-signed" actual &&
122842fd
FS
205 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
206'
207
d834c96a 208test_expect_success 'message for merging external branch' '
21531927 209 echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
30a95f30 210
1550bb6e 211 git checkout main &&
4114156a 212 git fetch "$(pwd)" left &&
30a95f30
JH
213
214 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
3af82863 215 test_cmp expected actual
30a95f30
JH
216'
217
d834c96a
JN
218test_expect_success '[merge] summary/log configuration' '
219 cat >expected <<-EOF &&
21531927 220 Merge branch ${apos}left${apos}
30a95f30 221
9830a9ca
JH
222 # By Another Author (3) and A U Thor (2)
223 # Via Another Committer
d834c96a
JN
224 * left:
225 Left #5
226 Left #4
227 Left #3
228 Common #2
229 Common #1
230 EOF
30a95f30 231
9a94dba0
JH
232 test_config merge.log true &&
233 test_unconfig merge.summary &&
6cd9cfef 234
1550bb6e 235 git checkout main &&
6183a6ad 236 test_tick &&
6cd9cfef
SG
237 git fetch . left &&
238
d834c96a 239 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
6cd9cfef 240
9a94dba0
JH
241 test_unconfig merge.log &&
242 test_config merge.summary true &&
30a95f30 243
1550bb6e 244 git checkout main &&
6183a6ad 245 test_tick &&
30a95f30
JH
246 git fetch . left &&
247
d834c96a 248 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
30a95f30 249
d834c96a
JN
250 test_cmp expected actual1 &&
251 test_cmp expected actual2
252'
30a95f30 253
b928cbf1 254test_expect_success 'setup FETCH_HEAD' '
1550bb6e 255 git checkout main &&
b928cbf1
RR
256 test_tick &&
257 git fetch . left
258'
259
260test_expect_success 'merge.log=3 limits shortlog length' '
261 cat >expected <<-EOF &&
21531927 262 Merge branch ${apos}left${apos}
b928cbf1 263
9830a9ca
JH
264 # By Another Author (3) and A U Thor (2)
265 # Via Another Committer
b928cbf1
RR
266 * left: (5 commits)
267 Left #5
268 Left #4
269 Left #3
270 ...
271 EOF
272
273 git -c merge.log=3 fmt-merge-msg <.git/FETCH_HEAD >actual &&
274 test_cmp expected actual
275'
276
277test_expect_success 'merge.log=5 shows all 5 commits' '
278 cat >expected <<-EOF &&
21531927 279 Merge branch ${apos}left${apos}
b928cbf1 280
9830a9ca
JH
281 # By Another Author (3) and A U Thor (2)
282 # Via Another Committer
b928cbf1
RR
283 * left:
284 Left #5
285 Left #4
286 Left #3
287 Common #2
288 Common #1
289 EOF
290
291 git -c merge.log=5 fmt-merge-msg <.git/FETCH_HEAD >actual &&
292 test_cmp expected actual
293'
294
9927ebed
RT
295test_expect_success '--log=5 with custom comment character' '
296 cat >expected <<-EOF &&
21531927 297 Merge branch ${apos}left${apos}
9927ebed 298
16a794de
JS
299 x By Another Author (3) and A U Thor (2)
300 x Via Another Committer
9927ebed
RT
301 * left:
302 Left #5
303 Left #4
304 Left #3
305 Common #2
306 Common #1
307 EOF
308
16a794de 309 git -c core.commentchar="x" fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
9927ebed
RT
310 test_cmp expected actual
311'
312
b928cbf1 313test_expect_success 'merge.log=0 disables shortlog' '
21531927 314 echo "Merge branch ${apos}left${apos}" >expected &&
b928cbf1
RR
315 git -c merge.log=0 fmt-merge-msg <.git/FETCH_HEAD >actual &&
316 test_cmp expected actual
317'
318
bd2549ca
RR
319test_expect_success '--log=3 limits shortlog length' '
320 cat >expected <<-EOF &&
21531927 321 Merge branch ${apos}left${apos}
bd2549ca 322
9830a9ca
JH
323 # By Another Author (3) and A U Thor (2)
324 # Via Another Committer
bd2549ca
RR
325 * left: (5 commits)
326 Left #5
327 Left #4
328 Left #3
329 ...
330 EOF
331
332 git fmt-merge-msg --log=3 <.git/FETCH_HEAD >actual &&
333 test_cmp expected actual
334'
335
336test_expect_success '--log=5 shows all 5 commits' '
337 cat >expected <<-EOF &&
21531927 338 Merge branch ${apos}left${apos}
bd2549ca 339
9830a9ca
JH
340 # By Another Author (3) and A U Thor (2)
341 # Via Another Committer
bd2549ca
RR
342 * left:
343 Left #5
344 Left #4
345 Left #3
346 Common #2
347 Common #1
348 EOF
349
350 git fmt-merge-msg --log=5 <.git/FETCH_HEAD >actual &&
351 test_cmp expected actual
352'
353
354test_expect_success '--no-log disables shortlog' '
21531927 355 echo "Merge branch ${apos}left${apos}" >expected &&
bd2549ca
RR
356 git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
357 test_cmp expected actual
358'
359
360test_expect_success '--log=0 disables shortlog' '
21531927 361 echo "Merge branch ${apos}left${apos}" >expected &&
bd2549ca
RR
362 git fmt-merge-msg --no-log <.git/FETCH_HEAD >actual &&
363 test_cmp expected actual
364'
365
2102440c
JN
366test_expect_success 'fmt-merge-msg -m' '
367 echo "Sync with left" >expected &&
368 cat >expected.log <<-EOF &&
369 Sync with left
370
9830a9ca
JH
371 # By Another Author (3) and A U Thor (2)
372 # Via Another Committer
2102440c
JN
373 * ${apos}left${apos} of $(pwd):
374 Left #5
375 Left #4
376 Left #3
377 Common #2
378 Common #1
379 EOF
380
9a94dba0
JH
381 test_unconfig merge.log &&
382 test_unconfig merge.summary &&
1550bb6e 383 git checkout main &&
2102440c
JN
384 git fetch "$(pwd)" left &&
385 git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
386 git fmt-merge-msg --log -m "Sync with left" \
387 <.git/FETCH_HEAD >actual.log &&
9a94dba0 388 test_config merge.log true &&
2102440c
JN
389 git fmt-merge-msg -m "Sync with left" \
390 <.git/FETCH_HEAD >actual.log-config &&
391 git fmt-merge-msg --no-log -m "Sync with left" \
392 <.git/FETCH_HEAD >actual.nolog &&
393
394 test_cmp expected actual &&
395 test_cmp expected.log actual.log &&
396 test_cmp expected.log actual.log-config &&
397 test_cmp expected actual.nolog
398'
399
d834c96a
JN
400test_expect_success 'setup: expected shortlog for two branches' '
401 cat >expected <<-EOF
21531927 402 Merge branches ${apos}left${apos} and ${apos}right${apos}
d834c96a 403
9830a9ca
JH
404 # By Another Author (3) and A U Thor (2)
405 # Via Another Committer
d834c96a
JN
406 * left:
407 Left #5
408 Left #4
409 Left #3
410 Common #2
411 Common #1
412
413 * right:
414 Right #5
415 Right #4
416 Right #3
417 Common #2
418 Common #1
419 EOF
420'
6cd9cfef 421
d834c96a 422test_expect_success 'shortlog for two branches' '
9a94dba0
JH
423 test_config merge.log true &&
424 test_unconfig merge.summary &&
1550bb6e 425 git checkout main &&
6183a6ad 426 test_tick &&
6cd9cfef 427 git fetch . left right &&
d834c96a 428 git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
6cd9cfef 429
9a94dba0
JH
430 test_unconfig merge.log &&
431 test_config merge.summary true &&
1550bb6e 432 git checkout main &&
6183a6ad 433 test_tick &&
30a95f30 434 git fetch . left right &&
d834c96a 435 git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
30a95f30 436
9a94dba0
JH
437 test_config merge.log yes &&
438 test_unconfig merge.summary &&
1550bb6e 439 git checkout main &&
6183a6ad 440 test_tick &&
6cd9cfef 441 git fetch . left right &&
d834c96a 442 git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
6cd9cfef 443
9a94dba0
JH
444 test_unconfig merge.log &&
445 test_config merge.summary yes &&
1550bb6e 446 git checkout main &&
6183a6ad 447 test_tick &&
30a95f30 448 git fetch . left right &&
d834c96a 449 git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
30a95f30 450
d834c96a
JN
451 test_cmp expected actual1 &&
452 test_cmp expected actual2 &&
453 test_cmp expected actual3 &&
454 test_cmp expected actual4
30a95f30
JH
455'
456
4c8d4c14 457test_expect_success 'merge-msg -F' '
9a94dba0
JH
458 test_unconfig merge.log &&
459 test_config merge.summary yes &&
1550bb6e 460 git checkout main &&
6183a6ad 461 test_tick &&
4c8d4c14 462 git fetch . left right &&
4c8d4c14
SB
463 git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
464 test_cmp expected actual
465'
466
467test_expect_success 'merge-msg -F in subdirectory' '
9a94dba0
JH
468 test_unconfig merge.log &&
469 test_config merge.summary yes &&
1550bb6e 470 git checkout main &&
6183a6ad 471 test_tick &&
4c8d4c14
SB
472 git fetch . left right &&
473 mkdir sub &&
474 cp .git/FETCH_HEAD sub/FETCH_HEAD &&
475 (
476 cd sub &&
477 git fmt-merge-msg -F FETCH_HEAD >../actual
478 ) &&
479 test_cmp expected actual
480'
481
419fe5bc 482test_expect_success 'merge-msg with nothing to merge' '
9a94dba0
JH
483 test_unconfig merge.log &&
484 test_config merge.summary yes &&
419fe5bc
SB
485
486 (
487 cd remote &&
488 git checkout -b unrelated &&
6183a6ad 489 test_tick &&
419fe5bc
SB
490 git fetch origin &&
491 git fmt-merge-msg <.git/FETCH_HEAD >../actual
492 ) &&
493
1c5e94f4 494 test_must_be_empty actual
419fe5bc
SB
495'
496
6d6f6e68 497test_expect_success 'merge-msg tag' '
d834c96a 498 cat >expected <<-EOF &&
21531927 499 Merge tag ${apos}tag-r3${apos}
d834c96a
JN
500
501 * tag ${apos}tag-r3${apos}:
502 Right #3
503 Common #2
504 Common #1
505 EOF
6d6f6e68 506
9a94dba0
JH
507 test_unconfig merge.log &&
508 test_config merge.summary yes &&
6d6f6e68 509
1550bb6e 510 git checkout main &&
6d6f6e68
SB
511 test_tick &&
512 git fetch . tag tag-r3 &&
513
514 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
515 test_cmp expected actual
516'
517
6d6f6e68 518test_expect_success 'merge-msg two tags' '
d834c96a 519 cat >expected <<-EOF &&
21531927 520 Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
d834c96a
JN
521
522 * tag ${apos}tag-r3${apos}:
523 Right #3
524 Common #2
525 Common #1
526
9830a9ca
JH
527 # By Another Author (3) and A U Thor (2)
528 # Via Another Committer
d834c96a
JN
529 * tag ${apos}tag-l5${apos}:
530 Left #5
531 Left #4
532 Left #3
533 Common #2
534 Common #1
535 EOF
536
9a94dba0
JH
537 test_unconfig merge.log &&
538 test_config merge.summary yes &&
6d6f6e68 539
1550bb6e 540 git checkout main &&
6d6f6e68
SB
541 test_tick &&
542 git fetch . tag tag-r3 tag tag-l5 &&
543
544 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
545 test_cmp expected actual
546'
547
6d6f6e68 548test_expect_success 'merge-msg tag and branch' '
d834c96a 549 cat >expected <<-EOF &&
21531927 550 Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
d834c96a
JN
551
552 * tag ${apos}tag-r3${apos}:
553 Right #3
554 Common #2
555 Common #1
556
9830a9ca
JH
557 # By Another Author (3) and A U Thor (2)
558 # Via Another Committer
d834c96a
JN
559 * left:
560 Left #5
561 Left #4
562 Left #3
563 Common #2
564 Common #1
565 EOF
566
9a94dba0
JH
567 test_unconfig merge.log &&
568 test_config merge.summary yes &&
6d6f6e68 569
1550bb6e 570 git checkout main &&
6d6f6e68
SB
571 test_tick &&
572 git fetch . tag tag-r3 left &&
573
574 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
575 test_cmp expected actual
576'
577
6d6f6e68 578test_expect_success 'merge-msg lots of commits' '
d834c96a
JN
579 {
580 cat <<-EOF &&
21531927 581 Merge branch ${apos}long${apos}
d834c96a
JN
582
583 * long: (35 commits)
584 EOF
585
586 i=29 &&
587 while test $i -gt 9
588 do
589 echo " $i" &&
0c51d6b4 590 i=$(($i-1)) || return 1
d834c96a
JN
591 done &&
592 echo " ..."
593 } >expected &&
6d6f6e68 594
9a94dba0
JH
595 test_config merge.summary yes &&
596
1550bb6e 597 git checkout main &&
6d6f6e68
SB
598 test_tick &&
599 git fetch . long &&
600
6d6f6e68
SB
601 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
602 test_cmp expected actual
603'
604
a38d3d76
JH
605test_expect_success 'merge-msg with "merging" an annotated tag' '
606 test_config merge.log true &&
607
1550bb6e 608 git checkout main^0 &&
a38d3d76
JH
609 git commit --allow-empty -m "One step ahead" &&
610 git tag -a -m "An annotated one" annote HEAD &&
611
1550bb6e 612 git checkout main &&
a38d3d76
JH
613 git fetch . annote &&
614
615 git fmt-merge-msg <.git/FETCH_HEAD >actual &&
616 {
617 cat <<-\EOF
21531927 618 Merge tag '\''annote'\''
a38d3d76
JH
619
620 An annotated one
621
622 * tag '\''annote'\'':
623 One step ahead
624 EOF
625 } >expected &&
626 test_cmp expected actual &&
627
628 test_when_finished "git reset --hard" &&
629 annote=$(git rev-parse annote) &&
adcc94a0 630 git merge --no-commit --no-ff $annote &&
a38d3d76
JH
631 {
632 cat <<-EOF
21531927 633 Merge tag '\''$annote'\''
a38d3d76
JH
634
635 An annotated one
636
637 * tag '\''$annote'\'':
638 One step ahead
639 EOF
640 } >expected &&
641 test_cmp expected .git/MERGE_MSG
642'
643
bd2bc942
JH
644test_expect_success 'merge --into-name=<name>' '
645 test_when_finished "git checkout main" &&
646 git checkout -B side main &&
647 git commit --allow-empty -m "One step ahead" &&
648
649 git checkout --detach main &&
650 git merge --no-ff side &&
651 git show -s --format="%s" >full.0 &&
652 head -n1 full.0 >actual &&
653 # expect that HEAD is shown as-is
654 grep -e "Merge branch .side. into HEAD$" actual &&
655
656 git reset --hard main &&
657 git merge --no-ff --into-name=main side &&
658 git show -s --format="%s" >full.1 &&
659 head -n1 full.1 >actual &&
660 # expect that we pretend to be merging to main, that is suppressed
661 grep -e "Merge branch .side.$" actual &&
662
663 git checkout -b throwaway main &&
664 git merge --no-ff --into-name=main side &&
665 git show -s --format="%s" >full.2 &&
666 head -n1 full.2 >actual &&
667 # expect that we pretend to be merging to main, that is suppressed
668 grep -e "Merge branch .side.$" actual
669'
670
6e6029a8 671test_expect_success 'merge.suppressDest configuration' '
bd2bc942 672 test_when_finished "git checkout main" &&
1550bb6e 673 git checkout -B side main &&
6e6029a8 674 git commit --allow-empty -m "One step ahead" &&
1550bb6e 675 git checkout main &&
6e6029a8
JH
676 git fetch . side &&
677
678 git -c merge.suppressDest="" fmt-merge-msg <.git/FETCH_HEAD >full.1 &&
679 head -n1 full.1 >actual &&
1550bb6e 680 grep -e "Merge branch .side. into main" actual &&
6e6029a8
JH
681
682 git -c merge.suppressDest="mast" fmt-merge-msg <.git/FETCH_HEAD >full.2 &&
683 head -n1 full.2 >actual &&
1550bb6e 684 grep -e "Merge branch .side. into main$" actual &&
6e6029a8 685
392ab3d9 686 git -c merge.suppressDest="ma?*[rn]" fmt-merge-msg <.git/FETCH_HEAD >full.3 &&
6e6029a8
JH
687 head -n1 full.3 >actual &&
688 grep -e "Merge branch .side." actual &&
bd2bc942
JH
689 ! grep -e " into main$" actual &&
690
691 git checkout --detach HEAD &&
692 git -c merge.suppressDest="main" fmt-merge-msg <.git/FETCH_HEAD >full.4 &&
693 head -n1 full.4 >actual &&
694 grep -e "Merge branch .side. into HEAD$" actual &&
695
696 git -c merge.suppressDest="main" fmt-merge-msg \
697 --into-name=main <.git/FETCH_HEAD >full.5 &&
698 head -n1 full.5 >actual &&
699 grep -e "Merge branch .side." actual &&
700 ! grep -e " into main$" actual &&
701 ! grep -e " into HEAD$" actual
6e6029a8
JH
702'
703
30a95f30 704test_done