@@ -148,6 +148,22 @@ test_expect_success 'Prompting works' '
148148 grep "^To: to@example.com$" msgtxt1
149149'
150150
151+ test_expect_success ' cccmd works' '
152+ clean_fake_sendmail &&
153+ cp $patches cccmd.patch &&
154+ echo cccmd--cccmd@example.com >>cccmd.patch &&
155+ echo sed -n s/^cccmd--//p \"\$1\" > cccmd-sed &&
156+ chmod +x cccmd-sed &&
157+ git send-email \
158+ --from="Example <nobody@example.com>" \
159+ --to=nobody@example.com \
160+ --cc-cmd=./cccmd-sed \
161+ --smtp-server="$(pwd)/fake.sendmail" \
162+ cccmd.patch \
163+ &&
164+ grep ^Cc:.*cccmd@example.com msgtxt1
165+ '
166+
151167z8=zzzzzzzz
152168z64=$z8$z8$z8$z8$z8$z8$z8$z8
153169z512=$z64$z64$z64$z64$z64$z64$z64$z64
@@ -274,16 +290,16 @@ EOF
274290test_suppression () {
275291 git send-email \
276292 --dry-run \
277- --suppress-cc=$1 \
293+ --suppress-cc=$1 ${2+ " --suppress-cc= $2 " } \
278294 --from=" Example <from@example.com>" \
279295 --to=to@example.com \
280296 --smtp-server relay.example.com \
281297 $patches |
282298 sed -e " s/^\(Date:\).*/\1 DATE-STRING/" \
283299 -e " s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
284300 -e " s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
285- > actual-suppress-$1 &&
286- test_cmp expected-suppress-$1 actual-suppress-$1
301+ > actual-suppress-$1 ${2+ " - $2 " } &&
302+ test_cmp expected-suppress-$1 ${2+ " - $2 " } actual-suppress-$1 ${2+ " - $2 " }
287303}
288304
289305test_expect_success ' sendemail.cc set' '
@@ -316,6 +332,34 @@ test_expect_success 'sendemail.cc unset' '
316332 test_suppression sob
317333'
318334
335+ cat > expected-suppress-cccmd << \EOF
336+ 0001-Second.patch
337+ (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
338+ (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
339+ (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
340+ (body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'
341+ Dry-OK. Log says:
342+ Server: relay.example.com
343+ MAIL FROM:<from@example.com>
344+ RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>
345+ From: Example <from@example.com>
346+ To: to@example.com
347+ Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>
348+ Subject: [PATCH 1/1] Second.
349+ Date: DATE-STRING
350+ Message-Id: MESSAGE-ID-STRING
351+ X-Mailer: X-MAILER-STRING
352+
353+ Result: OK
354+ EOF
355+
356+ test_expect_success ' sendemail.cccmd' '
357+ echo echo cc-cmd@example.com > cccmd &&
358+ chmod +x cccmd &&
359+ git config sendemail.cccmd ./cccmd &&
360+ test_suppression cccmd
361+ '
362+
319363cat > expected-suppress-all << \EOF
3203640001-Second.patch
321365Dry-OK. Log says:
@@ -341,13 +385,14 @@ cat >expected-suppress-body <<\EOF
341385(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
342386(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
343387(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
388+ (cc-cmd) Adding cc: cc-cmd@example.com from: './cccmd'
344389Dry-OK. Log says:
345390Server: relay.example.com
346391MAIL FROM:<from@example.com>
347- RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
392+ RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<cc-cmd@example.com>
348393From: Example <from@example.com>
349394To: to@example.com
350- Cc: A <author@example.com>, One <one@example.com>, two@example.com
395+ Cc: A <author@example.com>, One <one@example.com>, two@example.com, cc-cmd@example.com
351396Subject: [PATCH 1/1] Second.
352397Date: DATE-STRING
353398Message-Id: MESSAGE-ID-STRING
@@ -360,6 +405,30 @@ test_expect_success '--suppress-cc=body' '
360405 test_suppression body
361406'
362407
408+ cat > expected-suppress-body-cccmd << \EOF
409+ 0001-Second.patch
410+ (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
411+ (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'
412+ (mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'
413+ Dry-OK. Log says:
414+ Server: relay.example.com
415+ MAIL FROM:<from@example.com>
416+ RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>
417+ From: Example <from@example.com>
418+ To: to@example.com
419+ Cc: A <author@example.com>, One <one@example.com>, two@example.com
420+ Subject: [PATCH 1/1] Second.
421+ Date: DATE-STRING
422+ Message-Id: MESSAGE-ID-STRING
423+ X-Mailer: X-MAILER-STRING
424+
425+ Result: OK
426+ EOF
427+
428+ test_expect_success ' --suppress-cc=body --suppress-cc=cccmd' '
429+ test_suppression body cccmd
430+ '
431+
363432cat > expected-suppress-sob << \EOF
3644330001-Second.patch
365434(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -381,6 +450,7 @@ Result: OK
381450EOF
382451
383452test_expect_success ' --suppress-cc=sob' '
453+ git config --unset sendemail.cccmd
384454 test_suppression sob
385455'
386456
0 commit comments