@@ -32,11 +32,11 @@ clean_fake_sendmail() {
3232}
3333
3434test_expect_success ' Extract patches' '
35- patches=`git format-patch --cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
35+ patches=`git format-patch -s - -cc="One <one@example.com>" --cc=two@example.com -n HEAD^1`
3636'
3737
3838test_expect_success ' Send patches' '
39- git send-email --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
39+ git send-email --suppress-cc=sob -- from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
4040'
4141
4242cat > expected << \EOF
7474test_expect_success ' Show all headers' '
7575 git send-email \
7676 --dry-run \
77+ --suppress-cc=sob \
7778 --from="Example <from@example.com>" \
7879 --to=to@example.com \
7980 --cc=cc@example.com \
@@ -193,7 +194,7 @@ test_expect_success 'second message is patch' '
193194 grep "Subject:.*Second" msgtxt2
194195'
195196
196- cat > expected-show-all-headers << \EOF
197+ cat > expected-suppress-sob << \EOF
1971980001-Second.patch
198199(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
199200(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
@@ -213,22 +214,27 @@ X-Mailer: X-MAILER-STRING
213214Result: OK
214215EOF
215216
216- test_expect_success ' sendemail.cc set' '
217- git config sendemail.cc cc@example.com &&
217+ test_suppression () {
218218 git send-email \
219219 --dry-run \
220+ --suppress-cc=$1 \
220221 --from=" Example <from@example.com>" \
221222 --to=to@example.com \
222223 --smtp-server relay.example.com \
223224 $patches |
224225 sed -e " s/^\(Date:\).*/\1 DATE-STRING/" \
225226 -e " s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
226227 -e " s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
227- >actual-show-all-headers &&
228- test_cmp expected-show-all-headers actual-show-all-headers
228+ > actual-suppress-$1 &&
229+ test_cmp expected-suppress-$1 actual-suppress-$1
230+ }
231+
232+ test_expect_success ' sendemail.cc set' '
233+ git config sendemail.cc cc@example.com &&
234+ test_suppression sob
229235'
230236
231- cat > expected-show-all-headers << \EOF
237+ cat > expected-suppress-sob << \EOF
2322380001-Second.patch
233239(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
234240(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
@@ -250,17 +256,123 @@ EOF
250256
251257test_expect_success ' sendemail.cc unset' '
252258 git config --unset sendemail.cc &&
253- git send-email \
254- --dry-run \
255- --from="Example <from@example.com>" \
256- --to=to@example.com \
257- --smtp-server relay.example.com \
258- $patches |
259- sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
260- -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
261- -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
262- >actual-show-all-headers &&
263- test_cmp expected-show-all-headers actual-show-all-headers
259+ test_suppression sob
260+ '
261+
262+ cat > expected-suppress-all << \EOF
263+ 0001-Second.patch
264+ Dry-OK. Log says:
265+ Server: relay.example.com
266+ MAIL FROM:<from@example.com>
267+ RCPT TO:<to@example.com>
268+ From: Example <from@example.com>
269+ To: to@example.com
270+ Subject: [PATCH 1/1] Second.
271+ Date: DATE-STRING
272+ Message-Id: MESSAGE-ID-STRING
273+ X-Mailer: X-MAILER-STRING
274+
275+ Result: OK
276+ EOF
277+
278+ test_expect_success ' --suppress-cc=all' '
279+ test_suppression all
280+ '
281+
282+ cat > expected-suppress-body << \EOF
283+ 0001-Second.patch
284+ (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
285+ (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
286+ (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
287+ Dry-OK. Log says:
288+ Server: relay.example.com
289+ MAIL FROM:<from@example.com>
290+ RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
291+ From: Example <from@example.com>
292+ To: to@example.com
293+ Cc: A <author@example.com>, One <one@example.com>, two@example.com
294+ Subject: [PATCH 1/1] Second.
295+ Date: DATE-STRING
296+ Message-Id: MESSAGE-ID-STRING
297+ X-Mailer: X-MAILER-STRING
298+
299+ Result: OK
300+ EOF
301+
302+ test_expect_success ' --suppress-cc=body' '
303+ test_suppression body
304+ '
305+
306+ cat > expected-suppress-sob << \EOF
307+ 0001-Second.patch
308+ (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
309+ (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
310+ (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
311+ Dry-OK. Log says:
312+ Server: relay.example.com
313+ MAIL FROM:<from@example.com>
314+ RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
315+ From: Example <from@example.com>
316+ To: to@example.com
317+ Cc: A <author@example.com>, One <one@example.com>, two@example.com
318+ Subject: [PATCH 1/1] Second.
319+ Date: DATE-STRING
320+ Message-Id: MESSAGE-ID-STRING
321+ X-Mailer: X-MAILER-STRING
322+
323+ Result: OK
324+ EOF
325+
326+ test_expect_success ' --suppress-cc=sob' '
327+ test_suppression sob
328+ '
329+
330+ cat > expected-suppress-bodycc << \EOF
331+ 0001-Second.patch
332+ (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
333+ (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
334+ (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
335+ (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
336+ Dry-OK. Log says:
337+ Server: relay.example.com
338+ MAIL FROM:<from@example.com>
339+ RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
340+ From: Example <from@example.com>
341+ To: to@example.com
342+ Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
343+ Subject: [PATCH 1/1] Second.
344+ Date: DATE-STRING
345+ Message-Id: MESSAGE-ID-STRING
346+ X-Mailer: X-MAILER-STRING
347+
348+ Result: OK
349+ EOF
350+
351+ test_expect_success ' --suppress-cc=bodycc' '
352+ test_suppression bodycc
353+ '
354+
355+ cat > expected-suppress-cc << \EOF
356+ 0001-Second.patch
357+ (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
358+ (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
359+ Dry-OK. Log says:
360+ Server: relay.example.com
361+ MAIL FROM:<from@example.com>
362+ RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com>
363+ From: Example <from@example.com>
364+ To: to@example.com
365+ Cc: A <author@example.com>, C O Mitter <committer@example.com>
366+ Subject: [PATCH 1/1] Second.
367+ Date: DATE-STRING
368+ Message-Id: MESSAGE-ID-STRING
369+ X-Mailer: X-MAILER-STRING
370+
371+ Result: OK
372+ EOF
373+
374+ test_expect_success ' --suppress-cc=cc' '
375+ test_suppression cc
264376'
265377
266378test_expect_success ' --compose adds MIME for utf8 body' '
0 commit comments