git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: <git@vger.kernel.org>
Cc: Junio C Hamano <junkio@cox.net>
Subject: [PATCH] send-email: Add an option to suppress adding a specific email address
Date: Wed, 22 May 2019 19:32:27 -0500	[thread overview]
Message-ID: <87ftp6j9ic.fsf@xmission.com> (raw)


Make it easy to suppress stable@vger.kernel.org.  Long story short it
is desirable to have ``Cc: stable@vger.kernel.org'' on many bug fixes
sent to the linux kernel.  It is not always desirable to actually the
stable maintainer immediately as the patches are still being reviewed
etc.  Actually cc'd the stable maintainers in the linux kernel is not
even really necessary as they will always find the tag after the patch
has been merged in the commit body.

So I am adding yet another suppress command "suppress-addr" that will
take an email address keep that email address from being automatically
added to a destination the email will be sent to.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 Documentation/git-send-email.txt |  5 +++++
 git-send-email.perl              | 20 +++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 1afe9fc858ea..9833d4dbd9f4 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -346,6 +346,11 @@ Default is the value of `sendemail.suppresscc` configuration value; if
 that is unspecified, default to 'self' if --suppress-from is
 specified, as well as 'body' if --no-signed-off-cc is specified.
 
+--suppress-addr=<address>::
+	Specify an address that should not be automatically copied
+	on any email.
+	Default is the value of `sendemail.suppressaddr`.
+
 --[no-]suppress-from::
 	If this is set, do not add the From: address to the cc: list.
 	Default is the value of `sendemail.suppressFrom` configuration
diff --git a/git-send-email.perl b/git-send-email.perl
index 8eb63b5a2f8d..2ac0985f3f00 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -98,6 +98,7 @@ sub usage {
     --to-cmd                <str>  * Email To: via `<str> \$patch_path`
     --cc-cmd                <str>  * Email Cc: via `<str> \$patch_path`
     --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, misc-by, all.
+    --suppress-addr         <str>  * Don't automatically add the specified address
     --[no-]cc-cover                * Email Cc: addresses in the cover letter.
     --[no-]to-cover                * Email To: addresses in the cover letter.
     --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.
@@ -237,6 +238,7 @@ sub do_edit {
 my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);
 my ($validate, $confirm);
 my (@suppress_cc);
+my (@suppress_addr);
 my ($auto_8bit_encoding);
 my ($compose_encoding);
 my $target_xfer_encoding = 'auto';
@@ -274,6 +276,7 @@ sub do_edit {
     "aliasfiletype" => \$aliasfiletype,
     "bcc" => \@bcclist,
     "suppresscc" => \@suppress_cc,
+    "suppressaddr" => \@suppress_addr,
     "envelopesender" => \$envelope_sender,
     "confirm"   => \$confirm,
     "from" => \$sender,
@@ -360,6 +363,7 @@ sub signal_handler {
 		    "suppress-from!" => \$suppress_from,
 		    "no-suppress-from" => sub {$suppress_from = 0},
 		    "suppress-cc=s" => \@suppress_cc,
+		    "suppress-addr=s" => \@suppress_addr,
 		    "signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc,
 		    "no-signed-off-cc|no-signed-off-by-cc" => sub {$signed_off_by_cc = 0},
 		    "cc-cover|cc-cover!" => \$cover_cc,
@@ -489,6 +493,16 @@ sub read_config {
 	delete $suppress_cc{'body'};
 }
 
+# Set specific suppress addresses
+my (%suppress_addr);
+if (@suppress_addr) {
+	foreach my $addr (@suppress_addr) {
+		my $qaddr = unquote_rfc2047($addr);
+		my $saddr = sanitize_address($qaddr);
+		$suppress_addr{$saddr} = 1;
+	}
+}
+
 # Set confirm's default value
 my $confirm_unconfigured = !defined $confirm;
 if ($confirm_unconfigured) {
@@ -1623,6 +1637,7 @@ sub process_file {
 				$sauthor = sanitize_address($author);
 				next if $suppress_cc{'author'};
 				next if $suppress_cc{'self'} and $sauthor eq $sender;
+				next if ($suppress_addr{$sauthor});
 				printf(__("(mbox) Adding cc: %s from line '%s'\n"),
 					$1, $_) unless $quiet;
 				push @cc, $1;
@@ -1642,6 +1657,7 @@ sub process_file {
 						next if ($suppress_cc{'self'});
 					} else {
 						next if ($suppress_cc{'cc'});
+						next if ($suppress_addr{$saddr});
 					}
 					printf(__("(mbox) Adding cc: %s from line '%s'\n"),
 						$addr, $_) unless $quiet;
@@ -1681,7 +1697,7 @@ sub process_file {
 			# line 2 = subject
 			# So let's support that, too.
 			$input_format = 'lots';
-			if (@cc == 0 && !$suppress_cc{'cc'}) {
+			if (@cc == 0 && !$suppress_cc{'cc'} && !$suppress_addr{$_}) {
 				printf(__("(non-mbox) Adding cc: %s from line '%s'\n"),
 					$_, $_) unless $quiet;
 				push @cc, $_;
@@ -1700,6 +1716,7 @@ sub process_file {
 			$c = strip_garbage_one_address($c);
 			# sanitize a bit more to decide whether to suppress the address:
 			my $sc = sanitize_address($c);
+			next if ($suppress_addr{$sc});
 			if ($sc eq $sender) {
 				next if ($suppress_cc{'self'});
 			} else {
@@ -1833,6 +1850,7 @@ sub recipients_cmd {
 		$address =~ s/^\s*//g;
 		$address =~ s/\s*$//g;
 		$address = sanitize_address($address);
+		next if ($suppress_addr{$address});
 		next if ($address eq $sender and $suppress_cc{'self'});
 		push @addresses, $address;
 		printf(__("(%s) Adding %s: %s from: '%s'\n"),
-- 
2.21.0.dirty


             reply	other threads:[~2019-05-23  0:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  0:32 Eric W. Biederman [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-05-23  0:38 [PATCH] send-email: Add an option to suppress adding a specific email address Eric W. Biederman
2019-05-23  0:48 ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ftp6j9ic.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).