{"thread":{"id":"51158","subject":"[PATCH] send-email: Add an option to suppress adding a specific email address","startedAt":"2019-05-23T00:38:35Z","lastAt":"2019-05-23T00:48:43Z","messageCount":2,"participants":["Eric W. Biederman","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"376089","messageId":"87d0kaj98f.fsf@xmission.com","threadId":"51158","inReplyTo":null,"subject":"[PATCH] send-email: Add an option to suppress adding a specific email address","fromName":"Eric W. Biederman","fromEmail":"ebiederm@xmission.com","sentAt":"2019-05-23T00:38:24Z","receivedAt":"2019-05-23T00:38:35Z","isPatch":true,"sender":{"key":"ebiederm@xmission.com","avatar":"https://avatars.githubusercontent.com/u/7477136?v=4"},"body":"\nMake it easy to suppress stable@vger.kernel.org.  Long story short it\nis desirable to have ``Cc: stable@vger.kernel.org'' on many bug fixes\nsent to the linux kernel.  It is not always desirable to actually the\nstable maintainer immediately as the patches are still being reviewed\netc.  Actually cc'd the stable maintainers in the linux kernel is not\neven really necessary as they will always find the tag after the patch\nhas been merged in the commit body.\n\nSo I am adding yet another suppress command \"suppress-addr\" that will\ntake an email address keep that email address from being automatically\nadded to a destination the email will be sent to.\n\nSigned-off-by: \"Eric W. Biederman\" <ebiederm@xmission.com>\n---\n Documentation/git-send-email.txt |  5 +++++\n git-send-email.perl              | 20 +++++++++++++++++++-\n 2 files changed, 24 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 1afe9fc858ea..9833d4dbd9f4 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -346,6 +346,11 @@ Default is the value of `sendemail.suppresscc` configuration value; if\n that is unspecified, default to 'self' if --suppress-from is\n specified, as well as 'body' if --no-signed-off-cc is specified.\n \n+--suppress-addr=<address>::\n+\tSpecify an address that should not be automatically copied\n+\ton any email.\n+\tDefault is the value of `sendemail.suppressaddr`.\n+\n --[no-]suppress-from::\n \tIf this is set, do not add the From: address to the cc: list.\n \tDefault is the value of `sendemail.suppressFrom` configuration\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 8eb63b5a2f8d..2ac0985f3f00 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -98,6 +98,7 @@ sub usage {\n     --to-cmd                <str>  * Email To: via `<str> \\$patch_path`\n     --cc-cmd                <str>  * Email Cc: via `<str> \\$patch_path`\n     --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, misc-by, all.\n+    --suppress-addr         <str>  * Don't automatically add the specified address\n     --[no-]cc-cover                * Email Cc: addresses in the cover letter.\n     --[no-]to-cover                * Email To: addresses in the cover letter.\n     --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.\n@@ -237,6 +238,7 @@ sub do_edit {\n my ($identity, $aliasfiletype, @alias_files, $smtp_domain, $smtp_auth);\n my ($validate, $confirm);\n my (@suppress_cc);\n+my (@suppress_addr);\n my ($auto_8bit_encoding);\n my ($compose_encoding);\n my $target_xfer_encoding = 'auto';\n@@ -274,6 +276,7 @@ sub do_edit {\n     \"aliasfiletype\" => \\$aliasfiletype,\n     \"bcc\" => \\@bcclist,\n     \"suppresscc\" => \\@suppress_cc,\n+    \"suppressaddr\" => \\@suppress_addr,\n     \"envelopesender\" => \\$envelope_sender,\n     \"confirm\"   => \\$confirm,\n     \"from\" => \\$sender,\n@@ -360,6 +363,7 @@ sub signal_handler {\n \t\t    \"suppress-from!\" => \\$suppress_from,\n \t\t    \"no-suppress-from\" => sub {$suppress_from = 0},\n \t\t    \"suppress-cc=s\" => \\@suppress_cc,\n+\t\t    \"suppress-addr=s\" => \\@suppress_addr,\n \t\t    \"signed-off-cc|signed-off-by-cc!\" => \\$signed_off_by_cc,\n \t\t    \"no-signed-off-cc|no-signed-off-by-cc\" => sub {$signed_off_by_cc = 0},\n \t\t    \"cc-cover|cc-cover!\" => \\$cover_cc,\n@@ -489,6 +493,16 @@ sub read_config {\n \tdelete $suppress_cc{'body'};\n }\n \n+# Set specific suppress addresses\n+my (%suppress_addr);\n+if (@suppress_addr) {\n+\tforeach my $addr (@suppress_addr) {\n+\t\tmy $qaddr = unquote_rfc2047($addr);\n+\t\tmy $saddr = sanitize_address($qaddr);\n+\t\t$suppress_addr{$saddr} = 1;\n+\t}\n+}\n+\n # Set confirm's default value\n my $confirm_unconfigured = !defined $confirm;\n if ($confirm_unconfigured) {\n@@ -1623,6 +1637,7 @@ sub process_file {\n \t\t\t\t$sauthor = sanitize_address($author);\n \t\t\t\tnext if $suppress_cc{'author'};\n \t\t\t\tnext if $suppress_cc{'self'} and $sauthor eq $sender;\n+\t\t\t\tnext if ($suppress_addr{$sauthor});\n \t\t\t\tprintf(__(\"(mbox) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t\t$1, $_) unless $quiet;\n \t\t\t\tpush @cc, $1;\n@@ -1642,6 +1657,7 @@ sub process_file {\n \t\t\t\t\t\tnext if ($suppress_cc{'self'});\n \t\t\t\t\t} else {\n \t\t\t\t\t\tnext if ($suppress_cc{'cc'});\n+\t\t\t\t\t\tnext if ($suppress_addr{$saddr});\n \t\t\t\t\t}\n \t\t\t\t\tprintf(__(\"(mbox) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t\t\t$addr, $_) unless $quiet;\n@@ -1681,7 +1697,7 @@ sub process_file {\n \t\t\t# line 2 = subject\n \t\t\t# So let's support that, too.\n \t\t\t$input_format = 'lots';\n-\t\t\tif (@cc == 0 && !$suppress_cc{'cc'}) {\n+\t\t\tif (@cc == 0 && !$suppress_cc{'cc'} && !$suppress_addr{$_}) {\n \t\t\t\tprintf(__(\"(non-mbox) Adding cc: %s from line '%s'\\n\"),\n \t\t\t\t\t$_, $_) unless $quiet;\n \t\t\t\tpush @cc, $_;\n@@ -1700,6 +1716,7 @@ sub process_file {\n \t\t\t$c = strip_garbage_one_address($c);\n \t\t\t# sanitize a bit more to decide whether to suppress the address:\n \t\t\tmy $sc = sanitize_address($c);\n+\t\t\tnext if ($suppress_addr{$sc});\n \t\t\tif ($sc eq $sender) {\n \t\t\t\tnext if ($suppress_cc{'self'});\n \t\t\t} else {\n@@ -1833,6 +1850,7 @@ sub recipients_cmd {\n \t\t$address =~ s/^\\s*//g;\n \t\t$address =~ s/\\s*$//g;\n \t\t$address = sanitize_address($address);\n+\t\tnext if ($suppress_addr{$address});\n \t\tnext if ($address eq $sender and $suppress_cc{'self'});\n \t\tpush @addresses, $address;\n \t\tprintf(__(\"(%s) Adding %s: %s from: '%s'\\n\"),\n-- \n2.21.0.dirty\n\n"},{"id":"376091","messageId":"87y32yt2qh.fsf@evledraar.gmail.com","threadId":"51158","inReplyTo":"87d0kaj98f.fsf@xmission.com","subject":"Re: [PATCH] send-email: Add an option to suppress adding a specific email address","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2019-05-23T00:48:38Z","receivedAt":"2019-05-23T00:48:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, May 23 2019, Eric W. Biederman wrote:\n\n> Make it easy to suppress stable@vger.kernel.org.  Long story short it\n> is desirable to have ``Cc: stable@vger.kernel.org'' on many bug fixes\n> sent to the linux kernel.  It is not always desirable to actually the\n> stable maintainer immediately as the patches are still being reviewed\n> etc.  Actually cc'd the stable maintainers in the linux kernel is not\n> even really necessary as they will always find the tag after the patch\n> has been merged in the commit body.\n>\n> So I am adding yet another suppress command \"suppress-addr\" that will\n> take an email address keep that email address from being automatically\n> added to a destination the email will be sent to.\n\nI have a rewrite of much of the adjacent code queued in \"next\", can you\ncheck if applying it to that branch makes this work as you expect?\n\nWhether it does or not, this change should have a corresponding test\nupdate to t/t9001-send-email.sh, so we can just run that to see if it's\ndoing the right thing.\n"}]}