t4014: more tests about appending s-o-b lines

[bc: Squash the tests from Duy's original unify-appending-sob series. Fix test 90 "signoff: some random signoff-alike" and mark as failing. Correct behavior should insert a blank line after message body and signed-off-by. Add two additional tests: 1. failure to detect non-conforming elements in the footer when last line matches committer's s-o-b. 2. ensure various s-o-b -like elements in the footer are handled as conforming. e.g. "Change-id: IXXXX or Bug: 1234" ] Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Brandon Casey <bcasey@nvidia.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Feb 12, 2013 at 02:17 UTC 79133a66f79e70dab88f9f0558dd029bf02f2ac9
1 file changed +241
t/t4014-format-patch.sh
+241
@@ -963,4 +963,245 @@ test_expect_success 'format patch ignores color.ui' '
963 test_cmp expect actual
964 '
965
966 +append_signoff()
967 +{
968 + C=$(git commit-tree HEAD^^{tree} -p HEAD) &&
969 + git format-patch --stdout --signoff $C^..$C >append_signoff.patch &&
970 + sed -n -e "1,/^---$/p" append_signoff.patch |
971 + egrep -n "^Subject|Sign|^$"
972 +}
973 +
974 +test_expect_success 'signoff: commit with no body' '
975 + append_signoff </dev/null >actual &&
976 + cat <<\EOF | sed "s/EOL$//" >expected &&
977 +4:Subject: [PATCH] EOL
978 +8:
979 +9:Signed-off-by: C O Mitter <committer@example.com>
980 +EOF
981 + test_cmp expected actual
982 +'
983 +
984 +test_expect_success 'signoff: commit with only subject' '
985 + echo subject | append_signoff >actual &&
986 + cat >expected <<\EOF &&
987 +4:Subject: [PATCH] subject
988 +8:
989 +9:Signed-off-by: C O Mitter <committer@example.com>
990 +EOF
991 + test_cmp expected actual
992 +'
993 +
994 +test_expect_success 'signoff: commit with only subject that does not end with NL' '
995 + printf subject | append_signoff >actual &&
996 + cat >expected <<\EOF &&
997 +4:Subject: [PATCH] subject
998 +8:
999 +9:Signed-off-by: C O Mitter <committer@example.com>
1000 +EOF
1001 + test_cmp expected actual
1002 +'
1003 +
1004 +test_expect_success 'signoff: no existing signoffs' '
1005 + append_signoff <<\EOF >actual &&
1006 +subject
1007 +
1008 +body
1009 +EOF
1010 + cat >expected <<\EOF &&
1011 +4:Subject: [PATCH] subject
1012 +8:
1013 +10:
1014 +11:Signed-off-by: C O Mitter <committer@example.com>
1015 +EOF
1016 + test_cmp expected actual
1017 +'
1018 +
1019 +test_expect_success 'signoff: no existing signoffs and no trailing NL' '
1020 + printf "subject\n\nbody" | append_signoff >actual &&
1021 + cat >expected <<\EOF &&
1022 +4:Subject: [PATCH] subject
1023 +8:
1024 +10:
1025 +11:Signed-off-by: C O Mitter <committer@example.com>
1026 +EOF
1027 + test_cmp expected actual
1028 +'
1029 +
1030 +test_expect_success 'signoff: some random signoff' '
1031 + append_signoff <<\EOF >actual &&
1032 +subject
1033 +
1034 +body
1035 +
1036 +Signed-off-by: my@house
1037 +EOF
1038 + cat >expected <<\EOF &&
1039 +4:Subject: [PATCH] subject
1040 +8:
1041 +10:
1042 +11:Signed-off-by: my@house
1043 +12:Signed-off-by: C O Mitter <committer@example.com>
1044 +EOF
1045 + test_cmp expected actual
1046 +'
1047 +
1048 +test_expect_failure 'signoff: some random signoff-alike' '
1049 + append_signoff <<\EOF >actual &&
1050 +subject
1051 +
1052 +body
1053 +Fooled-by-me: my@house
1054 +EOF
1055 + cat >expected <<\EOF &&
1056 +4:Subject: [PATCH] subject
1057 +8:
1058 +11:
1059 +12:Signed-off-by: C O Mitter <committer@example.com>
1060 +EOF
1061 + test_cmp expected actual
1062 +'
1063 +
1064 +test_expect_failure 'signoff: not really a signoff' '
1065 + append_signoff <<\EOF >actual &&
1066 +subject
1067 +
1068 +I want to mention about Signed-off-by: here.
1069 +EOF
1070 + cat >expected <<\EOF &&
1071 +4:Subject: [PATCH] subject
1072 +8:
1073 +9:I want to mention about Signed-off-by: here.
1074 +10:
1075 +11:Signed-off-by: C O Mitter <committer@example.com>
1076 +EOF
1077 + test_cmp expected actual
1078 +'
1079 +
1080 +test_expect_failure 'signoff: not really a signoff (2)' '
1081 + append_signoff <<\EOF >actual &&
1082 +subject
1083 +
1084 +My unfortunate
1085 +Signed-off-by: example happens to be wrapped here.
1086 +EOF
1087 + cat >expected <<\EOF &&
1088 +4:Subject: [PATCH] subject
1089 +8:
1090 +10:Signed-off-by: example happens to be wrapped here.
1091 +11:
1092 +12:Signed-off-by: C O Mitter <committer@example.com>
1093 +EOF
1094 + test_cmp expected actual
1095 +'
1096 +
1097 +test_expect_failure 'signoff: valid S-o-b paragraph in the middle' '
1098 + append_signoff <<\EOF >actual &&
1099 +subject
1100 +
1101 +Signed-off-by: my@house
1102 +Signed-off-by: your@house
1103 +
1104 +A lot of houses.
1105 +EOF
1106 + cat >expected <<\EOF &&
1107 +4:Subject: [PATCH] subject
1108 +8:
1109 +9:Signed-off-by: my@house
1110 +10:Signed-off-by: your@house
1111 +11:
1112 +13:
1113 +14:Signed-off-by: C O Mitter <committer@example.com>
1114 +EOF
1115 + test_cmp expected actual
1116 +'
1117 +
1118 +test_expect_success 'signoff: the same signoff at the end' '
1119 + append_signoff <<\EOF >actual &&
1120 +subject
1121 +
1122 +body
1123 +
1124 +Signed-off-by: C O Mitter <committer@example.com>
1125 +EOF
1126 + cat >expected <<\EOF &&
1127 +4:Subject: [PATCH] subject
1128 +8:
1129 +10:
1130 +11:Signed-off-by: C O Mitter <committer@example.com>
1131 +EOF
1132 + test_cmp expected actual
1133 +'
1134 +
1135 +test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
1136 + printf "subject\n\nSigned-off-by: C O Mitter <committer@example.com>" |
1137 + append_signoff >actual &&
1138 + cat >expected <<\EOF &&
1139 +4:Subject: [PATCH] subject
1140 +8:
1141 +9:Signed-off-by: C O Mitter <committer@example.com>
1142 +EOF
1143 + test_cmp expected actual
1144 +'
1145 +
1146 +test_expect_success 'signoff: the same signoff NOT at the end' '
1147 + append_signoff <<\EOF >actual &&
1148 +subject
1149 +
1150 +body
1151 +
1152 +Signed-off-by: C O Mitter <committer@example.com>
1153 +Signed-off-by: my@house
1154 +EOF
1155 + cat >expected <<\EOF &&
1156 +4:Subject: [PATCH] subject
1157 +8:
1158 +10:
1159 +11:Signed-off-by: C O Mitter <committer@example.com>
1160 +12:Signed-off-by: my@house
1161 +EOF
1162 + test_cmp expected actual
1163 +'
1164 +
1165 +test_expect_failure 'signoff: detect garbage in non-conforming footer' '
1166 + append_signoff <<\EOF >actual &&
1167 +subject
1168 +
1169 +body
1170 +
1171 +Tested-by: my@house
1172 +Some Trash
1173 +Signed-off-by: C O Mitter <committer@example.com>
1174 +EOF
1175 + cat >expected <<\EOF &&
1176 +4:Subject: [PATCH] subject
1177 +8:
1178 +10:
1179 +13:Signed-off-by: C O Mitter <committer@example.com>
1180 +14:
1181 +15:Signed-off-by: C O Mitter <committer@example.com>
1182 +EOF
1183 + test_cmp expected actual
1184 +'
1185 +
1186 +test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
1187 + append_signoff <<\EOF >actual &&
1188 +subject
1189 +
1190 +body
1191 +
1192 +Reviewed-id: Noone
1193 +Tested-by: my@house
1194 +Change-id: Ideadbeef
1195 +Signed-off-by: C O Mitter <committer@example.com>
1196 +Bug: 1234
1197 +EOF
1198 + cat >expected <<\EOF &&
1199 +4:Subject: [PATCH] subject
1200 +8:
1201 +10:
1202 +14:Signed-off-by: C O Mitter <committer@example.com>
1203 +EOF
1204 + test_cmp expected actual
1205 +'
1206 +
1207 test_done