trailer: fix comment/cut-line regression with opts->no_divider
[git.git] / t / t7513-interpret-trailers.sh
blob3343ad0eb621cc8bb47fab60e9d57badd10b2d94
1 #!/bin/sh
3 # Copyright (c) 2013, 2014 Christian Couder
6 test_description='git interpret-trailers'
8 . ./test-lib.sh
10 # When we want one trailing space at the end of each line, let's use sed
11 # to make sure that these spaces are not removed by any automatic tool.
13 test_expect_success 'setup' '
14 : >empty &&
15 cat >basic_message <<-\EOF &&
16 subject
18 body
19 EOF
20 cat >complex_message_body <<-\EOF &&
21 my subject
23 my body which is long
24 and contains some special
25 chars like : = ? !
27 EOF
28 sed -e "s/ Z\$/ /" >complex_message_trailers <<-\EOF &&
29 Fixes: Z
30 Acked-by: Z
31 Reviewed-by: Z
32 Signed-off-by: Z
33 EOF
34 cat >basic_patch <<-\EOF
35 ---
36 foo.txt | 2 +-
37 1 file changed, 1 insertion(+), 1 deletion(-)
39 diff --git a/foo.txt b/foo.txt
40 index 0353767..1d91aa1 100644
41 --- a/foo.txt
42 +++ b/foo.txt
43 @@ -1,3 +1,3 @@
45 -bar
46 +baz
49 1.9.rc0.11.ga562ddc
51 EOF
54 test_expect_success 'with cmd' '
55 test_when_finished "git config --remove-section trailer.bug" &&
56 git config trailer.bug.key "Bug-maker: " &&
57 git config trailer.bug.ifExists "add" &&
58 git config trailer.bug.cmd "echo \"maybe is\"" &&
59 cat >expected2 <<-EOF &&
61 Bug-maker: maybe is him
62 Bug-maker: maybe is me
63 EOF
64 git interpret-trailers --trailer "bug: him" --trailer "bug:me" \
65 >actual2 &&
66 test_cmp expected2 actual2
69 test_expect_success 'with cmd and $1' '
70 test_when_finished "git config --remove-section trailer.bug" &&
71 git config trailer.bug.key "Bug-maker: " &&
72 git config trailer.bug.ifExists "add" &&
73 git config trailer.bug.cmd "echo \"\$1\" is" &&
74 cat >expected2 <<-EOF &&
76 Bug-maker: him is him
77 Bug-maker: me is me
78 EOF
79 git interpret-trailers --trailer "bug: him" --trailer "bug:me" \
80 >actual2 &&
81 test_cmp expected2 actual2
84 test_expect_success 'with cmd and $1 with sh -c' '
85 test_when_finished "git config --remove-section trailer.bug" &&
86 git config trailer.bug.key "Bug-maker: " &&
87 git config trailer.bug.ifExists "replace" &&
88 git config trailer.bug.cmd "sh -c \"echo who is \"\$1\"\"" &&
89 cat >expected2 <<-EOF &&
91 Bug-maker: who is me
92 EOF
93 git interpret-trailers --trailer "bug: him" --trailer "bug:me" \
94 >actual2 &&
95 test_cmp expected2 actual2
98 test_expect_success 'with cmd and $1 with shell script' '
99 test_when_finished "git config --remove-section trailer.bug" &&
100 git config trailer.bug.key "Bug-maker: " &&
101 git config trailer.bug.ifExists "replace" &&
102 git config trailer.bug.cmd "./echoscript" &&
103 cat >expected2 <<-EOF &&
105 Bug-maker: who is me
107 cat >echoscript <<-EOF &&
108 #!/bin/sh
109 echo who is "\$1"
111 chmod +x echoscript &&
112 git interpret-trailers --trailer "bug: him" --trailer "bug:me" \
113 >actual2 &&
114 test_cmp expected2 actual2
117 test_expect_success 'without config' '
118 sed -e "s/ Z\$/ /" >expected <<-\EOF &&
120 ack: Peff
121 Reviewed-by: Z
122 Acked-by: Johan
124 git interpret-trailers --trailer "ack = Peff" --trailer "Reviewed-by" \
125 --trailer "Acked-by: Johan" empty >actual &&
126 test_cmp expected actual
129 test_expect_success 'without config in another order' '
130 sed -e "s/ Z\$/ /" >expected <<-\EOF &&
132 Acked-by: Johan
133 Reviewed-by: Z
134 ack: Peff
136 git interpret-trailers --trailer "Acked-by: Johan" --trailer "Reviewed-by" \
137 --trailer "ack = Peff" empty >actual &&
138 test_cmp expected actual
141 test_expect_success '--trim-empty without config' '
142 cat >expected <<-\EOF &&
144 ack: Peff
145 Acked-by: Johan
147 git interpret-trailers --trim-empty --trailer ack=Peff \
148 --trailer "Reviewed-by" --trailer "Acked-by: Johan" \
149 --trailer "sob:" empty >actual &&
150 test_cmp expected actual
153 test_expect_success 'with config option on the command line' '
154 cat >expected <<-\EOF &&
156 Acked-by: Johan
157 Reviewed-by: Peff
159 { echo && echo "Acked-by: Johan"; } |
160 git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \
161 --trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual &&
162 test_cmp expected actual
165 test_expect_success 'with only a title in the message' '
166 cat >expected <<-\EOF &&
167 area: change
169 Reviewed-by: Peff
170 Acked-by: Johan
172 echo "area: change" |
173 git interpret-trailers --trailer "Reviewed-by: Peff" \
174 --trailer "Acked-by: Johan" >actual &&
175 test_cmp expected actual
178 test_expect_success 'with multiline title in the message' '
179 cat >expected <<-\EOF &&
180 place of
181 code: change
183 Reviewed-by: Peff
184 Acked-by: Johan
186 printf "%s\n" "place of" "code: change" |
187 git interpret-trailers --trailer "Reviewed-by: Peff" \
188 --trailer "Acked-by: Johan" >actual &&
189 test_cmp expected actual
192 test_expect_success 'with non-trailer lines mixed with Signed-off-by' '
193 cat >patch <<-\EOF &&
195 this is not a trailer
196 this is not a trailer
197 Signed-off-by: a <a@example.com>
198 this is not a trailer
200 cat >expected <<-\EOF &&
202 this is not a trailer
203 this is not a trailer
204 Signed-off-by: a <a@example.com>
205 this is not a trailer
206 token: value
208 git interpret-trailers --trailer "token: value" patch >actual &&
209 test_cmp expected actual
212 test_expect_success 'with non-trailer lines mixed with cherry picked from' '
213 cat >patch <<-\EOF &&
215 this is not a trailer
216 this is not a trailer
217 (cherry picked from commit x)
218 this is not a trailer
220 cat >expected <<-\EOF &&
222 this is not a trailer
223 this is not a trailer
224 (cherry picked from commit x)
225 this is not a trailer
226 token: value
228 git interpret-trailers --trailer "token: value" patch >actual &&
229 test_cmp expected actual
232 test_expect_success 'with non-trailer lines mixed with a configured trailer' '
233 cat >patch <<-\EOF &&
235 this is not a trailer
236 this is not a trailer
237 My-trailer: x
238 this is not a trailer
240 cat >expected <<-\EOF &&
242 this is not a trailer
243 this is not a trailer
244 My-trailer: x
245 this is not a trailer
246 token: value
248 test_config trailer.my.key "My-trailer: " &&
249 git interpret-trailers --trailer "token: value" patch >actual &&
250 test_cmp expected actual
253 test_expect_success 'with non-trailer lines mixed with a non-configured trailer' '
254 cat >patch <<-\EOF &&
256 this is not a trailer
257 this is not a trailer
258 I-am-not-configured: x
259 this is not a trailer
261 cat >expected <<-\EOF &&
263 this is not a trailer
264 this is not a trailer
265 I-am-not-configured: x
266 this is not a trailer
268 token: value
270 test_config trailer.my.key "My-trailer: " &&
271 git interpret-trailers --trailer "token: value" patch >actual &&
272 test_cmp expected actual
275 test_expect_success 'with all non-configured trailers' '
276 cat >patch <<-\EOF &&
278 I-am-not-configured: x
279 I-am-also-not-configured: x
281 cat >expected <<-\EOF &&
283 I-am-not-configured: x
284 I-am-also-not-configured: x
285 token: value
287 test_config trailer.my.key "My-trailer: " &&
288 git interpret-trailers --trailer "token: value" patch >actual &&
289 test_cmp expected actual
292 test_expect_success 'with non-trailer lines only' '
293 cat >patch <<-\EOF &&
295 this is not a trailer
297 cat >expected <<-\EOF &&
299 this is not a trailer
301 token: value
303 git interpret-trailers --trailer "token: value" patch >actual &&
304 test_cmp expected actual
307 test_expect_success 'line with leading whitespace is not trailer' '
308 q_to_tab >patch <<-\EOF &&
310 Qtoken: value
312 q_to_tab >expected <<-\EOF &&
314 Qtoken: value
316 token: value
318 git interpret-trailers --trailer "token: value" patch >actual &&
319 test_cmp expected actual
322 test_expect_success 'multiline field treated as one trailer for 25% check' '
323 q_to_tab >patch <<-\EOF &&
325 Signed-off-by: a <a@example.com>
326 name: value on
327 Qmultiple lines
328 this is not a trailer
329 this is not a trailer
330 this is not a trailer
331 this is not a trailer
332 this is not a trailer
333 this is not a trailer
335 q_to_tab >expected <<-\EOF &&
337 Signed-off-by: a <a@example.com>
338 name: value on
339 Qmultiple lines
340 this is not a trailer
341 this is not a trailer
342 this is not a trailer
343 this is not a trailer
344 this is not a trailer
345 this is not a trailer
346 name: value
348 git interpret-trailers --trailer "name: value" patch >actual &&
349 test_cmp expected actual
352 test_expect_success 'multiline field treated as atomic for placement' '
353 q_to_tab >patch <<-\EOF &&
355 another: trailer
356 name: value on
357 Qmultiple lines
358 another: trailer
360 q_to_tab >expected <<-\EOF &&
362 another: trailer
363 name: value on
364 Qmultiple lines
365 name: value
366 another: trailer
368 test_config trailer.name.where after &&
369 git interpret-trailers --trailer "name: value" patch >actual &&
370 test_cmp expected actual
373 test_expect_success 'multiline field treated as atomic for replacement' '
374 q_to_tab >patch <<-\EOF &&
376 another: trailer
377 name: value on
378 Qmultiple lines
379 another: trailer
381 q_to_tab >expected <<-\EOF &&
383 another: trailer
384 another: trailer
385 name: value
387 test_config trailer.name.ifexists replace &&
388 git interpret-trailers --trailer "name: value" patch >actual &&
389 test_cmp expected actual
392 test_expect_success 'multiline field treated as atomic for difference check' '
393 q_to_tab >patch <<-\EOF &&
395 another: trailer
396 name: first line
397 Qsecond line
398 another: trailer
400 test_config trailer.name.ifexists addIfDifferent &&
402 q_to_tab >trailer <<-\EOF &&
403 name: first line
404 Qsecond line
406 q_to_tab >expected <<-\EOF &&
408 another: trailer
409 name: first line
410 Qsecond line
411 another: trailer
413 git interpret-trailers --trailer "$(cat trailer)" patch >actual &&
414 test_cmp expected actual &&
416 q_to_tab >trailer <<-\EOF &&
417 name: first line
418 QQQQQsecond line
420 q_to_tab >expected <<-\EOF &&
422 another: trailer
423 name: first line
424 Qsecond line
425 another: trailer
426 name: first line
427 QQQQQsecond line
429 git interpret-trailers --trailer "$(cat trailer)" patch >actual &&
430 test_cmp expected actual &&
432 q_to_tab >trailer <<-\EOF &&
433 name: first line *DIFFERENT*
434 Qsecond line
436 q_to_tab >expected <<-\EOF &&
438 another: trailer
439 name: first line
440 Qsecond line
441 another: trailer
442 name: first line *DIFFERENT*
443 Qsecond line
445 git interpret-trailers --trailer "$(cat trailer)" patch >actual &&
446 test_cmp expected actual
449 test_expect_success 'multiline field treated as atomic for neighbor check' '
450 q_to_tab >patch <<-\EOF &&
452 another: trailer
453 name: first line
454 Qsecond line
455 another: trailer
457 test_config trailer.name.where after &&
458 test_config trailer.name.ifexists addIfDifferentNeighbor &&
460 q_to_tab >trailer <<-\EOF &&
461 name: first line
462 Qsecond line
464 q_to_tab >expected <<-\EOF &&
466 another: trailer
467 name: first line
468 Qsecond line
469 another: trailer
471 git interpret-trailers --trailer "$(cat trailer)" patch >actual &&
472 test_cmp expected actual &&
474 q_to_tab >trailer <<-\EOF &&
475 name: first line
476 QQQQQsecond line
478 q_to_tab >expected <<-\EOF &&
480 another: trailer
481 name: first line
482 Qsecond line
483 name: first line
484 QQQQQsecond line
485 another: trailer
487 git interpret-trailers --trailer "$(cat trailer)" patch >actual &&
488 test_cmp expected actual
491 test_expect_success 'with config setup' '
492 git config trailer.ack.key "Acked-by: " &&
493 cat >expected <<-\EOF &&
495 Acked-by: Peff
497 git interpret-trailers --trim-empty --trailer "ack = Peff" empty >actual &&
498 test_cmp expected actual &&
499 git interpret-trailers --trim-empty --trailer "Acked-by = Peff" empty >actual &&
500 test_cmp expected actual &&
501 git interpret-trailers --trim-empty --trailer "Acked-by :Peff" empty >actual &&
502 test_cmp expected actual
505 test_expect_success 'with config setup and ":=" as separators' '
506 git config trailer.separators ":=" &&
507 git config trailer.ack.key "Acked-by= " &&
508 cat >expected <<-\EOF &&
510 Acked-by= Peff
512 git interpret-trailers --trim-empty --trailer "ack = Peff" empty >actual &&
513 test_cmp expected actual &&
514 git interpret-trailers --trim-empty --trailer "Acked-by= Peff" empty >actual &&
515 test_cmp expected actual &&
516 git interpret-trailers --trim-empty --trailer "Acked-by : Peff" empty >actual &&
517 test_cmp expected actual
520 test_expect_success 'with config setup and "%" as separators' '
521 git config trailer.separators "%" &&
522 cat >expected <<-\EOF &&
524 bug% 42
525 count% 10
526 bug% 422
528 git interpret-trailers --trim-empty --trailer "bug = 42" \
529 --trailer count%10 --trailer "test: stuff" \
530 --trailer "bug % 422" empty >actual &&
531 test_cmp expected actual
534 test_expect_success 'with "%" as separators and a message with trailers' '
535 cat >special_message <<-\EOF &&
536 Special Message
538 bug% 42
539 count% 10
540 bug% 422
542 cat >expected <<-\EOF &&
543 Special Message
545 bug% 42
546 count% 10
547 bug% 422
548 count% 100
550 git interpret-trailers --trailer count%100 \
551 special_message >actual &&
552 test_cmp expected actual
555 test_expect_success 'with config setup and ":=#" as separators' '
556 git config trailer.separators ":=#" &&
557 git config trailer.bug.key "Bug #" &&
558 cat >expected <<-\EOF &&
560 Bug #42
562 git interpret-trailers --trim-empty --trailer "bug = 42" empty >actual &&
563 test_cmp expected actual
566 test_expect_success 'with commit basic message' '
567 cat basic_message >expected &&
568 echo >>expected &&
569 git interpret-trailers <basic_message >actual &&
570 test_cmp expected actual
573 test_expect_success 'with basic patch' '
574 cat basic_message >input &&
575 cat basic_patch >>input &&
576 cat basic_message >expected &&
577 echo >>expected &&
578 cat basic_patch >>expected &&
579 git interpret-trailers <input >actual &&
580 test_cmp expected actual
583 test_expect_success 'with commit complex message as argument' '
584 cat complex_message_body complex_message_trailers >complex_message &&
585 cat complex_message_body >expected &&
586 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
587 Fixes: Z
588 Acked-by= Z
589 Reviewed-by: Z
590 Signed-off-by: Z
592 git interpret-trailers complex_message >actual &&
593 test_cmp expected actual
596 test_expect_success 'with 2 files arguments' '
597 cat basic_message >>expected &&
598 echo >>expected &&
599 cat basic_patch >>expected &&
600 git interpret-trailers complex_message input >actual &&
601 test_cmp expected actual
604 # Cover multiple comment characters with the same test input.
605 for char in "#" ";"
607 case "$char" in
608 "#")
609 # This is the default, so let's explicitly _not_
610 # set any config to make sure it behaves as we expect.
613 config="-c core.commentChar=$char"
615 esac
617 test_expect_success "with message that has comments ($char)" '
618 cat basic_message >message_with_comments &&
619 sed -e "s/ Z\$/ /" \
620 -e "s/#/$char/g" >>message_with_comments <<-EOF &&
621 # comment
623 # other comment
624 Cc: Z
625 # yet another comment
626 Reviewed-by: Johan
627 Reviewed-by: Z
628 # last comment
631 cat basic_patch >>message_with_comments &&
632 cat basic_message >expected &&
633 sed -e "s/#/$char/g" >>expected <<-\EOF &&
634 # comment
636 Reviewed-by: Johan
637 Cc: Peff
638 # last comment
641 cat basic_patch >>expected &&
642 git $config interpret-trailers \
643 --trim-empty --trailer "Cc: Peff" \
644 message_with_comments >actual &&
645 test_cmp expected actual
647 done
649 test_expect_success 'with message that has an old style conflict block' '
650 cat basic_message >message_with_comments &&
651 sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF &&
652 # comment
654 # other comment
655 Cc: Z
656 # yet another comment
657 Reviewed-by: Johan
658 Reviewed-by: Z
659 # last comment
661 Conflicts:
664 cat basic_message >expected &&
665 cat >>expected <<-\EOF &&
666 # comment
668 Reviewed-by: Johan
669 Cc: Peff
670 # last comment
672 Conflicts:
675 git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual &&
676 test_cmp expected actual
679 test_expect_success 'with commit complex message and trailer args' '
680 cat complex_message_body >expected &&
681 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
682 Fixes: Z
683 Acked-by= Z
684 Reviewed-by: Z
685 Signed-off-by: Z
686 Acked-by= Peff
687 Bug #42
689 git interpret-trailers --trailer "ack: Peff" \
690 --trailer "bug: 42" <complex_message >actual &&
691 test_cmp expected actual
694 test_expect_success 'with complex patch, args and --trim-empty' '
695 cat complex_message >complex_patch &&
696 cat basic_patch >>complex_patch &&
697 cat complex_message_body >expected &&
698 cat >>expected <<-\EOF &&
699 Acked-by= Peff
700 Bug #42
702 cat basic_patch >>expected &&
703 git interpret-trailers --trim-empty --trailer "ack: Peff" \
704 --trailer "bug: 42" <complex_patch >actual &&
705 test_cmp expected actual
708 test_expect_success 'in-place editing with basic patch' '
709 cat basic_message >message &&
710 cat basic_patch >>message &&
711 cat basic_message >expected &&
712 echo >>expected &&
713 cat basic_patch >>expected &&
714 git interpret-trailers --in-place message &&
715 test_cmp expected message
718 test_expect_success 'in-place editing with additional trailer' '
719 cat basic_message >message &&
720 cat basic_patch >>message &&
721 cat basic_message >expected &&
722 echo >>expected &&
723 cat >>expected <<-\EOF &&
724 Reviewed-by: Alice
726 cat basic_patch >>expected &&
727 git interpret-trailers --trailer "Reviewed-by: Alice" --in-place message &&
728 test_cmp expected message
731 test_expect_success 'in-place editing on stdin disallowed' '
732 test_must_fail git interpret-trailers --trailer "Reviewed-by: Alice" --in-place < basic_message
735 test_expect_success 'in-place editing on non-existing file' '
736 test_must_fail git interpret-trailers --trailer "Reviewed-by: Alice" --in-place nonexisting &&
737 test_path_is_missing nonexisting
740 test_expect_success POSIXPERM,SANITY "in-place editing doesn't clobber original file on error" '
741 cat basic_message >message &&
742 chmod -r message &&
743 test_must_fail git interpret-trailers --trailer "Reviewed-by: Alice" --in-place message &&
744 chmod +r message &&
745 test_cmp message basic_message
748 test_expect_success 'using "where = before"' '
749 git config trailer.bug.where "before" &&
750 cat complex_message_body >expected &&
751 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
752 Bug #42
753 Fixes: Z
754 Acked-by= Z
755 Reviewed-by: Z
756 Signed-off-by: Z
757 Acked-by= Peff
759 git interpret-trailers --trailer "ack: Peff" \
760 --trailer "bug: 42" complex_message >actual &&
761 test_cmp expected actual
764 test_expect_success 'overriding configuration with "--where after"' '
765 git config trailer.ack.where "before" &&
766 cat complex_message_body >expected &&
767 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
768 Fixes: Z
769 Acked-by= Z
770 Acked-by= Peff
771 Reviewed-by: Z
772 Signed-off-by: Z
774 git interpret-trailers --where after --trailer "ack: Peff" \
775 complex_message >actual &&
776 test_cmp expected actual
779 test_expect_success 'using "where = before" with "--no-where"' '
780 cat complex_message_body >expected &&
781 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
782 Bug #42
783 Fixes: Z
784 Acked-by= Peff
785 Acked-by= Z
786 Reviewed-by: Z
787 Signed-off-by: Z
789 git interpret-trailers --where after --no-where --trailer "ack: Peff" \
790 --trailer "bug: 42" complex_message >actual &&
791 test_cmp expected actual
794 test_expect_success 'using "where = after"' '
795 git config trailer.ack.where "after" &&
796 cat complex_message_body >expected &&
797 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
798 Bug #42
799 Fixes: Z
800 Acked-by= Z
801 Acked-by= Peff
802 Reviewed-by: Z
803 Signed-off-by: Z
805 git interpret-trailers --trailer "ack: Peff" \
806 --trailer "bug: 42" complex_message >actual &&
807 test_cmp expected actual
810 test_expect_success 'using "where = end"' '
811 git config trailer.review.key "Reviewed-by" &&
812 git config trailer.review.where "end" &&
813 cat complex_message_body >expected &&
814 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
815 Fixes: Z
816 Acked-by= Z
817 Acked-by= Peff
818 Reviewed-by: Z
819 Signed-off-by: Z
820 Reviewed-by: Junio
821 Reviewed-by: Johannes
823 git interpret-trailers --trailer "ack: Peff" \
824 --trailer "Reviewed-by: Junio" --trailer "Reviewed-by: Johannes" \
825 complex_message >actual &&
826 test_cmp expected actual
829 test_expect_success 'using "where = start"' '
830 git config trailer.review.key "Reviewed-by" &&
831 git config trailer.review.where "start" &&
832 cat complex_message_body >expected &&
833 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
834 Reviewed-by: Johannes
835 Reviewed-by: Junio
836 Fixes: Z
837 Acked-by= Z
838 Acked-by= Peff
839 Reviewed-by: Z
840 Signed-off-by: Z
842 git interpret-trailers --trailer "ack: Peff" \
843 --trailer "Reviewed-by: Junio" --trailer "Reviewed-by: Johannes" \
844 complex_message >actual &&
845 test_cmp expected actual
848 test_expect_success 'using "where = before" for a token in the middle of the message' '
849 git config trailer.review.key "Reviewed-by:" &&
850 git config trailer.review.where "before" &&
851 cat complex_message_body >expected &&
852 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
853 Bug #42
854 Fixes: Z
855 Acked-by= Z
856 Acked-by= Peff
857 Reviewed-by:Johan
858 Reviewed-by:
859 Signed-off-by: Z
861 git interpret-trailers --trailer "ack: Peff" --trailer "bug: 42" \
862 --trailer "review: Johan" <complex_message >actual &&
863 test_cmp expected actual
866 test_expect_success 'using "where = before" and --trim-empty' '
867 cat complex_message_body >expected &&
868 cat >>expected <<-\EOF &&
869 Bug #46
870 Bug #42
871 Acked-by= Peff
872 Reviewed-by:Johan
874 git interpret-trailers --trim-empty --trailer "ack: Peff" \
875 --trailer "bug: 42" --trailer "review: Johan" \
876 --trailer "Bug: 46" <complex_message >actual &&
877 test_cmp expected actual
880 test_expect_success 'the default is "ifExists = addIfDifferentNeighbor"' '
881 cat complex_message_body >expected &&
882 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
883 Bug #42
884 Fixes: Z
885 Acked-by= Z
886 Acked-by= Peff
887 Acked-by= Junio
888 Acked-by= Peff
889 Reviewed-by:
890 Signed-off-by: Z
892 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
893 --trailer "ack: Junio" --trailer "bug: 42" --trailer "ack: Peff" \
894 --trailer "ack: Peff" <complex_message >actual &&
895 test_cmp expected actual
898 test_expect_success 'default "ifExists" is now "addIfDifferent"' '
899 git config trailer.ifexists "addIfDifferent" &&
900 cat complex_message_body >expected &&
901 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
902 Bug #42
903 Fixes: Z
904 Acked-by= Z
905 Acked-by= Peff
906 Acked-by= Junio
907 Reviewed-by:
908 Signed-off-by: Z
910 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
911 --trailer "ack: Junio" --trailer "bug: 42" --trailer "ack: Peff" \
912 --trailer "ack: Peff" <complex_message >actual &&
913 test_cmp expected actual
916 test_expect_success 'using "ifExists = addIfDifferent" with "where = end"' '
917 git config trailer.ack.ifExists "addIfDifferent" &&
918 git config trailer.ack.where "end" &&
919 cat complex_message_body >expected &&
920 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
921 Bug #42
922 Fixes: Z
923 Acked-by= Z
924 Reviewed-by:
925 Signed-off-by: Z
926 Acked-by= Peff
928 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
929 --trailer "bug: 42" --trailer "ack: Peff" \
930 <complex_message >actual &&
931 test_cmp expected actual
934 test_expect_success 'using "ifExists = addIfDifferent" with "where = before"' '
935 git config trailer.ack.ifExists "addIfDifferent" &&
936 git config trailer.ack.where "before" &&
937 cat complex_message_body >expected &&
938 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
939 Bug #42
940 Fixes: Z
941 Acked-by= Peff
942 Acked-by= Z
943 Reviewed-by:
944 Signed-off-by: Z
946 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
947 --trailer "bug: 42" --trailer "ack: Peff" \
948 <complex_message >actual &&
949 test_cmp expected actual
952 test_expect_success 'using "ifExists = addIfDifferentNeighbor" with "where = end"' '
953 git config trailer.ack.ifExists "addIfDifferentNeighbor" &&
954 git config trailer.ack.where "end" &&
955 cat complex_message_body >expected &&
956 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
957 Bug #42
958 Fixes: Z
959 Acked-by= Z
960 Reviewed-by:
961 Signed-off-by: Z
962 Acked-by= Peff
963 Acked-by= Junio
964 Tested-by: Jakub
965 Acked-by= Junio
966 Acked-by= Peff
968 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
969 --trailer "ack: Junio" --trailer "bug: 42" \
970 --trailer "Tested-by: Jakub" --trailer "ack: Junio" \
971 --trailer "ack: Junio" --trailer "ack: Peff" <complex_message >actual &&
972 test_cmp expected actual
975 test_expect_success 'using "ifExists = addIfDifferentNeighbor" with "where = after"' '
976 git config trailer.ack.ifExists "addIfDifferentNeighbor" &&
977 git config trailer.ack.where "after" &&
978 cat complex_message_body >expected &&
979 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
980 Bug #42
981 Fixes: Z
982 Acked-by= Z
983 Acked-by= Peff
984 Acked-by= Junio
985 Acked-by= Peff
986 Reviewed-by:
987 Signed-off-by: Z
988 Tested-by: Jakub
990 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
991 --trailer "ack: Junio" --trailer "bug: 42" \
992 --trailer "Tested-by: Jakub" --trailer "ack: Junio" \
993 --trailer "ack: Junio" --trailer "ack: Peff" <complex_message >actual &&
994 test_cmp expected actual
997 test_expect_success 'using "ifExists = addIfDifferentNeighbor" and --trim-empty' '
998 git config trailer.ack.ifExists "addIfDifferentNeighbor" &&
999 cat complex_message_body >expected &&
1000 cat >>expected <<-\EOF &&
1001 Bug #42
1002 Acked-by= Peff
1003 Acked-by= Junio
1004 Acked-by= Peff
1006 git interpret-trailers --trim-empty --trailer "ack: Peff" \
1007 --trailer "Acked-by= Peff" --trailer "review:" \
1008 --trailer "ack: Junio" --trailer "bug: 42" \
1009 --trailer "ack: Peff" <complex_message >actual &&
1010 test_cmp expected actual
1013 test_expect_success 'using "ifExists = add" with "where = end"' '
1014 git config trailer.ack.ifExists "add" &&
1015 git config trailer.ack.where "end" &&
1016 cat complex_message_body >expected &&
1017 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1018 Bug #42
1019 Fixes: Z
1020 Acked-by= Z
1021 Reviewed-by:
1022 Signed-off-by: Z
1023 Acked-by= Peff
1024 Acked-by= Peff
1025 Tested-by: Jakub
1026 Acked-by= Junio
1027 Tested-by: Johannes
1028 Acked-by= Peff
1030 git interpret-trailers --trailer "ack: Peff" \
1031 --trailer "Acked-by= Peff" --trailer "review:" \
1032 --trailer "Tested-by: Jakub" --trailer "ack: Junio" \
1033 --trailer "bug: 42" --trailer "Tested-by: Johannes" \
1034 --trailer "ack: Peff" <complex_message >actual &&
1035 test_cmp expected actual
1038 test_expect_success 'using "ifExists = add" with "where = after"' '
1039 git config trailer.ack.ifExists "add" &&
1040 git config trailer.ack.where "after" &&
1041 cat complex_message_body >expected &&
1042 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1043 Bug #42
1044 Fixes: Z
1045 Acked-by= Z
1046 Acked-by= Peff
1047 Acked-by= Peff
1048 Acked-by= Junio
1049 Acked-by= Peff
1050 Reviewed-by:
1051 Signed-off-by: Z
1053 git interpret-trailers --trailer "ack: Peff" \
1054 --trailer "Acked-by= Peff" --trailer "review:" \
1055 --trailer "ack: Junio" --trailer "bug: 42" \
1056 --trailer "ack: Peff" <complex_message >actual &&
1057 test_cmp expected actual
1060 test_expect_success 'overriding configuration with "--if-exists replace"' '
1061 git config trailer.fix.key "Fixes: " &&
1062 git config trailer.fix.ifExists "add" &&
1063 cat complex_message_body >expected &&
1064 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1065 Bug #42
1066 Acked-by= Z
1067 Reviewed-by:
1068 Signed-off-by: Z
1069 Fixes: 22
1071 git interpret-trailers --if-exists replace --trailer "review:" \
1072 --trailer "fix=53" --trailer "fix=22" --trailer "bug: 42" \
1073 <complex_message >actual &&
1074 test_cmp expected actual
1077 test_expect_success 'using "ifExists = replace"' '
1078 git config trailer.fix.key "Fixes: " &&
1079 git config trailer.fix.ifExists "replace" &&
1080 cat complex_message_body >expected &&
1081 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1082 Bug #42
1083 Acked-by= Z
1084 Acked-by= Junio
1085 Acked-by= Peff
1086 Reviewed-by:
1087 Signed-off-by: Z
1088 Fixes: 22
1090 git interpret-trailers --trailer "review:" \
1091 --trailer "fix=53" --trailer "ack: Junio" --trailer "fix=22" \
1092 --trailer "bug: 42" --trailer "ack: Peff" \
1093 <complex_message >actual &&
1094 test_cmp expected actual
1097 test_expect_success 'using "ifExists = replace" with "where = after"' '
1098 git config trailer.fix.where "after" &&
1099 cat complex_message_body >expected &&
1100 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1101 Bug #42
1102 Fixes: 22
1103 Acked-by= Z
1104 Acked-by= Junio
1105 Acked-by= Peff
1106 Reviewed-by:
1107 Signed-off-by: Z
1109 git interpret-trailers --trailer "review:" \
1110 --trailer "fix=53" --trailer "ack: Junio" --trailer "fix=22" \
1111 --trailer "bug: 42" --trailer "ack: Peff" \
1112 <complex_message >actual &&
1113 test_cmp expected actual
1116 test_expect_success 'using "ifExists = doNothing"' '
1117 git config trailer.fix.ifExists "doNothing" &&
1118 cat complex_message_body >expected &&
1119 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1120 Bug #42
1121 Fixes: Z
1122 Acked-by= Z
1123 Acked-by= Junio
1124 Acked-by= Peff
1125 Reviewed-by:
1126 Signed-off-by: Z
1128 git interpret-trailers --trailer "review:" --trailer "fix=53" \
1129 --trailer "ack: Junio" --trailer "fix=22" \
1130 --trailer "bug: 42" --trailer "ack: Peff" \
1131 <complex_message >actual &&
1132 test_cmp expected actual
1135 test_expect_success 'the default is "ifMissing = add"' '
1136 git config trailer.cc.key "Cc: " &&
1137 git config trailer.cc.where "before" &&
1138 cat complex_message_body >expected &&
1139 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1140 Bug #42
1141 Cc: Linus
1142 Fixes: Z
1143 Acked-by= Z
1144 Acked-by= Junio
1145 Acked-by= Peff
1146 Reviewed-by:
1147 Signed-off-by: Z
1149 git interpret-trailers --trailer "review:" --trailer "fix=53" \
1150 --trailer "cc=Linus" --trailer "ack: Junio" \
1151 --trailer "fix=22" --trailer "bug: 42" --trailer "ack: Peff" \
1152 <complex_message >actual &&
1153 test_cmp expected actual
1156 test_expect_success 'overriding configuration with "--if-missing doNothing"' '
1157 git config trailer.ifmissing "add" &&
1158 cat complex_message_body >expected &&
1159 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1160 Fixes: Z
1161 Acked-by= Z
1162 Acked-by= Junio
1163 Acked-by= Peff
1164 Reviewed-by:
1165 Signed-off-by: Z
1167 git interpret-trailers --if-missing doNothing \
1168 --trailer "review:" --trailer "fix=53" \
1169 --trailer "cc=Linus" --trailer "ack: Junio" \
1170 --trailer "fix=22" --trailer "bug: 42" --trailer "ack: Peff" \
1171 <complex_message >actual &&
1172 test_cmp expected actual
1175 test_expect_success 'when default "ifMissing" is "doNothing"' '
1176 git config trailer.ifmissing "doNothing" &&
1177 cat complex_message_body >expected &&
1178 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1179 Fixes: Z
1180 Acked-by= Z
1181 Acked-by= Junio
1182 Acked-by= Peff
1183 Reviewed-by:
1184 Signed-off-by: Z
1186 git interpret-trailers --trailer "review:" --trailer "fix=53" \
1187 --trailer "cc=Linus" --trailer "ack: Junio" \
1188 --trailer "fix=22" --trailer "bug: 42" --trailer "ack: Peff" \
1189 <complex_message >actual &&
1190 test_cmp expected actual &&
1191 git config trailer.ifmissing "add"
1194 test_expect_success 'using "ifMissing = add" with "where = end"' '
1195 git config trailer.cc.key "Cc: " &&
1196 git config trailer.cc.where "end" &&
1197 git config trailer.cc.ifMissing "add" &&
1198 cat complex_message_body >expected &&
1199 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1200 Bug #42
1201 Fixes: Z
1202 Acked-by= Z
1203 Acked-by= Junio
1204 Acked-by= Peff
1205 Reviewed-by:
1206 Signed-off-by: Z
1207 Cc: Linus
1209 git interpret-trailers --trailer "review:" --trailer "fix=53" \
1210 --trailer "ack: Junio" --trailer "fix=22" \
1211 --trailer "bug: 42" --trailer "cc=Linus" --trailer "ack: Peff" \
1212 <complex_message >actual &&
1213 test_cmp expected actual
1216 test_expect_success 'using "ifMissing = add" with "where = before"' '
1217 git config trailer.cc.key "Cc: " &&
1218 git config trailer.cc.where "before" &&
1219 git config trailer.cc.ifMissing "add" &&
1220 cat complex_message_body >expected &&
1221 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1222 Cc: Linus
1223 Bug #42
1224 Fixes: Z
1225 Acked-by= Z
1226 Acked-by= Junio
1227 Acked-by= Peff
1228 Reviewed-by:
1229 Signed-off-by: Z
1231 git interpret-trailers --trailer "review:" --trailer "fix=53" \
1232 --trailer "ack: Junio" --trailer "fix=22" \
1233 --trailer "bug: 42" --trailer "cc=Linus" --trailer "ack: Peff" \
1234 <complex_message >actual &&
1235 test_cmp expected actual
1238 test_expect_success 'using "ifMissing = doNothing"' '
1239 git config trailer.cc.ifMissing "doNothing" &&
1240 cat complex_message_body >expected &&
1241 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1242 Bug #42
1243 Fixes: Z
1244 Acked-by= Z
1245 Acked-by= Junio
1246 Acked-by= Peff
1247 Reviewed-by:
1248 Signed-off-by: Z
1250 git interpret-trailers --trailer "review:" --trailer "fix=53" \
1251 --trailer "cc=Linus" --trailer "ack: Junio" \
1252 --trailer "fix=22" --trailer "bug: 42" --trailer "ack: Peff" \
1253 <complex_message >actual &&
1254 test_cmp expected actual
1257 test_expect_success 'default "where" is now "after"' '
1258 git config trailer.where "after" &&
1259 git config --unset trailer.ack.where &&
1260 cat complex_message_body >expected &&
1261 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1262 Bug #42
1263 Fixes: Z
1264 Acked-by= Z
1265 Acked-by= Peff
1266 Acked-by= Peff
1267 Acked-by= Junio
1268 Acked-by= Peff
1269 Reviewed-by:
1270 Signed-off-by: Z
1271 Tested-by: Jakub
1272 Tested-by: Johannes
1274 git interpret-trailers --trailer "ack: Peff" \
1275 --trailer "Acked-by= Peff" --trailer "review:" \
1276 --trailer "Tested-by: Jakub" --trailer "ack: Junio" \
1277 --trailer "bug: 42" --trailer "Tested-by: Johannes" \
1278 --trailer "ack: Peff" <complex_message >actual &&
1279 test_cmp expected actual
1282 test_expect_success 'with simple command' '
1283 git config trailer.sign.key "Signed-off-by: " &&
1284 git config trailer.sign.where "after" &&
1285 git config trailer.sign.ifExists "addIfDifferentNeighbor" &&
1286 git config trailer.sign.command "echo \"A U Thor <author@example.com>\"" &&
1287 cat complex_message_body >expected &&
1288 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1289 Fixes: Z
1290 Acked-by= Z
1291 Reviewed-by:
1292 Signed-off-by: Z
1293 Signed-off-by: A U Thor <author@example.com>
1295 git interpret-trailers --trailer "review:" --trailer "fix=22" \
1296 <complex_message >actual &&
1297 test_cmp expected actual
1300 test_expect_success 'with command using committer information' '
1301 git config trailer.sign.ifExists "addIfDifferent" &&
1302 git config trailer.sign.command "echo \"\$GIT_COMMITTER_NAME <\$GIT_COMMITTER_EMAIL>\"" &&
1303 cat complex_message_body >expected &&
1304 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1305 Fixes: Z
1306 Acked-by= Z
1307 Reviewed-by:
1308 Signed-off-by: Z
1309 Signed-off-by: C O Mitter <committer@example.com>
1311 git interpret-trailers --trailer "review:" --trailer "fix=22" \
1312 <complex_message >actual &&
1313 test_cmp expected actual
1316 test_expect_success 'with command using author information' '
1317 git config trailer.sign.key "Signed-off-by: " &&
1318 git config trailer.sign.where "after" &&
1319 git config trailer.sign.ifExists "addIfDifferentNeighbor" &&
1320 git config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
1321 cat complex_message_body >expected &&
1322 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
1323 Fixes: Z
1324 Acked-by= Z
1325 Reviewed-by:
1326 Signed-off-by: Z
1327 Signed-off-by: A U Thor <author@example.com>
1329 git interpret-trailers --trailer "review:" --trailer "fix=22" \
1330 <complex_message >actual &&
1331 test_cmp expected actual
1334 test_expect_success 'setup a commit' '
1335 echo "Content of the first commit." > a.txt &&
1336 git add a.txt &&
1337 git commit -m "Add file a.txt"
1340 test_expect_success 'cmd takes precedence over command' '
1341 test_when_finished "git config --unset trailer.fix.cmd" &&
1342 git config trailer.fix.ifExists "replace" &&
1343 git config trailer.fix.cmd "test -n \"\$1\" && git log -1 --oneline --format=\"%h (%aN)\" \
1344 --abbrev-commit --abbrev=14 \"\$1\" || true" &&
1345 git config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" \
1346 --abbrev-commit --abbrev=14 \$ARG" &&
1347 FIXED=$(git log -1 --oneline --format="%h (%aN)" --abbrev-commit --abbrev=14 HEAD) &&
1348 cat complex_message_body >expected2 &&
1349 sed -e "s/ Z\$/ /" >>expected2 <<-EOF &&
1350 Fixes: $FIXED
1351 Acked-by= Z
1352 Reviewed-by:
1353 Signed-off-by: Z
1354 Signed-off-by: A U Thor <author@example.com>
1356 git interpret-trailers --trailer "review:" --trailer "fix=HEAD" \
1357 <complex_message >actual2 &&
1358 test_cmp expected2 actual2
1361 test_expect_success 'with command using $ARG' '
1362 git config trailer.fix.ifExists "replace" &&
1363 git config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" &&
1364 FIXED=$(git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 HEAD) &&
1365 cat complex_message_body >expected &&
1366 sed -e "s/ Z\$/ /" >>expected <<-EOF &&
1367 Fixes: $FIXED
1368 Acked-by= Z
1369 Reviewed-by:
1370 Signed-off-by: Z
1371 Signed-off-by: A U Thor <author@example.com>
1373 git interpret-trailers --trailer "review:" --trailer "fix=HEAD" \
1374 <complex_message >actual &&
1375 test_cmp expected actual
1378 test_expect_success 'with failing command using $ARG' '
1379 git config trailer.fix.ifExists "replace" &&
1380 git config trailer.fix.command "false \$ARG" &&
1381 cat complex_message_body >expected &&
1382 sed -e "s/ Z\$/ /" >>expected <<-EOF &&
1383 Fixes: Z
1384 Acked-by= Z
1385 Reviewed-by:
1386 Signed-off-by: Z
1387 Signed-off-by: A U Thor <author@example.com>
1389 git interpret-trailers --trailer "review:" --trailer "fix=HEAD" \
1390 <complex_message >actual &&
1391 test_cmp expected actual
1394 test_expect_success 'with empty tokens' '
1395 git config --unset trailer.fix.command &&
1396 cat >expected <<-EOF &&
1398 Signed-off-by: A U Thor <author@example.com>
1400 git interpret-trailers --trailer ":" --trailer ":test" >actual <<-EOF &&
1402 test_cmp expected actual
1405 test_expect_success 'with command but no key' '
1406 git config --unset trailer.sign.key &&
1407 cat >expected <<-EOF &&
1409 sign: A U Thor <author@example.com>
1411 git interpret-trailers >actual <<-EOF &&
1413 test_cmp expected actual
1416 test_expect_success 'with no command and no key' '
1417 git config --unset trailer.review.key &&
1418 cat >expected <<-EOF &&
1420 review: Junio
1421 sign: A U Thor <author@example.com>
1423 git interpret-trailers --trailer "review:Junio" >actual <<-EOF &&
1425 test_cmp expected actual
1428 test_expect_success 'with cut line' '
1429 cat >expected <<-\EOF &&
1430 my subject
1432 review: Brian
1433 sign: A U Thor <author@example.com>
1434 # ------------------------ >8 ------------------------
1435 ignore this
1437 git interpret-trailers --trailer review:Brian >actual <<-\EOF &&
1438 my subject
1439 # ------------------------ >8 ------------------------
1440 ignore this
1442 test_cmp expected actual
1445 test_expect_success 'only trailers' '
1446 git config trailer.sign.command "echo config-value" &&
1447 cat >expected <<-\EOF &&
1448 existing: existing-value
1449 sign: config-value
1450 added: added-value
1452 git interpret-trailers \
1453 --trailer added:added-value \
1454 --only-trailers >actual <<-\EOF &&
1455 my subject
1457 my body
1459 existing: existing-value
1461 test_cmp expected actual
1464 test_expect_success 'only-trailers omits non-trailer in middle of block' '
1465 git config trailer.sign.command "echo config-value" &&
1466 cat >expected <<-\EOF &&
1467 Signed-off-by: nobody <nobody@nowhere>
1468 Signed-off-by: somebody <somebody@somewhere>
1469 sign: config-value
1471 git interpret-trailers --only-trailers >actual <<-\EOF &&
1472 subject
1474 it is important that the trailers below are signed-off-by
1475 so that they meet the "25% trailers Git knows about" heuristic
1477 Signed-off-by: nobody <nobody@nowhere>
1478 this is not a trailer
1479 Signed-off-by: somebody <somebody@somewhere>
1481 test_cmp expected actual
1484 test_expect_success 'only input' '
1485 git config trailer.sign.command "echo config-value" &&
1486 cat >expected <<-\EOF &&
1487 existing: existing-value
1489 git interpret-trailers \
1490 --only-trailers --only-input >actual <<-\EOF &&
1491 my subject
1493 my body
1495 existing: existing-value
1497 test_cmp expected actual
1500 test_expect_success 'unfold' '
1501 cat >expected <<-\EOF &&
1502 foo: continued across several lines
1504 # pass through tr to make leading and trailing whitespace more obvious
1505 tr _ " " <<-\EOF |
1506 my subject
1508 my body
1510 foo:_
1511 __continued
1512 ___across
1513 ____several
1514 _____lines
1517 git interpret-trailers --only-trailers --only-input --unfold >actual &&
1518 test_cmp expected actual
1521 test_expect_success 'handling of --- lines in input' '
1522 echo "real-trailer: just right" >expected &&
1524 git interpret-trailers --parse >actual <<-\EOF &&
1525 subject
1527 body
1529 not-a-trailer: too soon
1530 ------ this is just a line in the commit message with a bunch of
1531 ------ dashes; it does not have any syntactic meaning.
1533 real-trailer: just right
1535 below the dashed line may be a patch, etc.
1537 not-a-trailer: too late
1540 test_cmp expected actual
1543 test_expect_success 'suppress --- handling' '
1544 echo "real-trailer: just right" >expected &&
1546 git interpret-trailers --parse --no-divider >actual <<-\EOF &&
1547 subject
1549 This commit message has a "---" in it, but because we tell
1550 interpret-trailers not to respect that, it has no effect.
1552 not-a-trailer: too soon
1555 This is still the commit message body.
1557 real-trailer: just right
1560 test_cmp expected actual
1563 test_expect_success 'suppressing --- does not disable cut-line handling' '
1564 echo "real-trailer: before the cut" >expected &&
1566 git interpret-trailers --parse --no-divider >actual <<-\EOF &&
1567 subject
1569 This input has a cut-line in it; we should stop parsing when we see it
1570 and consider only trailers before that line.
1572 real-trailer: before the cut
1574 # ------------------------ >8 ------------------------
1575 # Nothing below this line counts as part of the commit message.
1576 not-a-trailer: too late
1579 test_cmp expected actual
1582 test_done