Skip to content

Commit 9fe49ae

Browse files
committed
Merge branch 'mt/send-email-cover-to-cc'
* mt/send-email-cover-to-cc: t9001: avoid non-portable '\n' with sed test/send-email: to-cover, cc-cover tests git-send-email: two new options: to-cover, cc-cover
2 parents 7402a1c + 35ec002 commit 9fe49ae

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

Documentation/git-send-email.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,18 @@ Automating
248248
cc list. Default is the value of 'sendemail.signedoffbycc' configuration
249249
value; if that is unspecified, default to --signed-off-by-cc.
250250

251+
--[no-]cc-cover::
252+
If this is set, emails found in Cc: headers in the first patch of
253+
the series (typically the cover letter) are added to the cc list
254+
for each email set. Default is the value of 'sendemail.cccover'
255+
configuration value; if that is unspecified, default to --no-cc-cover.
256+
257+
--[no-]to-cover::
258+
If this is set, emails found in To: headers in the first patch of
259+
the series (typically the cover letter) are added to the to list
260+
for each email set. Default is the value of 'sendemail.tocover'
261+
configuration value; if that is unspecified, default to --no-to-cover.
262+
251263
--suppress-cc=<category>::
252264
Specify an additional category of recipients to suppress the
253265
auto-cc of:

git-send-email.perl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ sub usage {
8080
--to-cmd <str> * Email To: via `<str> \$patch_path`
8181
--cc-cmd <str> * Email Cc: via `<str> \$patch_path`
8282
--suppress-cc <str> * author, self, sob, cc, cccmd, body, bodycc, all.
83+
--[no-]cc-cover * Email Cc: addresses in the cover letter.
84+
--[no-]to-cover * Email To: addresses in the cover letter.
8385
--[no-]signed-off-by-cc * Send to Signed-off-by: addresses. Default on.
8486
--[no-]suppress-from * Send to self. Default off.
8587
--[no-]chain-reply-to * Chain In-Reply-To: fields. Default off.
@@ -195,6 +197,7 @@ sub do_edit {
195197

196198
# Variables with corresponding config settings
197199
my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc);
200+
my ($cover_cc, $cover_to);
198201
my ($to_cmd, $cc_cmd);
199202
my ($smtp_server, $smtp_server_port, @smtp_server_options);
200203
my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);
@@ -211,6 +214,8 @@ sub do_edit {
211214
"chainreplyto" => [\$chain_reply_to, 0],
212215
"suppressfrom" => [\$suppress_from, undef],
213216
"signedoffbycc" => [\$signed_off_by_cc, undef],
217+
"cccover" => [\$cover_cc, undef],
218+
"tocover" => [\$cover_to, undef],
214219
"signedoffcc" => [\$signed_off_by_cc, undef], # Deprecated
215220
"validate" => [\$validate, 1],
216221
"multiedit" => [\$multiedit, undef],
@@ -302,6 +307,8 @@ sub signal_handler {
302307
"suppress-from!" => \$suppress_from,
303308
"suppress-cc=s" => \@suppress_cc,
304309
"signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
310+
"cc-cover|cc-cover!" => \$cover_cc,
311+
"to-cover|to-cover!" => \$cover_to,
305312
"confirm=s" => \$confirm,
306313
"dry-run" => \$dry_run,
307314
"envelope-sender=s" => \$envelope_sender,
@@ -1481,6 +1488,15 @@ sub send_message {
14811488
@to = (@initial_to, @to);
14821489
@cc = (@initial_cc, @cc);
14831490

1491+
if ($message_num == 1) {
1492+
if (defined $cover_cc and $cover_cc) {
1493+
@initial_cc = @cc;
1494+
}
1495+
if (defined $cover_to and $cover_to) {
1496+
@initial_to = @to;
1497+
}
1498+
}
1499+
14841500
my $message_was_sent = send_message();
14851501

14861502
# set up for the next message

t/t9001-send-email.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,51 @@ test_expect_success $PREREQ '--force sends cover letter template anyway' '
13341334
test -n "$(ls msgtxt*)"
13351335
'
13361336

1337+
test_cover_addresses () {
1338+
header="$1"
1339+
shift
1340+
clean_fake_sendmail &&
1341+
rm -fr outdir &&
1342+
git format-patch --cover-letter -2 -o outdir &&
1343+
cover=`echo outdir/0000-*.patch` &&
1344+
mv $cover cover-to-edit.patch &&
1345+
perl -pe "s/^From:/$header: extra\@address.com\nFrom:/" cover-to-edit.patch >"$cover" &&
1346+
git send-email \
1347+
--force \
1348+
--from="Example <[email protected]>" \
1349+
--no-to --no-cc \
1350+
"$@" \
1351+
--smtp-server="$(pwd)/fake.sendmail" \
1352+
outdir/0000-*.patch \
1353+
outdir/0001-*.patch \
1354+
outdir/0002-*.patch \
1355+
2>errors >out &&
1356+
grep "^$header: [email protected]" msgtxt1 >to1 &&
1357+
grep "^$header: [email protected]" msgtxt2 >to2 &&
1358+
grep "^$header: [email protected]" msgtxt3 >to3 &&
1359+
test_line_count = 1 to1 &&
1360+
test_line_count = 1 to2 &&
1361+
test_line_count = 1 to3
1362+
}
1363+
1364+
test_expect_success $PREREQ 'to-cover adds To to all mail' '
1365+
test_cover_addresses "To" --to-cover
1366+
'
1367+
1368+
test_expect_success $PREREQ 'cc-cover adds Cc to all mail' '
1369+
test_cover_addresses "Cc" --cc-cover
1370+
'
1371+
1372+
test_expect_success $PREREQ 'tocover adds To to all mail' '
1373+
test_config sendemail.tocover true &&
1374+
test_cover_addresses "To"
1375+
'
1376+
1377+
test_expect_success $PREREQ 'cccover adds Cc to all mail' '
1378+
test_config sendemail.cccover true &&
1379+
test_cover_addresses "Cc"
1380+
'
1381+
13371382
test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
13381383
clean_fake_sendmail &&
13391384
echo "alias sbd [email protected]" >.mailrc &&

0 commit comments

Comments
 (0)