@@ -179,12 +179,21 @@ test_expect_success 'configuration To: header' '
179
179
grep "^To: R. E. Cipient <[email protected] >\$" patch9
180
180
'
181
181
182
+ # check_patch <patch>: Verify that <patch> looks like a half-sane
183
+ # patch email to avoid a false positive with !grep
184
+ check_patch () {
185
+ grep -e " ^From:" " $1 " &&
186
+ grep -e " ^Date:" " $1 " &&
187
+ grep -e " ^Subject:" " $1 "
188
+ }
189
+
182
190
test_expect_success ' --no-to overrides config.to' '
183
191
184
192
git config --replace-all format.to \
185
193
"R. E. Cipient <[email protected] >" &&
186
194
git format-patch --no-to --stdout master..side |
187
195
sed -e "/^\$/q" >patch10 &&
196
+ check_patch patch10 &&
188
197
! grep "^To: R. E. Cipient <[email protected] >\$" patch10
189
198
'
190
199
@@ -195,6 +204,7 @@ test_expect_success '--no-to and --to replaces config.to' '
195
204
git format-patch --no-to --to="Someone Else <[email protected] >" \
196
205
--stdout master..side |
197
206
sed -e "/^\$/q" >patch11 &&
207
+ check_patch patch11 &&
198
208
! grep "^To: Someone <[email protected] >\$" patch11 &&
199
209
grep "^To: Someone Else <[email protected] >\$" patch11
200
210
'
@@ -205,15 +215,17 @@ test_expect_success '--no-cc overrides config.cc' '
205
215
"C. E. Cipient <[email protected] >" &&
206
216
git format-patch --no-cc --stdout master..side |
207
217
sed -e "/^\$/q" >patch12 &&
218
+ check_patch patch12 &&
208
219
! grep "^Cc: C. E. Cipient <[email protected] >\$" patch12
209
220
'
210
221
211
- test_expect_success ' --no-add-headers overrides config.headers' '
222
+ test_expect_success ' --no-add-header overrides config.headers' '
212
223
213
224
git config --replace-all format.headers \
214
225
"Header1: B. E. Cipient <[email protected] >" &&
215
- git format-patch --no-add-headers --stdout master..side |
226
+ git format-patch --no-add-header --stdout master..side |
216
227
sed -e "/^\$/q" >patch13 &&
228
+ check_patch patch13 &&
217
229
! grep "^Header1: B. E. Cipient <[email protected] >\$" patch13
218
230
'
219
231
@@ -480,6 +492,7 @@ test_expect_success 'cover-letter inherits diff options' '
480
492
git mv file foo &&
481
493
git commit -m foo &&
482
494
git format-patch --cover-letter -1 &&
495
+ check_patch 0000-cover-letter.patch &&
483
496
! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
484
497
git format-patch --cover-letter -1 -M &&
485
498
grep "file => foo .* 0 *\$" 0000-cover-letter.patch
@@ -657,6 +670,7 @@ test_expect_success 'format-patch --no-signature ignores format.signature' '
657
670
git config format.signature "config sig" &&
658
671
git format-patch --stdout --signature="my sig" --no-signature \
659
672
-1 >output &&
673
+ check_patch output &&
660
674
! grep "config sig" output &&
661
675
! grep "my sig" output &&
662
676
! grep "^-- \$" output
@@ -673,17 +687,20 @@ test_expect_success 'format-patch --signature --cover-letter' '
673
687
test_expect_success ' format.signature="" supresses signatures' '
674
688
git config format.signature "" &&
675
689
git format-patch --stdout -1 >output &&
690
+ check_patch output &&
676
691
! grep "^-- \$" output
677
692
'
678
693
679
694
test_expect_success ' format-patch --no-signature supresses signatures' '
680
695
git config --unset-all format.signature &&
681
696
git format-patch --stdout --no-signature -1 >output &&
697
+ check_patch output &&
682
698
! grep "^-- \$" output
683
699
'
684
700
685
701
test_expect_success ' format-patch --signature="" supresses signatures' '
686
- git format-patch --signature="" -1 >output &&
702
+ git format-patch --stdout --signature="" -1 >output &&
703
+ check_patch output &&
687
704
! grep "^-- \$" output
688
705
'
689
706
0 commit comments