git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH] send-email: Add an option to suppress adding a specific email address
@ 2019-05-23  0:38 Eric W. Biederman
  2019-05-23  0:48 ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 3+ messages in thread
From: Eric W. Biederman @ 2019-05-23  0:38 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] send-email: Add an option to suppress adding a specific email address
  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
  0 siblings, 0 replies; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2019-05-23  0:48 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: git, Junio C Hamano


On Thu, May 23 2019, Eric W. Biederman wrote:

> 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.

I have a rewrite of much of the adjacent code queued in "next", can you
check if applying it to that branch makes this work as you expect?

Whether it does or not, this change should have a corresponding test
update to t/t9001-send-email.sh, so we can just run that to see if it's
doing the right thing.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] send-email: Add an option to suppress adding a specific email address
@ 2019-05-23  0:32 Eric W. Biederman
  0 siblings, 0 replies; 3+ messages in thread
From: Eric W. Biederman @ 2019-05-23  0:32 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-23  0:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
2019-05-23  0:32 Eric W. Biederman

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git