doc: gitrevisions - clarify 'latter case' is revision walk
[git/git-svn.git] / t / t7513-interpret-trailers.sh
blob322c436a494c14a7350d6fdd85efbfbc5a7a8d28
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 'without config' '
55 sed -e "s/ Z\$/ /" >expected <<-\EOF &&
57 ack: Peff
58 Reviewed-by: Z
59 Acked-by: Johan
60 EOF
61 git interpret-trailers --trailer "ack = Peff" --trailer "Reviewed-by" \
62 --trailer "Acked-by: Johan" empty >actual &&
63 test_cmp expected actual
66 test_expect_success 'without config in another order' '
67 sed -e "s/ Z\$/ /" >expected <<-\EOF &&
69 Acked-by: Johan
70 Reviewed-by: Z
71 ack: Peff
72 EOF
73 git interpret-trailers --trailer "Acked-by: Johan" --trailer "Reviewed-by" \
74 --trailer "ack = Peff" empty >actual &&
75 test_cmp expected actual
78 test_expect_success '--trim-empty without config' '
79 cat >expected <<-\EOF &&
81 ack: Peff
82 Acked-by: Johan
83 EOF
84 git interpret-trailers --trim-empty --trailer ack=Peff \
85 --trailer "Reviewed-by" --trailer "Acked-by: Johan" \
86 --trailer "sob:" empty >actual &&
87 test_cmp expected actual
90 test_expect_success 'with config option on the command line' '
91 cat >expected <<-\EOF &&
93 Acked-by: Johan
94 Reviewed-by: Peff
95 EOF
96 { echo; echo "Acked-by: Johan"; } |
97 git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \
98 --trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual &&
99 test_cmp expected actual
102 test_expect_success 'with only a title in the message' '
103 cat >expected <<-\EOF &&
104 area: change
106 Reviewed-by: Peff
107 Acked-by: Johan
109 echo "area: change" |
110 git interpret-trailers --trailer "Reviewed-by: Peff" \
111 --trailer "Acked-by: Johan" >actual &&
112 test_cmp expected actual
115 test_expect_success 'with multiline title in the message' '
116 cat >expected <<-\EOF &&
117 place of
118 code: change
120 Reviewed-by: Peff
121 Acked-by: Johan
123 printf "%s\n" "place of" "code: change" |
124 git interpret-trailers --trailer "Reviewed-by: Peff" \
125 --trailer "Acked-by: Johan" >actual &&
126 test_cmp expected actual
129 test_expect_success 'with config setup' '
130 git config trailer.ack.key "Acked-by: " &&
131 cat >expected <<-\EOF &&
133 Acked-by: Peff
135 git interpret-trailers --trim-empty --trailer "ack = Peff" empty >actual &&
136 test_cmp expected actual &&
137 git interpret-trailers --trim-empty --trailer "Acked-by = Peff" empty >actual &&
138 test_cmp expected actual &&
139 git interpret-trailers --trim-empty --trailer "Acked-by :Peff" empty >actual &&
140 test_cmp expected actual
143 test_expect_success 'with config setup and ":=" as separators' '
144 git config trailer.separators ":=" &&
145 git config trailer.ack.key "Acked-by= " &&
146 cat >expected <<-\EOF &&
148 Acked-by= Peff
150 git interpret-trailers --trim-empty --trailer "ack = Peff" empty >actual &&
151 test_cmp expected actual &&
152 git interpret-trailers --trim-empty --trailer "Acked-by= Peff" empty >actual &&
153 test_cmp expected actual &&
154 git interpret-trailers --trim-empty --trailer "Acked-by : Peff" empty >actual &&
155 test_cmp expected actual
158 test_expect_success 'with config setup and "%" as separators' '
159 git config trailer.separators "%" &&
160 cat >expected <<-\EOF &&
162 bug% 42
163 count% 10
164 bug% 422
166 git interpret-trailers --trim-empty --trailer "bug = 42" \
167 --trailer count%10 --trailer "test: stuff" \
168 --trailer "bug % 422" empty >actual &&
169 test_cmp expected actual
172 test_expect_success 'with "%" as separators and a message with trailers' '
173 cat >special_message <<-\EOF &&
174 Special Message
176 bug% 42
177 count% 10
178 bug% 422
180 cat >expected <<-\EOF &&
181 Special Message
183 bug% 42
184 count% 10
185 bug% 422
186 count% 100
188 git interpret-trailers --trailer count%100 \
189 special_message >actual &&
190 test_cmp expected actual
193 test_expect_success 'with config setup and ":=#" as separators' '
194 git config trailer.separators ":=#" &&
195 git config trailer.bug.key "Bug #" &&
196 cat >expected <<-\EOF &&
198 Bug #42
200 git interpret-trailers --trim-empty --trailer "bug = 42" empty >actual &&
201 test_cmp expected actual
204 test_expect_success 'with commit basic message' '
205 cat basic_message >expected &&
206 echo >>expected &&
207 git interpret-trailers <basic_message >actual &&
208 test_cmp expected actual
211 test_expect_success 'with basic patch' '
212 cat basic_message >input &&
213 cat basic_patch >>input &&
214 cat basic_message >expected &&
215 echo >>expected &&
216 cat basic_patch >>expected &&
217 git interpret-trailers <input >actual &&
218 test_cmp expected actual
221 test_expect_success 'with commit complex message as argument' '
222 cat complex_message_body complex_message_trailers >complex_message &&
223 cat complex_message_body >expected &&
224 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
225 Fixes: Z
226 Acked-by= Z
227 Reviewed-by: Z
228 Signed-off-by: Z
230 git interpret-trailers complex_message >actual &&
231 test_cmp expected actual
234 test_expect_success 'with 2 files arguments' '
235 cat basic_message >>expected &&
236 echo >>expected &&
237 cat basic_patch >>expected &&
238 git interpret-trailers complex_message input >actual &&
239 test_cmp expected actual
242 test_expect_success 'with message that has comments' '
243 cat basic_message >message_with_comments &&
244 sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF &&
245 # comment
247 # other comment
248 Cc: Z
249 # yet another comment
250 Reviewed-by: Johan
251 Reviewed-by: Z
252 # last comment
255 cat basic_patch >>message_with_comments &&
256 cat basic_message >expected &&
257 cat >>expected <<-\EOF &&
258 # comment
260 Reviewed-by: Johan
261 Cc: Peff
262 # last comment
265 cat basic_patch >>expected &&
266 git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual &&
267 test_cmp expected actual
270 test_expect_success 'with message that has an old style conflict block' '
271 cat basic_message >message_with_comments &&
272 sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF &&
273 # comment
275 # other comment
276 Cc: Z
277 # yet another comment
278 Reviewed-by: Johan
279 Reviewed-by: Z
280 # last comment
282 Conflicts:
285 cat basic_message >expected &&
286 cat >>expected <<-\EOF &&
287 # comment
289 Reviewed-by: Johan
290 Cc: Peff
291 # last comment
293 Conflicts:
296 git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual &&
297 test_cmp expected actual
300 test_expect_success 'with commit complex message and trailer args' '
301 cat complex_message_body >expected &&
302 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
303 Fixes: Z
304 Acked-by= Z
305 Reviewed-by: Z
306 Signed-off-by: Z
307 Acked-by= Peff
308 Bug #42
310 git interpret-trailers --trailer "ack: Peff" \
311 --trailer "bug: 42" <complex_message >actual &&
312 test_cmp expected actual
315 test_expect_success 'with complex patch, args and --trim-empty' '
316 cat complex_message >complex_patch &&
317 cat basic_patch >>complex_patch &&
318 cat complex_message_body >expected &&
319 cat >>expected <<-\EOF &&
320 Acked-by= Peff
321 Bug #42
323 cat basic_patch >>expected &&
324 git interpret-trailers --trim-empty --trailer "ack: Peff" \
325 --trailer "bug: 42" <complex_patch >actual &&
326 test_cmp expected actual
329 test_expect_success 'using "where = before"' '
330 git config trailer.bug.where "before" &&
331 cat complex_message_body >expected &&
332 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
333 Bug #42
334 Fixes: Z
335 Acked-by= Z
336 Reviewed-by: Z
337 Signed-off-by: Z
338 Acked-by= Peff
340 git interpret-trailers --trailer "ack: Peff" \
341 --trailer "bug: 42" complex_message >actual &&
342 test_cmp expected actual
345 test_expect_success 'using "where = after"' '
346 git config trailer.ack.where "after" &&
347 cat complex_message_body >expected &&
348 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
349 Bug #42
350 Fixes: Z
351 Acked-by= Z
352 Acked-by= Peff
353 Reviewed-by: Z
354 Signed-off-by: Z
356 git interpret-trailers --trailer "ack: Peff" \
357 --trailer "bug: 42" complex_message >actual &&
358 test_cmp expected actual
361 test_expect_success 'using "where = end"' '
362 git config trailer.review.key "Reviewed-by" &&
363 git config trailer.review.where "end" &&
364 cat complex_message_body >expected &&
365 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
366 Fixes: Z
367 Acked-by= Z
368 Acked-by= Peff
369 Reviewed-by: Z
370 Signed-off-by: Z
371 Reviewed-by: Junio
372 Reviewed-by: Johannes
374 git interpret-trailers --trailer "ack: Peff" \
375 --trailer "Reviewed-by: Junio" --trailer "Reviewed-by: Johannes" \
376 complex_message >actual &&
377 test_cmp expected actual
380 test_expect_success 'using "where = start"' '
381 git config trailer.review.key "Reviewed-by" &&
382 git config trailer.review.where "start" &&
383 cat complex_message_body >expected &&
384 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
385 Reviewed-by: Johannes
386 Reviewed-by: Junio
387 Fixes: Z
388 Acked-by= Z
389 Acked-by= Peff
390 Reviewed-by: Z
391 Signed-off-by: Z
393 git interpret-trailers --trailer "ack: Peff" \
394 --trailer "Reviewed-by: Junio" --trailer "Reviewed-by: Johannes" \
395 complex_message >actual &&
396 test_cmp expected actual
399 test_expect_success 'using "where = before" for a token in the middle of the message' '
400 git config trailer.review.key "Reviewed-by:" &&
401 git config trailer.review.where "before" &&
402 cat complex_message_body >expected &&
403 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
404 Bug #42
405 Fixes: Z
406 Acked-by= Z
407 Acked-by= Peff
408 Reviewed-by:Johan
409 Reviewed-by:
410 Signed-off-by: Z
412 git interpret-trailers --trailer "ack: Peff" --trailer "bug: 42" \
413 --trailer "review: Johan" <complex_message >actual &&
414 test_cmp expected actual
417 test_expect_success 'using "where = before" and --trim-empty' '
418 cat complex_message_body >expected &&
419 cat >>expected <<-\EOF &&
420 Bug #46
421 Bug #42
422 Acked-by= Peff
423 Reviewed-by:Johan
425 git interpret-trailers --trim-empty --trailer "ack: Peff" \
426 --trailer "bug: 42" --trailer "review: Johan" \
427 --trailer "Bug: 46" <complex_message >actual &&
428 test_cmp expected actual
431 test_expect_success 'the default is "ifExists = addIfDifferentNeighbor"' '
432 cat complex_message_body >expected &&
433 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
434 Bug #42
435 Fixes: Z
436 Acked-by= Z
437 Acked-by= Peff
438 Acked-by= Junio
439 Acked-by= Peff
440 Reviewed-by:
441 Signed-off-by: Z
443 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
444 --trailer "ack: Junio" --trailer "bug: 42" --trailer "ack: Peff" \
445 --trailer "ack: Peff" <complex_message >actual &&
446 test_cmp expected actual
449 test_expect_success 'default "ifExists" is now "addIfDifferent"' '
450 git config trailer.ifexists "addIfDifferent" &&
451 cat complex_message_body >expected &&
452 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
453 Bug #42
454 Fixes: Z
455 Acked-by= Z
456 Acked-by= Peff
457 Acked-by= Junio
458 Reviewed-by:
459 Signed-off-by: Z
461 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
462 --trailer "ack: Junio" --trailer "bug: 42" --trailer "ack: Peff" \
463 --trailer "ack: Peff" <complex_message >actual &&
464 test_cmp expected actual
467 test_expect_success 'using "ifExists = addIfDifferent" with "where = end"' '
468 git config trailer.ack.ifExists "addIfDifferent" &&
469 git config trailer.ack.where "end" &&
470 cat complex_message_body >expected &&
471 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
472 Bug #42
473 Fixes: Z
474 Acked-by= Z
475 Reviewed-by:
476 Signed-off-by: Z
477 Acked-by= Peff
479 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
480 --trailer "bug: 42" --trailer "ack: Peff" \
481 <complex_message >actual &&
482 test_cmp expected actual
485 test_expect_success 'using "ifExists = addIfDifferent" with "where = before"' '
486 git config trailer.ack.ifExists "addIfDifferent" &&
487 git config trailer.ack.where "before" &&
488 cat complex_message_body >expected &&
489 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
490 Bug #42
491 Fixes: Z
492 Acked-by= Peff
493 Acked-by= Z
494 Reviewed-by:
495 Signed-off-by: Z
497 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
498 --trailer "bug: 42" --trailer "ack: Peff" \
499 <complex_message >actual &&
500 test_cmp expected actual
503 test_expect_success 'using "ifExists = addIfDifferentNeighbor" with "where = end"' '
504 git config trailer.ack.ifExists "addIfDifferentNeighbor" &&
505 git config trailer.ack.where "end" &&
506 cat complex_message_body >expected &&
507 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
508 Bug #42
509 Fixes: Z
510 Acked-by= Z
511 Reviewed-by:
512 Signed-off-by: Z
513 Acked-by= Peff
514 Acked-by= Junio
515 Tested-by: Jakub
516 Acked-by= Junio
517 Acked-by= Peff
519 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
520 --trailer "ack: Junio" --trailer "bug: 42" \
521 --trailer "Tested-by: Jakub" --trailer "ack: Junio" \
522 --trailer "ack: Junio" --trailer "ack: Peff" <complex_message >actual &&
523 test_cmp expected actual
526 test_expect_success 'using "ifExists = addIfDifferentNeighbor" with "where = after"' '
527 git config trailer.ack.ifExists "addIfDifferentNeighbor" &&
528 git config trailer.ack.where "after" &&
529 cat complex_message_body >expected &&
530 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
531 Bug #42
532 Fixes: Z
533 Acked-by= Z
534 Acked-by= Peff
535 Acked-by= Junio
536 Acked-by= Peff
537 Reviewed-by:
538 Signed-off-by: Z
539 Tested-by: Jakub
541 git interpret-trailers --trailer "ack: Peff" --trailer "review:" \
542 --trailer "ack: Junio" --trailer "bug: 42" \
543 --trailer "Tested-by: Jakub" --trailer "ack: Junio" \
544 --trailer "ack: Junio" --trailer "ack: Peff" <complex_message >actual &&
545 test_cmp expected actual
548 test_expect_success 'using "ifExists = addIfDifferentNeighbor" and --trim-empty' '
549 git config trailer.ack.ifExists "addIfDifferentNeighbor" &&
550 cat complex_message_body >expected &&
551 cat >>expected <<-\EOF &&
552 Bug #42
553 Acked-by= Peff
554 Acked-by= Junio
555 Acked-by= Peff
557 git interpret-trailers --trim-empty --trailer "ack: Peff" \
558 --trailer "Acked-by= Peff" --trailer "review:" \
559 --trailer "ack: Junio" --trailer "bug: 42" \
560 --trailer "ack: Peff" <complex_message >actual &&
561 test_cmp expected actual
564 test_expect_success 'using "ifExists = add" with "where = end"' '
565 git config trailer.ack.ifExists "add" &&
566 git config trailer.ack.where "end" &&
567 cat complex_message_body >expected &&
568 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
569 Bug #42
570 Fixes: Z
571 Acked-by= Z
572 Reviewed-by:
573 Signed-off-by: Z
574 Acked-by= Peff
575 Acked-by= Peff
576 Tested-by: Jakub
577 Acked-by= Junio
578 Tested-by: Johannes
579 Acked-by= Peff
581 git interpret-trailers --trailer "ack: Peff" \
582 --trailer "Acked-by= Peff" --trailer "review:" \
583 --trailer "Tested-by: Jakub" --trailer "ack: Junio" \
584 --trailer "bug: 42" --trailer "Tested-by: Johannes" \
585 --trailer "ack: Peff" <complex_message >actual &&
586 test_cmp expected actual
589 test_expect_success 'using "ifExists = add" with "where = after"' '
590 git config trailer.ack.ifExists "add" &&
591 git config trailer.ack.where "after" &&
592 cat complex_message_body >expected &&
593 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
594 Bug #42
595 Fixes: Z
596 Acked-by= Z
597 Acked-by= Peff
598 Acked-by= Peff
599 Acked-by= Junio
600 Acked-by= Peff
601 Reviewed-by:
602 Signed-off-by: Z
604 git interpret-trailers --trailer "ack: Peff" \
605 --trailer "Acked-by= Peff" --trailer "review:" \
606 --trailer "ack: Junio" --trailer "bug: 42" \
607 --trailer "ack: Peff" <complex_message >actual &&
608 test_cmp expected actual
611 test_expect_success 'using "ifExists = replace"' '
612 git config trailer.fix.key "Fixes: " &&
613 git config trailer.fix.ifExists "replace" &&
614 cat complex_message_body >expected &&
615 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
616 Bug #42
617 Acked-by= Z
618 Acked-by= Junio
619 Acked-by= Peff
620 Reviewed-by:
621 Signed-off-by: Z
622 Fixes: 22
624 git interpret-trailers --trailer "review:" \
625 --trailer "fix=53" --trailer "ack: Junio" --trailer "fix=22" \
626 --trailer "bug: 42" --trailer "ack: Peff" \
627 <complex_message >actual &&
628 test_cmp expected actual
631 test_expect_success 'using "ifExists = replace" with "where = after"' '
632 git config trailer.fix.where "after" &&
633 cat complex_message_body >expected &&
634 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
635 Bug #42
636 Fixes: 22
637 Acked-by= Z
638 Acked-by= Junio
639 Acked-by= Peff
640 Reviewed-by:
641 Signed-off-by: Z
643 git interpret-trailers --trailer "review:" \
644 --trailer "fix=53" --trailer "ack: Junio" --trailer "fix=22" \
645 --trailer "bug: 42" --trailer "ack: Peff" \
646 <complex_message >actual &&
647 test_cmp expected actual
650 test_expect_success 'using "ifExists = doNothing"' '
651 git config trailer.fix.ifExists "doNothing" &&
652 cat complex_message_body >expected &&
653 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
654 Bug #42
655 Fixes: Z
656 Acked-by= Z
657 Acked-by= Junio
658 Acked-by= Peff
659 Reviewed-by:
660 Signed-off-by: Z
662 git interpret-trailers --trailer "review:" --trailer "fix=53" \
663 --trailer "ack: Junio" --trailer "fix=22" \
664 --trailer "bug: 42" --trailer "ack: Peff" \
665 <complex_message >actual &&
666 test_cmp expected actual
669 test_expect_success 'the default is "ifMissing = add"' '
670 git config trailer.cc.key "Cc: " &&
671 git config trailer.cc.where "before" &&
672 cat complex_message_body >expected &&
673 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
674 Bug #42
675 Cc: Linus
676 Fixes: Z
677 Acked-by= Z
678 Acked-by= Junio
679 Acked-by= Peff
680 Reviewed-by:
681 Signed-off-by: Z
683 git interpret-trailers --trailer "review:" --trailer "fix=53" \
684 --trailer "cc=Linus" --trailer "ack: Junio" \
685 --trailer "fix=22" --trailer "bug: 42" --trailer "ack: Peff" \
686 <complex_message >actual &&
687 test_cmp expected actual
690 test_expect_success 'when default "ifMissing" is "doNothing"' '
691 git config trailer.ifmissing "doNothing" &&
692 cat complex_message_body >expected &&
693 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
694 Fixes: Z
695 Acked-by= Z
696 Acked-by= Junio
697 Acked-by= Peff
698 Reviewed-by:
699 Signed-off-by: Z
701 git interpret-trailers --trailer "review:" --trailer "fix=53" \
702 --trailer "cc=Linus" --trailer "ack: Junio" \
703 --trailer "fix=22" --trailer "bug: 42" --trailer "ack: Peff" \
704 <complex_message >actual &&
705 test_cmp expected actual &&
706 git config trailer.ifmissing "add"
709 test_expect_success 'using "ifMissing = add" with "where = end"' '
710 git config trailer.cc.key "Cc: " &&
711 git config trailer.cc.where "end" &&
712 git config trailer.cc.ifMissing "add" &&
713 cat complex_message_body >expected &&
714 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
715 Bug #42
716 Fixes: Z
717 Acked-by= Z
718 Acked-by= Junio
719 Acked-by= Peff
720 Reviewed-by:
721 Signed-off-by: Z
722 Cc: Linus
724 git interpret-trailers --trailer "review:" --trailer "fix=53" \
725 --trailer "ack: Junio" --trailer "fix=22" \
726 --trailer "bug: 42" --trailer "cc=Linus" --trailer "ack: Peff" \
727 <complex_message >actual &&
728 test_cmp expected actual
731 test_expect_success 'using "ifMissing = add" with "where = before"' '
732 git config trailer.cc.key "Cc: " &&
733 git config trailer.cc.where "before" &&
734 git config trailer.cc.ifMissing "add" &&
735 cat complex_message_body >expected &&
736 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
737 Cc: Linus
738 Bug #42
739 Fixes: Z
740 Acked-by= Z
741 Acked-by= Junio
742 Acked-by= Peff
743 Reviewed-by:
744 Signed-off-by: Z
746 git interpret-trailers --trailer "review:" --trailer "fix=53" \
747 --trailer "ack: Junio" --trailer "fix=22" \
748 --trailer "bug: 42" --trailer "cc=Linus" --trailer "ack: Peff" \
749 <complex_message >actual &&
750 test_cmp expected actual
753 test_expect_success 'using "ifMissing = doNothing"' '
754 git config trailer.cc.ifMissing "doNothing" &&
755 cat complex_message_body >expected &&
756 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
757 Bug #42
758 Fixes: Z
759 Acked-by= Z
760 Acked-by= Junio
761 Acked-by= Peff
762 Reviewed-by:
763 Signed-off-by: Z
765 git interpret-trailers --trailer "review:" --trailer "fix=53" \
766 --trailer "cc=Linus" --trailer "ack: Junio" \
767 --trailer "fix=22" --trailer "bug: 42" --trailer "ack: Peff" \
768 <complex_message >actual &&
769 test_cmp expected actual
772 test_expect_success 'default "where" is now "after"' '
773 git config trailer.where "after" &&
774 git config --unset trailer.ack.where &&
775 cat complex_message_body >expected &&
776 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
777 Bug #42
778 Fixes: Z
779 Acked-by= Z
780 Acked-by= Peff
781 Acked-by= Peff
782 Acked-by= Junio
783 Acked-by= Peff
784 Reviewed-by:
785 Signed-off-by: Z
786 Tested-by: Jakub
787 Tested-by: Johannes
789 git interpret-trailers --trailer "ack: Peff" \
790 --trailer "Acked-by= Peff" --trailer "review:" \
791 --trailer "Tested-by: Jakub" --trailer "ack: Junio" \
792 --trailer "bug: 42" --trailer "Tested-by: Johannes" \
793 --trailer "ack: Peff" <complex_message >actual &&
794 test_cmp expected actual
797 test_expect_success 'with simple command' '
798 git config trailer.sign.key "Signed-off-by: " &&
799 git config trailer.sign.where "after" &&
800 git config trailer.sign.ifExists "addIfDifferentNeighbor" &&
801 git config trailer.sign.command "echo \"A U Thor <author@example.com>\"" &&
802 cat complex_message_body >expected &&
803 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
804 Fixes: Z
805 Acked-by= Z
806 Reviewed-by:
807 Signed-off-by: Z
808 Signed-off-by: A U Thor <author@example.com>
810 git interpret-trailers --trailer "review:" --trailer "fix=22" \
811 <complex_message >actual &&
812 test_cmp expected actual
815 test_expect_success 'with command using commiter information' '
816 git config trailer.sign.ifExists "addIfDifferent" &&
817 git config trailer.sign.command "echo \"\$GIT_COMMITTER_NAME <\$GIT_COMMITTER_EMAIL>\"" &&
818 cat complex_message_body >expected &&
819 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
820 Fixes: Z
821 Acked-by= Z
822 Reviewed-by:
823 Signed-off-by: Z
824 Signed-off-by: C O Mitter <committer@example.com>
826 git interpret-trailers --trailer "review:" --trailer "fix=22" \
827 <complex_message >actual &&
828 test_cmp expected actual
831 test_expect_success 'with command using author information' '
832 git config trailer.sign.key "Signed-off-by: " &&
833 git config trailer.sign.where "after" &&
834 git config trailer.sign.ifExists "addIfDifferentNeighbor" &&
835 git config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
836 cat complex_message_body >expected &&
837 sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
838 Fixes: Z
839 Acked-by= Z
840 Reviewed-by:
841 Signed-off-by: Z
842 Signed-off-by: A U Thor <author@example.com>
844 git interpret-trailers --trailer "review:" --trailer "fix=22" \
845 <complex_message >actual &&
846 test_cmp expected actual
849 test_expect_success 'setup a commit' '
850 echo "Content of the first commit." > a.txt &&
851 git add a.txt &&
852 git commit -m "Add file a.txt"
855 test_expect_success 'with command using $ARG' '
856 git config trailer.fix.ifExists "replace" &&
857 git config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" &&
858 FIXED=$(git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 HEAD) &&
859 cat complex_message_body >expected &&
860 sed -e "s/ Z\$/ /" >>expected <<-EOF &&
861 Fixes: $FIXED
862 Acked-by= Z
863 Reviewed-by:
864 Signed-off-by: Z
865 Signed-off-by: A U Thor <author@example.com>
867 git interpret-trailers --trailer "review:" --trailer "fix=HEAD" \
868 <complex_message >actual &&
869 test_cmp expected actual
872 test_expect_success 'with failing command using $ARG' '
873 git config trailer.fix.ifExists "replace" &&
874 git config trailer.fix.command "false \$ARG" &&
875 cat complex_message_body >expected &&
876 sed -e "s/ Z\$/ /" >>expected <<-EOF &&
877 Fixes: Z
878 Acked-by= Z
879 Reviewed-by:
880 Signed-off-by: Z
881 Signed-off-by: A U Thor <author@example.com>
883 git interpret-trailers --trailer "review:" --trailer "fix=HEAD" \
884 <complex_message >actual &&
885 test_cmp expected actual
888 test_expect_success 'with empty tokens' '
889 git config --unset trailer.fix.command &&
890 cat >expected <<-EOF &&
892 Signed-off-by: A U Thor <author@example.com>
894 git interpret-trailers --trailer ":" --trailer ":test" >actual <<-EOF &&
896 test_cmp expected actual
899 test_expect_success 'with command but no key' '
900 git config --unset trailer.sign.key &&
901 cat >expected <<-EOF &&
903 sign: A U Thor <author@example.com>
905 git interpret-trailers >actual <<-EOF &&
907 test_cmp expected actual
910 test_expect_success 'with no command and no key' '
911 git config --unset trailer.review.key &&
912 cat >expected <<-EOF &&
914 review: Junio
915 sign: A U Thor <author@example.com>
917 git interpret-trailers --trailer "review:Junio" >actual <<-EOF &&
919 test_cmp expected actual
922 test_done