Skip to content

Commit c14bd20

Browse files
committed
Merge branch 'tr/maint-format-patch-empty-output'
* tr/maint-format-patch-empty-output: Document negated forms of format-patch --to --cc --add-headers t4014: "no-add-headers" is actually called "no-add-header" t4014: invoke format-patch with --stdout where intended t4014: check for empty files from git format-patch --stdout
2 parents fee6bc5 + b2cd17b commit c14bd20

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

Documentation/git-format-patch.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,22 @@ will want to ensure that threading is disabled for `git send-email`.
166166
--to=<email>::
167167
Add a `To:` header to the email headers. This is in addition
168168
to any configured headers, and may be used multiple times.
169+
The negated form `--no-to` discards all `To:` headers added so
170+
far (from config or command line).
169171

170172
--cc=<email>::
171173
Add a `Cc:` header to the email headers. This is in addition
172174
to any configured headers, and may be used multiple times.
175+
The negated form `--no-cc` discards all `Cc:` headers added so
176+
far (from config or command line).
173177

174178
--add-header=<header>::
175179
Add an arbitrary header to the email headers. This is in addition
176180
to any configured headers, and may be used multiple times.
177-
For example, `--add-header="Organization: git-foo"`
181+
For example, `--add-header="Organization: git-foo"`.
182+
The negated form `--no-add-header` discards *all* (`To:`,
183+
`Cc:`, and custom) headers added so far from config or command
184+
line.
178185

179186
--cover-letter::
180187
In addition to the patches, generate a cover letter file

t/t4014-format-patch.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,21 @@ test_expect_success 'configuration To: header' '
179179
grep "^To: R. E. Cipient <[email protected]>\$" patch9
180180
'
181181

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+
182190
test_expect_success '--no-to overrides config.to' '
183191
184192
git config --replace-all format.to \
185193
"R. E. Cipient <[email protected]>" &&
186194
git format-patch --no-to --stdout master..side |
187195
sed -e "/^\$/q" >patch10 &&
196+
check_patch patch10 &&
188197
! grep "^To: R. E. Cipient <[email protected]>\$" patch10
189198
'
190199

@@ -195,6 +204,7 @@ test_expect_success '--no-to and --to replaces config.to' '
195204
git format-patch --no-to --to="Someone Else <[email protected]>" \
196205
--stdout master..side |
197206
sed -e "/^\$/q" >patch11 &&
207+
check_patch patch11 &&
198208
! grep "^To: Someone <[email protected]>\$" patch11 &&
199209
grep "^To: Someone Else <[email protected]>\$" patch11
200210
'
@@ -205,15 +215,17 @@ test_expect_success '--no-cc overrides config.cc' '
205215
"C. E. Cipient <[email protected]>" &&
206216
git format-patch --no-cc --stdout master..side |
207217
sed -e "/^\$/q" >patch12 &&
218+
check_patch patch12 &&
208219
! grep "^Cc: C. E. Cipient <[email protected]>\$" patch12
209220
'
210221

211-
test_expect_success '--no-add-headers overrides config.headers' '
222+
test_expect_success '--no-add-header overrides config.headers' '
212223
213224
git config --replace-all format.headers \
214225
"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 |
216227
sed -e "/^\$/q" >patch13 &&
228+
check_patch patch13 &&
217229
! grep "^Header1: B. E. Cipient <[email protected]>\$" patch13
218230
'
219231

@@ -480,6 +492,7 @@ test_expect_success 'cover-letter inherits diff options' '
480492
git mv file foo &&
481493
git commit -m foo &&
482494
git format-patch --cover-letter -1 &&
495+
check_patch 0000-cover-letter.patch &&
483496
! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
484497
git format-patch --cover-letter -1 -M &&
485498
grep "file => foo .* 0 *\$" 0000-cover-letter.patch
@@ -657,6 +670,7 @@ test_expect_success 'format-patch --no-signature ignores format.signature' '
657670
git config format.signature "config sig" &&
658671
git format-patch --stdout --signature="my sig" --no-signature \
659672
-1 >output &&
673+
check_patch output &&
660674
! grep "config sig" output &&
661675
! grep "my sig" output &&
662676
! grep "^-- \$" output
@@ -673,17 +687,20 @@ test_expect_success 'format-patch --signature --cover-letter' '
673687
test_expect_success 'format.signature="" supresses signatures' '
674688
git config format.signature "" &&
675689
git format-patch --stdout -1 >output &&
690+
check_patch output &&
676691
! grep "^-- \$" output
677692
'
678693

679694
test_expect_success 'format-patch --no-signature supresses signatures' '
680695
git config --unset-all format.signature &&
681696
git format-patch --stdout --no-signature -1 >output &&
697+
check_patch output &&
682698
! grep "^-- \$" output
683699
'
684700

685701
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 &&
687704
! grep "^-- \$" output
688705
'
689706

0 commit comments

Comments
 (0)