Skip to content

Commit 451316d

Browse files
committed
Merge branch 'pb/send-email-cccmd-fix'
* pb/send-email-cccmd-fix: Test cccmd in t9001-send-email.sh and fix some bugs
2 parents b58f6b5 + cb8a9bd commit 451316d

4 files changed

Lines changed: 80 additions & 10 deletions

File tree

Documentation/git-send-email.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ Automating
193193
- 'self' will avoid including the sender
194194
- 'cc' will avoid including anyone mentioned in Cc lines in the patch header
195195
except for self (use 'self' for that).
196-
- 'ccbody' will avoid including anyone mentioned in Cc lines in the
196+
- 'bodycc' will avoid including anyone mentioned in Cc lines in the
197197
patch body (commit message) except for self (use 'self' for that).
198198
- 'sob' will avoid including anyone mentioned in Signed-off-by lines except
199199
for self (use 'self' for that).
200200
- 'cccmd' will avoid running the --cc-cmd.
201-
- 'body' is equivalent to 'sob' + 'ccbody'
201+
- 'body' is equivalent to 'sob' + 'bodycc'
202202
- 'all' will suppress all auto cc values.
203203
--
204204
+

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ _git_rebase ()
12991299
}
13001300

13011301
__git_send_email_confirm_options="always never auto cc compose"
1302-
__git_send_email_suppresscc_options="author self cc ccbody sob cccmd body all"
1302+
__git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
13031303

13041304
_git_send_email ()
13051305
{

git-send-email.perl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ sub read_config {
334334
}
335335

336336
if ($suppress_cc{'all'}) {
337-
foreach my $entry (qw (ccmd cc author self sob body bodycc)) {
337+
foreach my $entry (qw (cccmd cc author self sob body bodycc)) {
338338
$suppress_cc{$entry} = 1;
339339
}
340340
delete $suppress_cc{'all'};
@@ -1104,7 +1104,7 @@ sub send_message
11041104
close F;
11051105

11061106
if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
1107-
open(F, "$cc_cmd $t |")
1107+
open(F, "$cc_cmd \Q$t\E |")
11081108
or die "(cc-cmd) Could not execute '$cc_cmd'";
11091109
while(<F>) {
11101110
my $c = $_;

t/t9001-send-email.sh

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
151167
z8=zzzzzzzz
152168
z64=$z8$z8$z8$z8$z8$z8$z8$z8
153169
z512=$z64$z64$z64$z64$z64$z64$z64$z64
@@ -274,16 +290,16 @@ EOF
274290
test_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

289305
test_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+
319363
cat >expected-suppress-all <<\EOF
320364
0001-Second.patch
321365
Dry-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'
344389
Dry-OK. Log says:
345390
Server: relay.example.com
346391
MAIL 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>
348393
From: Example <from@example.com>
349394
To: 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
351396
Subject: [PATCH 1/1] Second.
352397
Date: DATE-STRING
353398
Message-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+
363432
cat >expected-suppress-sob <<\EOF
364433
0001-Second.patch
365434
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -381,6 +450,7 @@ Result: OK
381450
EOF
382451

383452
test_expect_success '--suppress-cc=sob' '
453+
git config --unset sendemail.cccmd
384454
test_suppression sob
385455
'
386456

0 commit comments

Comments
 (0)