Skip to content

Commit b1c8a11

Browse files
Awaryngitster
authored andcommitted
send-email: allow multiple emails using --cc, --to and --bcc
Accept a list of emails separated by commas in flags --cc, --to and --bcc. Multiple addresses can already be given by using these options multiple times, but it is more convenient to allow cutting-and-pasting a list of addresses from the header of an existing e-mail message, which already lists them as comma-separated list, as a value to a single parameter. The following format can now be used: $ git send-email --to='Jane <[email protected]>, [email protected]' Remove the limitation imposed by 79ee555 (Check and document the options to prevent mistakes, 2006-06-21) which rejected every argument with comma in --cc, --to and --bcc. Signed-off-by: Mathieu Lienard--Mayor <[email protected]> Signed-off-by: Jorge Juan Garcia Garcia <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Remi Lespinet <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1fe9703 commit b1c8a11

File tree

3 files changed

+52
-21
lines changed

3 files changed

+52
-21
lines changed

Documentation/git-send-email.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ Composing
4949
of 'sendemail.annotate'. See the CONFIGURATION section for
5050
'sendemail.multiEdit'.
5151

52-
--bcc=<address>::
52+
--bcc=<address>,...::
5353
Specify a "Bcc:" value for each email. Default is the value of
5454
'sendemail.bcc'.
5555
+
56-
The --bcc option must be repeated for each user you want on the bcc list.
56+
This option may be specified multiple times.
5757

58-
--cc=<address>::
58+
--cc=<address>,...::
5959
Specify a starting "Cc:" value for each email.
6060
Default is the value of 'sendemail.cc'.
6161
+
62-
The --cc option must be repeated for each user you want on the cc list.
62+
This option may be specified multiple times.
6363

6464
--compose::
6565
Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
@@ -110,13 +110,13 @@ is not set, this will be prompted for.
110110
Only necessary if --compose is also set. If --compose
111111
is not set, this will be prompted for.
112112

113-
--to=<address>::
113+
--to=<address>,...::
114114
Specify the primary recipient of the emails generated. Generally, this
115115
will be the upstream maintainer of the project involved. Default is the
116116
value of the 'sendemail.to' configuration value; if that is unspecified,
117117
and --to-cmd is not specified, this will be prompted for.
118118
+
119-
The --to option must be repeated for each user you want on the to list.
119+
This option may be specified multiple times.
120120

121121
--8bit-encoding=<encoding>::
122122
When encountering a non-ASCII message or subject that does not

git-send-email.perl

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -460,20 +460,6 @@ sub read_config {
460460
($repoauthor) = Git::ident_person(@repo, 'author');
461461
($repocommitter) = Git::ident_person(@repo, 'committer');
462462

463-
# Verify the user input
464-
465-
foreach my $entry (@initial_to) {
466-
die "Comma in --to entry: $entry'\n" unless $entry !~ m/,/;
467-
}
468-
469-
foreach my $entry (@initial_cc) {
470-
die "Comma in --cc entry: $entry'\n" unless $entry !~ m/,/;
471-
}
472-
473-
foreach my $entry (@bcclist) {
474-
die "Comma in --bcclist entry: $entry'\n" unless $entry !~ m/,/;
475-
}
476-
477463
sub parse_address_line {
478464
if ($have_mail_address) {
479465
return map { $_->format } Mail::Address->parse($_[0]);
@@ -1026,7 +1012,8 @@ sub sanitize_address_list {
10261012
}
10271013

10281014
sub process_address_list {
1029-
my @addr_list = expand_aliases(@_);
1015+
my @addr_list = map { parse_address_line($_) } @_;
1016+
@addr_list = expand_aliases(@addr_list);
10301017
@addr_list = sanitize_address_list(@addr_list);
10311018
@addr_list = validate_address_list(@addr_list);
10321019
return @addr_list;

t/t9001-send-email.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,4 +1648,48 @@ test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' '
16481648
do_xmailer_test 1 "--xmailer"
16491649
'
16501650

1651+
test_expect_success $PREREQ 'setup expected-list' '
1652+
git send-email \
1653+
--dry-run \
1654+
--from="Example <[email protected]>" \
1655+
--to="To 1 <[email protected]>" \
1656+
1657+
1658+
--cc="Cc 1 <[email protected]>" \
1659+
--cc="Cc2 <[email protected]>" \
1660+
1661+
1662+
0001-add-master.patch | replace_variable_fields \
1663+
>expected-list
1664+
'
1665+
1666+
test_expect_success $PREREQ 'use email list in --cc --to and --bcc' '
1667+
git send-email \
1668+
--dry-run \
1669+
--from="Example <[email protected]>" \
1670+
1671+
1672+
--cc="Cc 1 <[email protected]>, Cc2 <[email protected]>" \
1673+
1674+
0001-add-master.patch | replace_variable_fields \
1675+
>actual-list &&
1676+
test_cmp expected-list actual-list
1677+
'
1678+
1679+
test_expect_success $PREREQ 'aliases work with email list' '
1680+
echo "alias to2 [email protected]" >.mutt &&
1681+
echo "alias cc1 Cc 1 <[email protected]>" >>.mutt &&
1682+
test_config sendemail.aliasesfile ".mutt" &&
1683+
test_config sendemail.aliasfiletype mutt &&
1684+
git send-email \
1685+
--dry-run \
1686+
--from="Example <[email protected]>" \
1687+
--to="To 1 <[email protected]>, to2, [email protected]" \
1688+
--cc="cc1, Cc2 <[email protected]>" \
1689+
1690+
0001-add-master.patch | replace_variable_fields \
1691+
>actual-list &&
1692+
test_cmp expected-list actual-list
1693+
'
1694+
16511695
test_done

0 commit comments

Comments
 (0)