git-send-email: Generalize auto-cc recipient mechanism.
There are a few options to git-send-email to suppress the automatic generation of 'Cc' fields: --suppress-from, and --signed-off-cc. However, there are other times that git-send-email automatically includes Cc'd recipients. This is not desirable for all development environments. Add a new option --suppress-cc, which can be specified one or more times to list the categories of auto-cc fields that should be suppressed. If not specified, it defaults to values to give the same behavior as specified by --suppress-from, and --signed-off-cc. The categories are: self - patch sender. Same as --suppress-from. author - patch author. cc - cc lines mentioned in the patch. cccmd - avoid running the cccmd. sob - signed off by lines. all - all non-explicit recipients Signed-off-by: David Brown <git@davidb.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
7a2078b4b0
commit
656482830d
|
@ -117,6 +117,17 @@ The --cc option must be repeated for each user you want on the cc list.
|
||||||
Default is the value of 'sendemail.suppressfrom' configuration value;
|
Default is the value of 'sendemail.suppressfrom' configuration value;
|
||||||
if that is unspecified, default to --no-suppress-from.
|
if that is unspecified, default to --no-suppress-from.
|
||||||
|
|
||||||
|
--suppress-cc::
|
||||||
|
Specify an additional category of recipients to suppress the
|
||||||
|
auto-cc of. 'self' will avoid including the sender, 'author' will
|
||||||
|
avoid including the patch author, 'cc' will avoid including anyone
|
||||||
|
mentioned in Cc lines in the patch, 'sob' will avoid including
|
||||||
|
anyone mentioned in Signed-off-by lines, and 'cccmd' will avoid
|
||||||
|
running the --cc-cmd. 'all' will suppress all auto cc values.
|
||||||
|
Default is the value of 'sendemail.suppresscc' configuration value;
|
||||||
|
if that is unspecified, default to 'self' if --suppress-from is
|
||||||
|
specified, as well as 'sob' if --no-signed-off-cc is specified.
|
||||||
|
|
||||||
--thread, --no-thread::
|
--thread, --no-thread::
|
||||||
If this is set, the In-Reply-To header will be set on each email sent.
|
If this is set, the In-Reply-To header will be set on each email sent.
|
||||||
If disabled with "--no-thread", no emails will have the In-Reply-To
|
If disabled with "--no-thread", no emails will have the In-Reply-To
|
||||||
|
|
|
@ -88,6 +88,12 @@ Options:
|
||||||
|
|
||||||
--smtp-ssl If set, connects to the SMTP server using SSL.
|
--smtp-ssl If set, connects to the SMTP server using SSL.
|
||||||
|
|
||||||
|
--suppress-cc Suppress the specified category of auto-CC. The category
|
||||||
|
can be one of 'author' for the patch author, 'self' to
|
||||||
|
avoid copying yourself, 'sob' for Signed-off-by lines,
|
||||||
|
'cccmd' for the output of the cccmd, or 'all' to suppress
|
||||||
|
all of these.
|
||||||
|
|
||||||
--suppress-from Suppress sending emails to yourself. Defaults to off.
|
--suppress-from Suppress sending emails to yourself. Defaults to off.
|
||||||
|
|
||||||
--thread Specify that the "In-Reply-To:" header should be set on all
|
--thread Specify that the "In-Reply-To:" header should be set on all
|
||||||
|
@ -180,12 +186,13 @@ my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
|
||||||
my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl);
|
my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl);
|
||||||
my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
|
my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
|
||||||
my ($no_validate);
|
my ($no_validate);
|
||||||
|
my (@suppress_cc);
|
||||||
|
|
||||||
my %config_bool_settings = (
|
my %config_bool_settings = (
|
||||||
"thread" => [\$thread, 1],
|
"thread" => [\$thread, 1],
|
||||||
"chainreplyto" => [\$chain_reply_to, 1],
|
"chainreplyto" => [\$chain_reply_to, 1],
|
||||||
"suppressfrom" => [\$suppress_from, 0],
|
"suppressfrom" => [\$suppress_from, undef],
|
||||||
"signedoffcc" => [\$signed_off_cc, 1],
|
"signedoffcc" => [\$signed_off_cc, undef],
|
||||||
"smtpssl" => [\$smtp_ssl, 0],
|
"smtpssl" => [\$smtp_ssl, 0],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -199,6 +206,7 @@ my %config_settings = (
|
||||||
"aliasfiletype" => \$aliasfiletype,
|
"aliasfiletype" => \$aliasfiletype,
|
||||||
"bcc" => \@bcclist,
|
"bcc" => \@bcclist,
|
||||||
"aliasesfile" => \@alias_files,
|
"aliasesfile" => \@alias_files,
|
||||||
|
"suppresscc" => \@suppress_cc,
|
||||||
);
|
);
|
||||||
|
|
||||||
# Begin by accumulating all the variables (defined above), that we will end up
|
# Begin by accumulating all the variables (defined above), that we will end up
|
||||||
|
@ -221,6 +229,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
|
||||||
"quiet" => \$quiet,
|
"quiet" => \$quiet,
|
||||||
"cc-cmd=s" => \$cc_cmd,
|
"cc-cmd=s" => \$cc_cmd,
|
||||||
"suppress-from!" => \$suppress_from,
|
"suppress-from!" => \$suppress_from,
|
||||||
|
"suppress-cc=s" => \@suppress_cc,
|
||||||
"signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
|
"signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
|
||||||
"dry-run" => \$dry_run,
|
"dry-run" => \$dry_run,
|
||||||
"envelope-sender=s" => \$envelope_sender,
|
"envelope-sender=s" => \$envelope_sender,
|
||||||
|
@ -266,6 +275,35 @@ foreach my $setting (values %config_bool_settings) {
|
||||||
${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]}));
|
${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Set CC suppressions
|
||||||
|
my(%suppress_cc);
|
||||||
|
if (@suppress_cc) {
|
||||||
|
foreach my $entry (@suppress_cc) {
|
||||||
|
die "Unknown --suppress-cc field: '$entry'\n"
|
||||||
|
unless $entry =~ /^(all|cccmd|cc|author|self|sob)$/;
|
||||||
|
$suppress_cc{$entry} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($suppress_cc{'all'}) {
|
||||||
|
foreach my $entry (qw (ccmd cc author self sob)) {
|
||||||
|
$suppress_cc{$entry} = 1;
|
||||||
|
}
|
||||||
|
delete $suppress_cc{'all'};
|
||||||
|
}
|
||||||
|
|
||||||
|
# If explicit old-style ones are specified, they trump --suppress-cc.
|
||||||
|
$suppress_cc{'self'} = $suppress_from if defined $suppress_from;
|
||||||
|
$suppress_cc{'sob'} = $signed_off_cc if defined $signed_off_cc;
|
||||||
|
|
||||||
|
# Debugging, print out the suppressions.
|
||||||
|
if (0) {
|
||||||
|
print "suppressions:\n";
|
||||||
|
foreach my $entry (keys %suppress_cc) {
|
||||||
|
printf " %-5s -> $suppress_cc{$entry}\n", $entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my ($repoauthor) = $repo->ident_person('author');
|
my ($repoauthor) = $repo->ident_person('author');
|
||||||
my ($repocommitter) = $repo->ident_person('committer');
|
my ($repocommitter) = $repo->ident_person('committer');
|
||||||
|
|
||||||
|
@ -711,11 +749,14 @@ foreach my $t (@files) {
|
||||||
|
|
||||||
} elsif (/^(Cc|From):\s+(.*)$/) {
|
} elsif (/^(Cc|From):\s+(.*)$/) {
|
||||||
if (unquote_rfc2047($2) eq $sender) {
|
if (unquote_rfc2047($2) eq $sender) {
|
||||||
next if ($suppress_from);
|
next if ($suppress_cc{'self'});
|
||||||
}
|
}
|
||||||
elsif ($1 eq 'From') {
|
elsif ($1 eq 'From') {
|
||||||
($author, $author_encoding)
|
($author, $author_encoding)
|
||||||
= unquote_rfc2047($2);
|
= unquote_rfc2047($2);
|
||||||
|
next if ($suppress_cc{'author'});
|
||||||
|
} else {
|
||||||
|
next if ($suppress_cc{'cc'});
|
||||||
}
|
}
|
||||||
printf("(mbox) Adding cc: %s from line '%s'\n",
|
printf("(mbox) Adding cc: %s from line '%s'\n",
|
||||||
$2, $_) unless $quiet;
|
$2, $_) unless $quiet;
|
||||||
|
@ -742,7 +783,7 @@ foreach my $t (@files) {
|
||||||
# line 2 = subject
|
# line 2 = subject
|
||||||
# So let's support that, too.
|
# So let's support that, too.
|
||||||
$input_format = 'lots';
|
$input_format = 'lots';
|
||||||
if (@cc == 0) {
|
if (@cc == 0 && !$suppress_cc{'cc'}) {
|
||||||
printf("(non-mbox) Adding cc: %s from line '%s'\n",
|
printf("(non-mbox) Adding cc: %s from line '%s'\n",
|
||||||
$_, $_) unless $quiet;
|
$_, $_) unless $quiet;
|
||||||
|
|
||||||
|
@ -759,10 +800,11 @@ foreach my $t (@files) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$message .= $_;
|
$message .= $_;
|
||||||
if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
|
if (/^(Signed-off-by|Cc): (.*)$/i) {
|
||||||
|
next if ($suppress_cc{'sob'});
|
||||||
my $c = $2;
|
my $c = $2;
|
||||||
chomp $c;
|
chomp $c;
|
||||||
next if ($c eq $sender and $suppress_from);
|
next if ($c eq $sender and $suppress_cc{'self'});
|
||||||
push @cc, $c;
|
push @cc, $c;
|
||||||
printf("(sob) Adding cc: %s from line '%s'\n",
|
printf("(sob) Adding cc: %s from line '%s'\n",
|
||||||
$c, $_) unless $quiet;
|
$c, $_) unless $quiet;
|
||||||
|
@ -771,7 +813,7 @@ foreach my $t (@files) {
|
||||||
}
|
}
|
||||||
close F;
|
close F;
|
||||||
|
|
||||||
if (defined $cc_cmd) {
|
if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
|
||||||
open(F, "$cc_cmd $t |")
|
open(F, "$cc_cmd $t |")
|
||||||
or die "(cc-cmd) Could not execute '$cc_cmd'";
|
or die "(cc-cmd) Could not execute '$cc_cmd'";
|
||||||
while(<F>) {
|
while(<F>) {
|
||||||
|
|
Loading…
Reference in New Issue