@@ -605,6 +605,12 @@ test_expect_success 'pretty format %(trailers) shows trailers' '
605
605
test_cmp expect actual
606
606
'
607
607
608
+ test_expect_success ' pretty format %(trailers:) enables no options' '
609
+ git log --no-walk --pretty="%(trailers:)" >actual &&
610
+ # "expect" the same as the test above
611
+ test_cmp expect actual
612
+ '
613
+
608
614
test_expect_success ' %(trailers:only) shows only "key: value" trailers' '
609
615
git log --no-walk --pretty="%(trailers:only)" >actual &&
610
616
{
@@ -709,19 +715,101 @@ test_expect_success '%(trailers:key) without value is error' '
709
715
test_cmp expect actual
710
716
'
711
717
718
+ test_expect_success ' %(trailers:keyonly) shows only keys' '
719
+ git log --no-walk --pretty="format:%(trailers:keyonly)" >actual &&
720
+ test_write_lines \
721
+ "Signed-off-by" \
722
+ "Acked-by" \
723
+ "[ v2 updated patch description ]" \
724
+ "Signed-off-by" >expect &&
725
+ test_cmp expect actual
726
+ '
727
+
728
+ test_expect_success ' %(trailers:key=foo,keyonly) shows only key' '
729
+ git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly)" >actual &&
730
+ echo "Acked-by" >expect &&
731
+ test_cmp expect actual
732
+ '
733
+
712
734
test_expect_success ' %(trailers:key=foo,valueonly) shows only value' '
713
735
git log --no-walk --pretty="format:%(trailers:key=Acked-by,valueonly)" >actual &&
714
736
echo "A U Thor <[email protected] >" >expect &&
715
737
test_cmp expect actual
716
738
'
717
739
740
+ test_expect_success ' %(trailers:valueonly) shows only values' '
741
+ git log --no-walk --pretty="format:%(trailers:valueonly)" >actual &&
742
+ test_write_lines \
743
+
744
+
745
+ "[ v2 updated patch description ]" \
746
+ "A U Thor" \
747
+
748
+ test_cmp expect actual
749
+ '
750
+
751
+ test_expect_success ' %(trailers:key=foo,keyonly,valueonly) shows nothing' '
752
+ git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly,valueonly)" >actual &&
753
+ echo >expect &&
754
+ test_cmp expect actual
755
+ '
756
+
718
757
test_expect_success ' pretty format %(trailers:separator) changes separator' '
758
+ git log --no-walk --pretty=format:"X%(trailers:separator=%x00)X" >actual &&
759
+ (
760
+ printf "XSigned-off-by: A U Thor <[email protected] >\0" &&
761
+ printf "Acked-by: A U Thor <[email protected] >\0" &&
762
+ printf "[ v2 updated patch description ]\0" &&
763
+ printf "Signed-off-by: A U Thor\n <[email protected] >X"
764
+ ) >expect &&
765
+ test_cmp expect actual
766
+ '
767
+
768
+ test_expect_success ' pretty format %(trailers:separator=X,unfold) changes separator' '
719
769
git log --no-walk --pretty=format:"X%(trailers:separator=%x00,unfold)X" >actual &&
720
- printf "XSigned-off-by: A U Thor <[email protected] >\0Acked-by: A U Thor <[email protected] >\0[ v2 updated patch description ]\0Signed-off-by: A U Thor <[email protected] >X" >expect &&
770
+ (
771
+ printf "XSigned-off-by: A U Thor <[email protected] >\0" &&
772
+ printf "Acked-by: A U Thor <[email protected] >\0" &&
773
+ printf "[ v2 updated patch description ]\0" &&
774
+ printf "Signed-off-by: A U Thor <[email protected] >X"
775
+ ) >expect &&
776
+ test_cmp expect actual
777
+ '
778
+
779
+ test_expect_success ' pretty format %(trailers:key_value_separator) changes key-value separator' '
780
+ git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00)X" >actual &&
781
+ (
782
+ printf "XSigned-off-by\0A U Thor <[email protected] >\n" &&
783
+ printf "Acked-by\0A U Thor <[email protected] >\n" &&
784
+ printf "[ v2 updated patch description ]\n" &&
785
+ printf "Signed-off-by\0A U Thor\n <[email protected] >\nX"
786
+ ) >expect &&
787
+ test_cmp expect actual
788
+ '
789
+
790
+ test_expect_success ' pretty format %(trailers:key_value_separator,unfold) changes key-value separator' '
791
+ git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00,unfold)X" >actual &&
792
+ (
793
+ printf "XSigned-off-by\0A U Thor <[email protected] >\n" &&
794
+ printf "Acked-by\0A U Thor <[email protected] >\n" &&
795
+ printf "[ v2 updated patch description ]\n" &&
796
+ printf "Signed-off-by\0A U Thor <[email protected] >\nX"
797
+ ) >expect &&
798
+ test_cmp expect actual
799
+ '
800
+
801
+ test_expect_success ' pretty format %(trailers:separator,key_value_separator) changes both separators' '
802
+ git log --no-walk --pretty=format:"%(trailers:separator=%x00,key_value_separator=%x00%x00,unfold)" >actual &&
803
+ (
804
+ printf "Signed-off-by\0\0A U Thor <[email protected] >\0" &&
805
+ printf "Acked-by\0\0A U Thor <[email protected] >\0" &&
806
+ printf "[ v2 updated patch description ]\0" &&
807
+ printf "Signed-off-by\0\0A U Thor <[email protected] >"
808
+ ) >expect &&
721
809
test_cmp expect actual
722
810
'
723
811
724
- test_expect_success ' pretty format %(trailers) combining separator/key/valueonly' '
812
+ test_expect_success ' pretty format %(trailers) combining separator/key/keyonly/ valueonly' '
725
813
git commit --allow-empty -F - <<-\EOF &&
726
814
Important fix
727
815
@@ -748,6 +836,13 @@ test_expect_success 'pretty format %(trailers) combining separator/key/valueonly
748
836
"Does not close any tickets" \
749
837
"Another fix #567, #890" \
750
838
"Important fix #1234" >expect &&
839
+ test_cmp expect actual &&
840
+
841
+ git log --pretty="%s% (trailers:separator=%x2c%x20,key=Closes,keyonly)" HEAD~3.. >actual &&
842
+ test_write_lines \
843
+ "Does not close any tickets" \
844
+ "Another fix Closes, Closes" \
845
+ "Important fix Closes" >expect &&
751
846
test_cmp expect actual
752
847
'
753
848
0 commit comments