@@ -837,6 +837,24 @@ test_trailer_option '%(trailers:only) shows only "key: value" trailers' \
837
837
838
838
EOF
839
839
840
+ test_trailer_option ' %(trailers:only=no,only=true) shows only "key: value" trailers' \
841
+ ' trailers:only=no,only=true' << -EOF
842
+ $( grep -v patch.description < trailers)
843
+
844
+ EOF
845
+
846
+ test_trailer_option ' %(trailers:only=yes) shows only "key: value" trailers' \
847
+ ' trailers:only=yes' << -EOF
848
+ $( grep -v patch.description < trailers)
849
+
850
+ EOF
851
+
852
+ test_trailer_option ' %(trailers:only=no) shows all trailers' \
853
+ ' trailers:only=no' << -EOF
854
+ $( cat trailers)
855
+
856
+ EOF
857
+
840
858
test_trailer_option ' %(trailers:only) and %(trailers:unfold) work together' \
841
859
' trailers:only,unfold' << -EOF
842
860
$( grep -v patch.description < trailers | unfold)
@@ -849,6 +867,78 @@ test_trailer_option '%(trailers:unfold) and %(trailers:only) work together' \
849
867
850
868
EOF
851
869
870
+ test_trailer_option ' %(trailers:key=foo) shows that trailer' \
871
+ ' trailers:key=Signed-off-by' << -EOF
872
+ Signed-off-by: A U Thor <[email protected] >
873
+
874
+ EOF
875
+
876
+ test_trailer_option ' %(trailers:key=foo) is case insensitive' \
877
+ ' trailers:key=SiGned-oFf-bY' << -EOF
878
+ Signed-off-by: A U Thor <[email protected] >
879
+
880
+ EOF
881
+
882
+ test_trailer_option ' %(trailers:key=foo:) trailing colon also works' \
883
+ ' trailers:key=Signed-off-by:' << -EOF
884
+ Signed-off-by: A U Thor <[email protected] >
885
+
886
+ EOF
887
+
888
+ test_trailer_option ' %(trailers:key=foo) multiple keys' \
889
+ ' trailers:key=Reviewed-by:,key=Signed-off-by' << -EOF
890
+ Reviewed-by: A U Thor <[email protected] >
891
+ Signed-off-by: A U Thor <[email protected] >
892
+
893
+ EOF
894
+
895
+ test_trailer_option ' %(trailers:key=nonexistent) becomes empty' \
896
+ ' trailers:key=Shined-off-by:' << -EOF
897
+
898
+ EOF
899
+
900
+ test_trailer_option ' %(trailers:key=foo) handles multiple lines even if folded' \
901
+ ' trailers:key=Acked-by' << -EOF
902
+ $( grep -v patch.description < trailers | grep -v Signed-off-by | grep -v Reviewed-by)
903
+
904
+ EOF
905
+
906
+ test_trailer_option ' %(trailers:key=foo,unfold) properly unfolds' \
907
+ ' trailers:key=Signed-Off-by,unfold' << -EOF
908
+ $( unfold < trailers | grep Signed-off-by)
909
+
910
+ EOF
911
+
912
+ test_trailer_option ' %(trailers:key=foo,only=no) also includes nontrailer lines' \
913
+ ' trailers:key=Signed-off-by,only=no' << -EOF
914
+ Signed-off-by: A U Thor <[email protected] >
915
+ $( grep patch.description < trailers)
916
+
917
+ EOF
918
+
919
+ test_trailer_option ' %(trailers:key=foo,valueonly) shows only value' \
920
+ ' trailers:key=Signed-off-by,valueonly' << -EOF
921
+
922
+
923
+ EOF
924
+
925
+ test_trailer_option ' %(trailers:separator) changes separator' \
926
+ ' trailers:separator=%x2C,key=Reviewed-by,key=Signed-off-by:' << -EOF
927
+ Reviewed-by: A U Thor <[email protected] >,Signed-off-by: A U Thor <[email protected] >
928
+ EOF
929
+
930
+ test_trailer_option ' %(trailers:key_value_separator) changes key-value separator' \
931
+ ' trailers:key_value_separator=%x2C,key=Reviewed-by,key=Signed-off-by:' << -EOF
932
+ Reviewed-by,A U Thor <[email protected] >
933
+ Signed-off-by,A U Thor <[email protected] >
934
+
935
+ EOF
936
+
937
+ test_trailer_option ' %(trailers:separator,key_value_separator) changes both separators' \
938
+ ' trailers:separator=%x2C,key_value_separator=%x2C,key=Reviewed-by,key=Signed-off-by:' << -EOF
939
+ Reviewed-by,A U Thor <[email protected] >,Signed-off-by,A U Thor <[email protected] >
940
+ EOF
941
+
852
942
test_failing_trailer_option () {
853
943
title=$1 option=$2
854
944
cat > expect
@@ -866,6 +956,11 @@ test_failing_trailer_option '%(trailers) rejects unknown trailers arguments' \
866
956
fatal: unknown %(trailers) argument: unsupported
867
957
EOF
868
958
959
+ test_failing_trailer_option ' %(trailers:key) without value is error' \
960
+ ' trailers:key' << -\EOF
961
+ fatal: expected %(trailers:key=<value>)
962
+ EOF
963
+
869
964
test_expect_success ' if arguments, %(contents:trailers) shows error if colon is missing' '
870
965
cat >expect <<-EOF &&
871
966
fatal: unrecognized %(contents) argument: trailersonly
0 commit comments