119
120
test_expect_success 'commit did not screw up the log message' '
121
git cat-file commit side >actual &&
122
- grep "^Side .* with .* backslash-n" actual
122
+ test_grep "^Side .* with .* backslash-n" actual
123
'
124
125
test_expect_success 'format-patch did not screw up the log message' '
126
- grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
127
- grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
126
+ test_grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
127
+ test_grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
128
'
129
130
test_expect_success 'replay did not screw up the log message' '
131
git cat-file commit rebuild-1 >actual &&
132
- grep "^Side .* with .* backslash-n" actual
132
+ test_grep "^Side .* with .* backslash-n" actual
133
'
134
135
test_expect_success 'format-patch empty commit' '
145
" &&
146
git format-patch --stdout main..side >patch2 &&
147
sed -e "/^\$/q" patch2 >hdrs2 &&
148
- grep "^To: R E Cipient <rcipient@example.com>\$" hdrs2 &&
149
- grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs2
148
+ test_grep "^To: R E Cipient <rcipient@example.com>\$" hdrs2 &&
149
+ test_grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs2
150
'
151
152
test_expect_success 'extra headers without newlines' '
154
git config --add format.headers "Cc: S E Cipient <scipient@example.com>" &&
155
git format-patch --stdout main..side >patch3 &&
156
sed -e "/^\$/q" patch3 >hdrs3 &&
157
- grep "^To: R E Cipient <rcipient@example.com>\$" hdrs3 &&
158
- grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs3
157
+ test_grep "^To: R E Cipient <rcipient@example.com>\$" hdrs3 &&
158
+ test_grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs3
159
'
160
161
test_expect_success 'extra headers with multiple To:s' '
163
git config --add format.headers "To: S E Cipient <scipient@example.com>" &&
164
git format-patch --stdout main..side >patch4 &&
165
sed -e "/^\$/q" patch4 >hdrs4 &&
166
- grep "^To: R E Cipient <rcipient@example.com>,\$" hdrs4 &&
167
- grep "^ *S E Cipient <scipient@example.com>\$" hdrs4
166
+ test_grep "^To: R E Cipient <rcipient@example.com>,\$" hdrs4 &&
167
+ test_grep "^ *S E Cipient <scipient@example.com>\$" hdrs4
168
'
169
170
test_expect_success 'additional command line cc (ascii)' '
171
git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
172
git format-patch --cc="S E Cipient <scipient@example.com>" --stdout main..side >patch5 &&
173
sed -e "/^\$/q" patch5 >hdrs5 &&
174
- grep "^Cc: R E Cipient <rcipient@example.com>,\$" hdrs5 &&
175
- grep "^ *S E Cipient <scipient@example.com>\$" hdrs5
174
+ test_grep "^Cc: R E Cipient <rcipient@example.com>,\$" hdrs5 &&
175
+ test_grep "^ *S E Cipient <scipient@example.com>\$" hdrs5
176
'
177
178
test_expect_failure 'additional command line cc (rfc822)' '
179
git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
180
git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout main..side >patch5 &&
181
sed -e "/^\$/q" patch5 >hdrs5 &&
182
- grep "^Cc: R E Cipient <rcipient@example.com>,\$" hdrs5 &&
183
- grep "^ *\"S. E. Cipient\" <scipient@example.com>\$" hdrs5
182
+ test_grep "^Cc: R E Cipient <rcipient@example.com>,\$" hdrs5 &&
183
+ test_grep "^ *\"S. E. Cipient\" <scipient@example.com>\$" hdrs5
184
'
185
186
test_expect_success 'command line headers' '
187
git config --unset-all format.headers &&
188
git format-patch --add-header="Cc: R E Cipient <rcipient@example.com>" --stdout main..side >patch6 &&
189
sed -e "/^\$/q" patch6 >hdrs6 &&
190
- grep "^Cc: R E Cipient <rcipient@example.com>\$" hdrs6
190
+ test_grep "^Cc: R E Cipient <rcipient@example.com>\$" hdrs6
191
'
192
193
test_expect_success 'configuration headers and command line headers' '
194
git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
195
git format-patch --add-header="Cc: S E Cipient <scipient@example.com>" --stdout main..side >patch7 &&
196
sed -e "/^\$/q" patch7 >hdrs7 &&
197
- grep "^Cc: R E Cipient <rcipient@example.com>,\$" hdrs7 &&
198
- grep "^ *S E Cipient <scipient@example.com>\$" hdrs7
197
+ test_grep "^Cc: R E Cipient <rcipient@example.com>,\$" hdrs7 &&
198
+ test_grep "^ *S E Cipient <scipient@example.com>\$" hdrs7
199
'
200
201
test_expect_success 'command line To: header (ascii)' '
202
git config --unset-all format.headers &&
203
git format-patch --to="R E Cipient <rcipient@example.com>" --stdout main..side >patch8 &&
204
sed -e "/^\$/q" patch8 >hdrs8 &&
205
- grep "^To: R E Cipient <rcipient@example.com>\$" hdrs8
205
+ test_grep "^To: R E Cipient <rcipient@example.com>\$" hdrs8
206
'
207
208
test_expect_failure 'command line To: header (rfc822)' '
209
git format-patch --to="R. E. Cipient <rcipient@example.com>" --stdout main..side >patch8 &&
210
sed -e "/^\$/q" patch8 >hdrs8 &&
211
- grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" hdrs8
211
+ test_grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" hdrs8
212
'
213
214
test_expect_failure 'command line To: header (rfc2047)' '
215
git format-patch --to="R Ä Cipient <rcipient@example.com>" --stdout main..side >patch8 &&
216
sed -e "/^\$/q" patch8 >hdrs8 &&
217
- grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" hdrs8
217
+ test_grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" hdrs8
218
'
219
220
test_expect_success 'configuration To: header (ascii)' '
221
git config format.to "R E Cipient <rcipient@example.com>" &&
222
git format-patch --stdout main..side >patch9 &&
223
sed -e "/^\$/q" patch9 >hdrs9 &&
224
- grep "^To: R E Cipient <rcipient@example.com>\$" hdrs9
224
+ test_grep "^To: R E Cipient <rcipient@example.com>\$" hdrs9
225
'
226
227
test_expect_failure 'configuration To: header (rfc822)' '
228
git config format.to "R. E. Cipient <rcipient@example.com>" &&
229
git format-patch --stdout main..side >patch9 &&
230
sed -e "/^\$/q" patch9 >hdrs9 &&
231
- grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" hdrs9
231
+ test_grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" hdrs9
232
'
233
234
test_expect_failure 'configuration To: header (rfc2047)' '
235
git config format.to "R Ä Cipient <rcipient@example.com>" &&
236
git format-patch --stdout main..side >patch9 &&
237
sed -e "/^\$/q" patch9 >hdrs9 &&
238
- grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" hdrs9
238
+ test_grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" hdrs9
239
'
240
241
# check_patch <patch>: Verify that <patch> looks like a half-sane
250
git -c format.from=false format-patch --stdout main..side >patch &&
251
sed -e "/^\$/q" patch >hdrs &&
252
check_patch patch &&
253
- ! grep "^From: C O Mitter <committer@example.com>\$" hdrs
253
+ test_grep ! "^From: C O Mitter <committer@example.com>\$" hdrs
254
'
255
256
test_expect_success 'format.from=true' '
257
git -c format.from=true format-patch --stdout main..side >patch &&
258
sed -e "/^\$/q" patch >hdrs &&
259
check_patch hdrs &&
260
- grep "^From: C O Mitter <committer@example.com>\$" hdrs
260
+ test_grep "^From: C O Mitter <committer@example.com>\$" hdrs
261
'
262
263
test_expect_success 'format.from with address' '
264
git -c format.from="F R Om <from@example.com>" format-patch --stdout main..side >patch &&
265
sed -e "/^\$/q" patch >hdrs &&
266
check_patch hdrs &&
267
- grep "^From: F R Om <from@example.com>\$" hdrs
267
+ test_grep "^From: F R Om <from@example.com>\$" hdrs
268
'
269
270
test_expect_success '--no-from overrides format.from' '
271
git -c format.from="F R Om <from@example.com>" format-patch --no-from --stdout main..side >patch &&
272
sed -e "/^\$/q" patch >hdrs &&
273
check_patch hdrs &&
274
- ! grep "^From: F R Om <from@example.com>\$" hdrs
274
+ test_grep ! "^From: F R Om <from@example.com>\$" hdrs
275
'
276
277
test_expect_success '--from overrides format.from' '
278
git -c format.from="F R Om <from@example.com>" format-patch --from --stdout main..side >patch &&
279
sed -e "/^\$/q" patch >hdrs &&
280
check_patch hdrs &&
281
- ! grep "^From: F R Om <from@example.com>\$" hdrs
281
+ test_grep ! "^From: F R Om <from@example.com>\$" hdrs
282
'
283
284
test_expect_success '--no-to overrides config.to' '
287
git format-patch --no-to --stdout main..side >patch10 &&
288
sed -e "/^\$/q" patch10 >hdrs10 &&
289
check_patch hdrs10 &&
290
- ! grep "^To: R E Cipient <rcipient@example.com>\$" hdrs10
290
+ test_grep ! "^To: R E Cipient <rcipient@example.com>\$" hdrs10
291
'
292
293
test_expect_success '--no-to and --to replaces config.to' '
297
--stdout main..side >patch11 &&
298
sed -e "/^\$/q" patch11 >hdrs11 &&
299
check_patch hdrs11 &&
300
- ! grep "^To: Someone <someone@out.there>\$" hdrs11 &&
301
- grep "^To: Someone Else <else@out.there>\$" hdrs11
300
+ test_grep ! "^To: Someone <someone@out.there>\$" hdrs11 &&
301
+ test_grep "^To: Someone Else <else@out.there>\$" hdrs11
302
'
303
304
test_expect_success '--no-cc overrides config.cc' '
307
git format-patch --no-cc --stdout main..side >patch12 &&
308
sed -e "/^\$/q" patch12 >hdrs12 &&
309
check_patch hdrs12 &&
310
- ! grep "^Cc: C E Cipient <rcipient@example.com>\$" hdrs12
310
+ test_grep ! "^Cc: C E Cipient <rcipient@example.com>\$" hdrs12
311
'
312
313
test_expect_success '--no-add-header overrides config.headers' '
316
git format-patch --no-add-header --stdout main..side >patch13 &&
317
sed -e "/^\$/q" patch13 >hdrs13 &&
318
check_patch hdrs13 &&
319
- ! grep "^Header1: B E Cipient <rcipient@example.com>\$" hdrs13
319
+ test_grep ! "^Header1: B E Cipient <rcipient@example.com>\$" hdrs13
320
'
321
322
test_expect_success 'multiple files' '
508
test_expect_success 'reroll count' '
509
rm -fr patches &&
510
git format-patch -o patches --cover-letter --reroll-count 4 main..side >list &&
511
- ! grep -v "^patches/v4-000[0-3]-" list &&
511
+ test_grep ! -v "^patches/v4-000[0-3]-" list &&
512
sed -n -e "/^Subject: /p" $(cat list) >subjects &&
513
- ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects
513
+ test_grep ! -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects
514
'
515
516
test_expect_success 'reroll count (-v)' '
517
rm -fr patches &&
518
git format-patch -o patches --cover-letter -v4 main..side >list &&
519
- ! grep -v "^patches/v4-000[0-3]-" list &&
519
+ test_grep ! -v "^patches/v4-000[0-3]-" list &&
520
sed -n -e "/^Subject: /p" $(cat list) >subjects &&
521
- ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects
521
+ test_grep ! -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects
522
'
523
524
test_expect_success 'reroll count (-v) with a fractional number' '
525
rm -fr patches &&
526
git format-patch -o patches --cover-letter -v4.4 main..side >list &&
527
- ! grep -v "^patches/v4.4-000[0-3]-" list &&
527
+ test_grep ! -v "^patches/v4.4-000[0-3]-" list &&
528
sed -n -e "/^Subject: /p" $(cat list) >subjects &&
529
- ! grep -v "^Subject: \[PATCH v4.4 [0-3]/3\] " subjects
529
+ test_grep ! -v "^Subject: \[PATCH v4.4 [0-3]/3\] " subjects
530
'
531
532
test_expect_success 'reroll (-v) count with a non number' '
533
rm -fr patches &&
534
git format-patch -o patches --cover-letter -v4rev2 main..side >list &&
535
- ! grep -v "^patches/v4rev2-000[0-3]-" list &&
535
+ test_grep ! -v "^patches/v4rev2-000[0-3]-" list &&
536
sed -n -e "/^Subject: /p" $(cat list) >subjects &&
537
- ! grep -v "^Subject: \[PATCH v4rev2 [0-3]/3\] " subjects
537
+ test_grep ! -v "^Subject: \[PATCH v4rev2 [0-3]/3\] " subjects
538
'
539
540
test_expect_success 'reroll (-v) count with a non-pathname character' '
541
rm -fr patches &&
542
git format-patch -o patches --cover-letter -v4---..././../--1/.2// main..side >list &&
543
- ! grep -v "patches/v4-\.-\.-\.-1-\.2-000[0-3]-" list &&
543
+ test_grep ! -v "patches/v4-\.-\.-\.-1-\.2-000[0-3]-" list &&
544
sed -n -e "/^Subject: /p" $(cat list) >subjects &&
545
- ! grep -v "^Subject: \[PATCH v4---\.\.\./\./\.\./--1/\.2// [0-3]/3\] " subjects
545
+ test_grep ! -v "^Subject: \[PATCH v4---\.\.\./\./\.\./--1/\.2// [0-3]/3\] " subjects
546
'
547
548
check_threading () {
813
git commit -m foo &&
814
git format-patch --no-renames --cover-letter -1 &&
815
check_patch 0000-cover-letter.patch &&
816
- ! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
816
+ test_grep ! "file => foo .* 0 *\$" 0000-cover-letter.patch &&
817
git format-patch --cover-letter -1 -M &&
818
- grep "file => foo .* 0 *\$" 0000-cover-letter.patch
818
+ test_grep "file => foo .* 0 *\$" 0000-cover-letter.patch
819
'
820
821
cat >expect <<EOF
924
925
test_expect_success 'format-patch --in-reply-to' '
926
git format-patch -1 --stdout --in-reply-to "baz@foo.bar" >patch8 &&
927
- grep "^In-Reply-To: <baz@foo.bar>" patch8 &&
928
- grep "^References: <baz@foo.bar>" patch8
927
+ test_grep "^In-Reply-To: <baz@foo.bar>" patch8 &&
928
+ test_grep "^References: <baz@foo.bar>" patch8
929
'
930
931
test_expect_success 'format-patch --signoff' '
932
git format-patch -1 --signoff --stdout >out &&
933
- grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" out
933
+ test_grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" out
934
'
935
936
test_expect_success 'format-patch --notes --signoff' '
949
git notes add -m "notes config message" HEAD &&
950
951
git format-patch -1 --stdout >out &&
952
- ! grep "notes config message" out &&
952
+ test_grep ! "notes config message" out &&
953
git format-patch -1 --stdout --notes >out &&
954
- grep "notes config message" out &&
954
+ test_grep "notes config message" out &&
955
git format-patch -1 --stdout --no-notes >out &&
956
- ! grep "notes config message" out &&
956
+ test_grep ! "notes config message" out &&
957
git format-patch -1 --stdout --notes --no-notes >out &&
958
- ! grep "notes config message" out &&
958
+ test_grep ! "notes config message" out &&
959
git format-patch -1 --stdout --no-notes --notes >out &&
960
- grep "notes config message" out &&
960
+ test_grep "notes config message" out &&
961
962
test_config format.notes true &&
963
git format-patch -1 --stdout >out &&
964
- grep "notes config message" out &&
964
+ test_grep "notes config message" out &&
965
git format-patch -1 --stdout --notes >out &&
966
- grep "notes config message" out &&
966
+ test_grep "notes config message" out &&
967
git format-patch -1 --stdout --no-notes >out &&
968
- ! grep "notes config message" out &&
968
+ test_grep ! "notes config message" out &&
969
git format-patch -1 --stdout --notes --no-notes >out &&
970
- ! grep "notes config message" out &&
970
+ test_grep ! "notes config message" out &&
971
git format-patch -1 --stdout --no-notes --notes >out &&
972
- grep "notes config message" out
972
+ test_grep "notes config message" out
973
'
974
975
test_expect_success 'format-patch with multiple notes refs' '
979
git notes --ref note2 add -m "this is note 2" HEAD &&
980
981
git format-patch -1 --stdout >out &&
982
- ! grep "this is note 1" out &&
983
- ! grep "this is note 2" out &&
982
+ test_grep ! "this is note 1" out &&
983
+ test_grep ! "this is note 2" out &&
984
git format-patch -1 --stdout --notes=note1 >out &&
985
- grep "this is note 1" out &&
986
- ! grep "this is note 2" out &&
985
+ test_grep "this is note 1" out &&
986
+ test_grep ! "this is note 2" out &&
987
git format-patch -1 --stdout --notes=note2 >out &&
988
- ! grep "this is note 1" out &&
989
- grep "this is note 2" out &&
988
+ test_grep ! "this is note 1" out &&
989
+ test_grep "this is note 2" out &&
990
git format-patch -1 --stdout --notes=note1 --notes=note2 >out &&
991
- grep "this is note 1" out &&
992
- grep "this is note 2" out &&
991
+ test_grep "this is note 1" out &&
992
+ test_grep "this is note 2" out &&
993
994
test_config format.notes note1 &&
995
git format-patch -1 --stdout >out &&
996
- grep "this is note 1" out &&
997
- ! grep "this is note 2" out &&
996
+ test_grep "this is note 1" out &&
997
+ test_grep ! "this is note 2" out &&
998
git format-patch -1 --stdout --no-notes >out &&
999
- ! grep "this is note 1" out &&
1000
- ! grep "this is note 2" out &&
999
+ test_grep ! "this is note 1" out &&
1000
+ test_grep ! "this is note 2" out &&
1001
git format-patch -1 --stdout --notes=note2 >out &&
1002
- grep "this is note 1" out &&
1003
- grep "this is note 2" out &&
1002
+ test_grep "this is note 1" out &&
1003
+ test_grep "this is note 2" out &&
1004
git format-patch -1 --stdout --no-notes --notes=note2 >out &&
1005
- ! grep "this is note 1" out &&
1006
- grep "this is note 2" out &&
1005
+ test_grep ! "this is note 1" out &&
1006
+ test_grep "this is note 2" out &&
1007
1008
git config --add format.notes note2 &&
1009
git format-patch -1 --stdout >out &&
1010
- grep "this is note 1" out &&
1011
- grep "this is note 2" out &&
1010
+ test_grep "this is note 1" out &&
1011
+ test_grep "this is note 2" out &&
1012
git format-patch -1 --stdout --no-notes >out &&
1013
- ! grep "this is note 1" out &&
1014
- ! grep "this is note 2" out
1013
+ test_grep ! "this is note 1" out &&
1014
+ test_grep ! "this is note 2" out
1015
'
1016
1017
test_expect_success 'format-patch with multiple notes refs in config' '
1024
1025
git config format.notes note1 &&
1026
git format-patch -1 --stdout >out &&
1027
- grep "this is note 1" out &&
1028
- ! grep "this is note 2" out &&
1027
+ test_grep "this is note 1" out &&
1028
+ test_grep ! "this is note 2" out &&
1029
git config format.notes note2 &&
1030
git format-patch -1 --stdout >out &&
1031
- ! grep "this is note 1" out &&
1032
- grep "this is note 2" out &&
1031
+ test_grep ! "this is note 1" out &&
1032
+ test_grep "this is note 2" out &&
1033
git config --add format.notes note1 &&
1034
git format-patch -1 --stdout >out &&
1035
- grep "this is note 1" out &&
1036
- grep "this is note 2" out &&
1035
+ test_grep "this is note 1" out &&
1036
+ test_grep "this is note 2" out &&
1037
1038
git config --replace-all format.notes note1 &&
1039
git config --add format.notes false &&
1040
git format-patch -1 --stdout >out &&
1041
- ! grep "this is note 1" out &&
1042
- ! grep "this is note 2" out &&
1041
+ test_grep ! "this is note 1" out &&
1042
+ test_grep ! "this is note 2" out &&
1043
git config --add format.notes note2 &&
1044
git format-patch -1 --stdout >out &&
1045
- ! grep "this is note 1" out &&
1046
- grep "this is note 2" out
1045
+ test_grep ! "this is note 1" out &&
1046
+ test_grep "this is note 2" out
1047
'
1048
1049
echo "fatal: --name-only does not make sense" >expect.name-only
1095
1096
git format-patch main..pathspec -- file_a >output &&
1097
test_cmp expect output &&
1098
- ! grep file_b *.patch
1098
+ test_grep ! file_b *.patch
1099
'
1100
1101
test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
1129
test_expect_success 'format-patch with format.signature config' '
1130
git config format.signature "config sig" &&
1131
git format-patch --stdout -1 >output &&
1132
- grep "config sig" output
1132
+ test_grep "config sig" output
1133
'
1134
1135
test_expect_success 'format-patch --signature overrides format.signature' '
1136
git config format.signature "config sig" &&
1137
git format-patch --stdout --signature="overrides" -1 >output &&
1138
- ! grep "config sig" output &&
1139
- grep "overrides" output
1138
+ test_grep ! "config sig" output &&
1139
+ test_grep "overrides" output
1140
'
1141
1142
test_expect_success 'format-patch --no-signature ignores format.signature' '
1144
git format-patch --stdout --signature="my sig" --no-signature \
1145
-1 >output &&
1146
check_patch output &&
1147
- ! grep "config sig" output &&
1148
- ! grep "my sig" output &&
1149
- ! grep "^-- \$" output
1147
+ test_grep ! "config sig" output &&
1148
+ test_grep ! "my sig" output &&
1149
+ test_grep ! "^-- \$" output
1150
'
1151
1152
test_expect_success 'format-patch --signature --cover-letter' '
1161
git config format.signature "" &&
1162
git format-patch --stdout -1 >output &&
1163
check_patch output &&
1164
- ! grep "^-- \$" output
1164
+ test_grep ! "^-- \$" output
1165
'
1166
1167
test_expect_success 'format-patch --no-signature suppresses signatures' '
1168
git config --unset-all format.signature &&
1169
git format-patch --stdout --no-signature -1 >output &&
1170
check_patch output &&
1171
- ! grep "^-- \$" output
1171
+ test_grep ! "^-- \$" output
1172
'
1173
1174
test_expect_success 'format-patch --signature="" suppresses signatures' '
1175
git format-patch --stdout --signature="" -1 >output &&
1176
check_patch output &&
1177
- ! grep "^-- \$" output
1177
+ test_grep ! "^-- \$" output
1178
'
1179
1180
test_expect_success 'prepare mail-signature input' '
1213
test_config format.signaturefile mail-signature &&
1214
git format-patch --stdout --no-signature -1 >output &&
1215
check_patch output &&
1216
- ! grep "^-- \$" output
1216
+ test_grep ! "^-- \$" output
1217
'
1218
1219
test_expect_success '--signature-file overrides format.signaturefile' '
1235
test_config format.signaturefile mail-signature &&
1236
git format-patch --stdout --signature="my sig" -1 >output &&
1237
check_patch output &&
1238
- grep "my sig" output
1238
+ test_grep "my sig" output
1239
'
1240
1241
test_expect_success TTY 'format-patch --stdout paginates' '
2001
test_config format.coverFromDescription default &&
2002
git checkout rebuild-1 &&
2003
git format-patch --stdout --cover-letter main >actual &&
2004
- grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2005
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2006
- grep "^config subject$" actual &&
2007
- grep "^body$" actual
2004
+ test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2005
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2006
+ test_grep "^config subject$" actual &&
2007
+ test_grep "^body$" actual
2008
'
2009
2010
test_expect_success 'cover letter with --cover-from-description default' '
2013
body" &&
2014
git checkout rebuild-1 &&
2015
git format-patch --stdout --cover-letter --cover-from-description default main >actual &&
2016
- grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2017
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2018
- grep "^config subject$" actual &&
2019
- grep "^body$" actual
2016
+ test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2017
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2018
+ test_grep "^config subject$" actual &&
2019
+ test_grep "^body$" actual
2020
'
2021
2022
test_expect_success 'cover letter with format.coverFromDescription = none' '
2026
test_config format.coverFromDescription none &&
2027
git checkout rebuild-1 &&
2028
git format-patch --stdout --cover-letter main >actual &&
2029
- grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2030
- grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2031
- ! grep "^config subject$" actual &&
2032
- ! grep "^body$" actual
2029
+ test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2030
+ test_grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2031
+ test_grep ! "^config subject$" actual &&
2032
+ test_grep ! "^body$" actual
2033
'
2034
2035
test_expect_success 'cover letter with --cover-from-description none' '
2038
body" &&
2039
git checkout rebuild-1 &&
2040
git format-patch --stdout --cover-letter --cover-from-description none main >actual &&
2041
- grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2042
- grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2043
- ! grep "^config subject$" actual &&
2044
- ! grep "^body$" actual
2041
+ test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2042
+ test_grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2043
+ test_grep ! "^config subject$" actual &&
2044
+ test_grep ! "^body$" actual
2045
'
2046
2047
test_expect_success 'cover letter with format.coverFromDescription = message' '
2051
test_config format.coverFromDescription message &&
2052
git checkout rebuild-1 &&
2053
git format-patch --stdout --cover-letter main >actual &&
2054
- grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2055
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2056
- grep "^config subject$" actual &&
2057
- grep "^body$" actual
2054
+ test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2055
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2056
+ test_grep "^config subject$" actual &&
2057
+ test_grep "^body$" actual
2058
'
2059
2060
test_expect_success 'cover letter with --cover-from-description message' '
2063
body" &&
2064
git checkout rebuild-1 &&
2065
git format-patch --stdout --cover-letter --cover-from-description message main >actual &&
2066
- grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2067
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2068
- grep "^config subject$" actual &&
2069
- grep "^body$" actual
2066
+ test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2067
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2068
+ test_grep "^config subject$" actual &&
2069
+ test_grep "^body$" actual
2070
'
2071
2072
test_expect_success 'cover letter with format.coverFromDescription = subject' '
2076
test_config format.coverFromDescription subject &&
2077
git checkout rebuild-1 &&
2078
git format-patch --stdout --cover-letter main >actual &&
2079
- grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2080
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2081
- ! grep "^config subject$" actual &&
2082
- grep "^body$" actual
2079
+ test_grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2080
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2081
+ test_grep ! "^config subject$" actual &&
2082
+ test_grep "^body$" actual
2083
'
2084
2085
test_expect_success 'cover letter with --cover-from-description subject' '
2088
body" &&
2089
git checkout rebuild-1 &&
2090
git format-patch --stdout --cover-letter --cover-from-description subject main >actual &&
2091
- grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2092
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2093
- ! grep "^config subject$" actual &&
2094
- grep "^body$" actual
2091
+ test_grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2092
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2093
+ test_grep ! "^config subject$" actual &&
2094
+ test_grep "^body$" actual
2095
'
2096
2097
test_expect_success 'cover letter with --cover-from-description subject (UTF-8 subject line)' '
2100
body" &&
2101
git checkout rebuild-1 &&
2102
git format-patch --stdout --cover-letter --cover-from-description subject --encode-email-headers main >actual &&
2103
- grep "^Subject: \[PATCH 0/2\] =?UTF-8?q?Caf=C3=A9=3F?=$" actual &&
2104
- ! grep "Café" actual
2103
+ test_grep "^Subject: \[PATCH 0/2\] =?UTF-8?q?Caf=C3=A9=3F?=$" actual &&
2104
+ test_grep ! "Café" actual
2105
'
2106
2107
test_expect_success 'cover letter with format.coverFromDescription = auto (short subject line)' '
2111
test_config format.coverFromDescription auto &&
2112
git checkout rebuild-1 &&
2113
git format-patch --stdout --cover-letter main >actual &&
2114
- grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2115
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2116
- ! grep "^config subject$" actual &&
2117
- grep "^body$" actual
2114
+ test_grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2115
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2116
+ test_grep ! "^config subject$" actual &&
2117
+ test_grep "^body$" actual
2118
'
2119
2120
test_expect_success 'cover letter with --cover-from-description auto (short subject line)' '
2123
body" &&
2124
git checkout rebuild-1 &&
2125
git format-patch --stdout --cover-letter --cover-from-description auto main >actual &&
2126
- grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2127
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2128
- ! grep "^config subject$" actual &&
2129
- grep "^body$" actual
2126
+ test_grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2127
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2128
+ test_grep ! "^config subject$" actual &&
2129
+ test_grep "^body$" actual
2130
'
2131
2132
test_expect_success 'cover letter with format.coverFromDescription = auto (long subject line)' '
2136
test_config format.coverFromDescription auto &&
2137
git checkout rebuild-1 &&
2138
git format-patch --stdout --cover-letter main >actual &&
2139
- grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2140
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2141
- grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual &&
2142
- grep "^body$" actual
2139
+ test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2140
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2141
+ test_grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual &&
2142
+ test_grep "^body$" actual
2143
'
2144
2145
test_expect_success 'cover letter with --cover-from-description auto (long subject line)' '
2148
body" &&
2149
git checkout rebuild-1 &&
2150
git format-patch --stdout --cover-letter --cover-from-description auto main >actual &&
2151
- grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2152
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2153
- grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual &&
2154
- grep "^body$" actual
2151
+ test_grep "^Subject: \[PATCH 0/2\] \*\*\* SUBJECT HERE \*\*\*$" actual &&
2152
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2153
+ test_grep "^this is a really long first line and it is over 100 characters long which is the threshold for long subjects$" actual &&
2154
+ test_grep "^body$" actual
2155
'
2156
2157
test_expect_success 'cover letter with command-line --cover-from-description overrides config' '
2161
test_config format.coverFromDescription none &&
2162
git checkout rebuild-1 &&
2163
git format-patch --stdout --cover-letter --cover-from-description subject main >actual &&
2164
- grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2165
- ! grep "^\*\*\* BLURB HERE \*\*\*$" actual &&
2166
- ! grep "^config subject$" actual &&
2167
- grep "^body$" actual
2164
+ test_grep "^Subject: \[PATCH 0/2\] config subject$" actual &&
2165
+ test_grep ! "^\*\*\* BLURB HERE \*\*\*$" actual &&
2166
+ test_grep ! "^config subject$" actual &&
2167
+ test_grep "^body$" actual
2168
'
2169
2170
test_expect_success 'cover letter using branch description (1)' '
2171
git checkout rebuild-1 &&
2172
test_config branch.rebuild-1.description hello &&
2173
git format-patch --stdout --cover-letter main >actual &&
2174
- grep hello actual
2174
+ test_grep hello actual
2175
'
2176
2177
test_expect_success 'cover letter using branch description (2)' '
2178
git checkout rebuild-1 &&
2179
test_config branch.rebuild-1.description hello &&
2180
git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual &&
2181
- grep hello actual
2181
+ test_grep hello actual
2182
'
2183
2184
test_expect_success 'cover letter using branch description (3)' '
2185
git checkout rebuild-1 &&
2186
test_config branch.rebuild-1.description hello &&
2187
git format-patch --stdout --cover-letter ^main rebuild-1 >actual &&
2188
- grep hello actual
2188
+ test_grep hello actual
2189
'
2190
2191
test_expect_success 'cover letter using branch description (4)' '
2192
git checkout rebuild-1 &&
2193
test_config branch.rebuild-1.description hello &&
2194
git format-patch --stdout --cover-letter main.. >actual &&
2195
- grep hello actual
2195
+ test_grep hello actual
2196
'
2197
2198
test_expect_success 'cover letter using branch description (5)' '
2199
git checkout rebuild-1 &&
2200
test_config branch.rebuild-1.description hello &&
2201
git format-patch --stdout --cover-letter -2 HEAD >actual &&
2202
- grep hello actual
2202
+ test_grep hello actual
2203
'
2204
2205
test_expect_success 'cover letter using branch description (6)' '
2206
git checkout rebuild-1 &&
2207
test_config branch.rebuild-1.description hello &&
2208
git format-patch --stdout --cover-letter -2 >actual &&
2209
- grep hello actual
2209
+ test_grep hello actual
2210
'
2211
2212
test_expect_success 'cover letter with --description-file' '
2219
git checkout rebuild-1 &&
2220
git format-patch --stdout --cover-letter --cover-from-description auto \
2221
--description-file description.txt main >actual &&
2222
- grep "^Subject: \[PATCH 0/2\] subject from file$" actual &&
2223
- grep "^body from file$" actual
2222
+ test_grep "^Subject: \[PATCH 0/2\] subject from file$" actual &&
2223
+ test_grep "^body from file$" actual
2224
'
2225
2226
test_expect_success 'cover letter with nothing' '
2467
test_expect_success 'format-patch format.useAutoBase whenAble history involves criss-cross' '
2468
test_config format.useAutoBase whenAble &&
2469
git format-patch -1 >patch &&
2470
- ! grep "^base-commit:" patch
2470
+ test_grep ! "^base-commit:" patch
2471
'
2472
2473
test_expect_success 'format-patch format.useAutoBase option' '
2502
test_expect_success 'format-patch --no-base overrides format.useAutoBase' '
2503
test_config format.useAutoBase true &&
2504
git format-patch --stdout --no-base -1 >patch &&
2505
- ! grep "^base-commit:" patch
2505
+ test_grep ! "^base-commit:" patch
2506
'
2507
2508
test_expect_success 'format-patch --no-base overrides format.useAutoBase whenAble' '
2509
test_config format.useAutoBase whenAble &&
2510
git format-patch --stdout --no-base -1 >patch &&
2511
- ! grep "^base-commit:" patch
2511
+ test_grep ! "^base-commit:" patch
2512
'
2513
2514
test_expect_success 'format-patch --base with --attach' '
2521
test_expect_success 'format-patch --attach cover-letter only is non-multipart' '
2522
test_when_finished "rm -fr patches" &&
2523
git format-patch -o patches --cover-letter --attach=mimemime --base=HEAD~ -1 &&
2524
- ! grep -E "^--+mimemime" patches/0000*.patch &&
2524
+ test_grep ! -E "^--+mimemime" patches/0000*.patch &&
2525
grep -E "^--+mimemime$" patches/0001*.patch >output &&
2526
test_line_count = 2 output &&
2527
grep -E "^--+mimemime--$" patches/0001*.patch >output &&
2533
separator=attachment-separator &&
2534
test_config format.attach "$separator" &&
2535
filename=$(git format-patch -o patches -1) &&
2536
- grep "^Content-Type: multipart/.*$separator" "$filename"
2536
+ test_grep "^Content-Type: multipart/.*$separator" "$filename"
2537
'
2538
2539
test_expect_success 'format-patch with format.attach=disabled' '
2543
test_config format.attach "" &&
2544
filename=$(git format-patch -o patches -1) &&
2545
# The output should not even declare content type for text/plain.
2546
- ! grep "^Content-Type: multipart/" "$filename"
2546
+ test_grep ! "^Content-Type: multipart/" "$filename"
2547
'
2548
2549
test_expect_success '-c format.mboxrd format-patch' '
2674
2675
test_expect_success 'format-patch does not respect diff.noprefix' '
2676
git -c diff.noprefix format-patch -1 --stdout >actual &&
2677
- grep "^--- a/blorp" actual
2677
+ test_grep "^--- a/blorp" actual
2678
'
2679
2680
test_expect_success 'format-patch respects format.noprefix' '
2681
git -c format.noprefix format-patch -1 --stdout >actual &&
2682
- grep "^--- blorp" actual
2682
+ test_grep "^--- blorp" actual
2683
'
2684
2685
test_expect_success 'format.noprefix=false' '
2686
git -c format.noprefix=false format-patch -1 --stdout >actual &&
2687
- grep "^--- a/blorp" actual
2687
+ test_grep "^--- a/blorp" actual
2688
'
2689
2690
test_expect_success 'format-patch --default-prefix overrides format.noprefix' '
2691
git -c format.noprefix \
2692
format-patch -1 --default-prefix --stdout >actual &&
2693
- grep "^--- a/blorp" actual
2693
+ test_grep "^--- a/blorp" actual
2694
'
2695
2696
test_expect_success 'errors on format.noprefix which is not boolean' '