Skip to content

Commit 324a8bd

Browse files
JoePerchesgitster
authored andcommitted
git-send-email --cc-cmd
This new option allows an arbitrary "cmd" to generate per patch file specific "Cc:"s. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a9ab200 commit 324a8bd

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

Documentation/git-send-email.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ The --bcc option must be repeated for each user you want on the bcc list.
3434
+
3535
The --cc option must be repeated for each user you want on the cc list.
3636

37+
--cc-cmd::
38+
Specify a command to execute once per patch file which
39+
should generate patch file specific "Cc:" entries.
40+
Output of this command must be single email address per line.
41+
Default is the value of 'sendemail.cccmd' configuration value.
42+
3743
--chain-reply-to, --no-chain-reply-to::
3844
If this is set, each email will be sent as a reply to the previous
3945
email sent. If disabled with "--no-chain-reply-to", all emails after
@@ -124,6 +130,9 @@ sendemail.aliasfiletype::
124130
Format of the file(s) specified in sendemail.aliasesfile. Must be
125131
one of 'mutt', 'mailrc', 'pine', or 'gnus'.
126132

133+
sendemail.cccmd::
134+
Command to execute to generate per patch file specific "Cc:"s.
135+
127136
sendemail.bcc::
128137
Email address (or alias) to always bcc.
129138

git-send-email.perl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ sub usage {
4646
--cc Specify an initial "Cc:" list for the entire series
4747
of emails.
4848
49+
--cc-cmd Specify a command to execute per file which adds
50+
per file specific cc address entries
51+
4952
--bcc Specify a list of email addresses that should be Bcc:
5053
on all the emails.
5154
@@ -157,13 +160,14 @@ sub format_2822_time {
157160
my ($quiet, $dry_run) = (0, 0);
158161

159162
# Variables with corresponding config settings
160-
my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc);
163+
my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
161164

162165
my %config_settings = (
163166
"thread" => [\$thread, 1],
164167
"chainreplyto" => [\$chain_reply_to, 1],
165168
"suppressfrom" => [\$suppress_from, 0],
166169
"signedoffcc" => [\$signed_off_cc, 1],
170+
"cccmd" => [\$cc_cmd, ""],
167171
);
168172

169173
foreach my $setting (keys %config_settings) {
@@ -189,6 +193,7 @@ sub format_2822_time {
189193
"smtp-server=s" => \$smtp_server,
190194
"compose" => \$compose,
191195
"quiet" => \$quiet,
196+
"cc-cmd=s" => \$cc_cmd,
192197
"suppress-from!" => \$suppress_from,
193198
"signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
194199
"dry-run" => \$dry_run,
@@ -652,11 +657,26 @@ sub send_message
652657
}
653658
}
654659
close F;
660+
661+
if ($cc_cmd ne "") {
662+
open(F, "$cc_cmd $t |")
663+
or die "(cc-cmd) Could not execute '$cc_cmd'";
664+
while(<F>) {
665+
my $c = $_;
666+
$c =~ s/^\s*//g;
667+
$c =~ s/\n$//g;
668+
push @cc, $c;
669+
printf("(cc-cmd) Adding cc: %s from: '%s'\n",
670+
$c, $cc_cmd) unless $quiet;
671+
}
672+
close F
673+
or die "(cc-cmd) failed to close pipe to '$cc_cmd'";
674+
}
675+
655676
if (defined $author) {
656677
$message = "From: $author\n\n$message";
657678
}
658679

659-
660680
send_message();
661681

662682
# set up for the next message

0 commit comments

Comments
 (0)