# Re: [PATCH] git-send-email: Add a --cc-nobody option

5 messages from 2007-09-18 to 2007-09-18. Participants: Andreas Ericsson, Felipe Balbi, felipebalbi@users.sourceforge.net, Alex Unleashed.
Thread: https://gitlist.dev/t/9923

## felipebalbi@users.sourceforge.net, 2007-09-18 11:42

Subject: [PATCH] git-send-email: Add a --cc-nobody option
Message-ID: <11901157221792-git-send-email-felipebalbi@users.sourceforge.net>
URL: https://gitlist.dev/e/11901157221792-git-send-email-felipebalbi%40users.sourceforge.net

```
From: Felipe Balbi <felipe.lima@indt.org.br>

This patch adds a --cc-nobody option to avoid sending emails
to everybody but the ones listed by --to option.

Signed-off-by: Felipe Balbi <felipe.lima@indt.org.br>
---
 git-send-email.perl |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 4031e86..a5a466c 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -88,6 +88,9 @@ Options:
    --suppress-from Suppress sending emails to yourself if your address
                   appears in a From: line. Defaults to off.
 
+   --cc-nobody	  Do not send emails to anyone unless explicitly listed by
+		  --to option.
+
    --thread       Specify that the "In-Reply-To:" header should be set on all
                   emails. Defaults to on.
 
@@ -171,7 +174,7 @@ if ($@) {
 my ($quiet, $dry_run) = (0, 0);
 
 # Variables with corresponding config settings
-my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
+my ($thread, $chain_reply_to, $suppress_from, $cc_nobody, $signed_off_cc, $cc_cmd);
 my ($smtp_server, $smtp_authuser, $smtp_authpass, $smtp_ssl);
 my ($identity, $aliasfiletype, @alias_files);
 
@@ -179,6 +182,7 @@ my %config_bool_settings = (
     "thread" => [\$thread, 1],
     "chainreplyto" => [\$chain_reply_to, 1],
     "suppressfrom" => [\$suppress_from, 0],
+    "ccnobody" => [\$cc_nobody, 0],
     "signedoffcc" => [\$signed_off_cc, 1],
     "smtpssl" => [\$smtp_ssl, 0],
 );
@@ -212,6 +216,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "quiet" => \$quiet,
 		    "cc-cmd=s" => \$cc_cmd,
 		    "suppress-from!" => \$suppress_from,
+		    "cc-nobody!" => \$cc_nobody,
 		    "signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
 		    "dry-run" => \$dry_run,
 		    "envelope-sender=s" => \$envelope_sender,
@@ -669,8 +674,11 @@ foreach my $t (@files) {
 					$subject = $1;
 
 				} elsif (/^(Cc|From):\s+(.*)$/) {
-					if (unquote_rfc2047($2) eq $sender) {
-						next if ($suppress_from);
+					if (unquote_rfc2047($2)) {
+						next if ($cc_nobody);
+					}
+					elsif (unquote_rfc2047($2) eq $sender) {
+						next if ($suppress_from|$cc_nobody);
 					}
 					elsif ($1 eq 'From') {
 						$author = unquote_rfc2047($2);
@@ -707,7 +715,7 @@ foreach my $t (@files) {
 			}
 		} else {
 			$message .=  $_;
-			if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
+			if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc && !$cc_nobody) {
 				my $c = $2;
 				chomp $c;
 				push @cc, $c;
-- 
1.5.3.1.91.gd3392

```

## Andreas Ericsson, 2007-09-18 11:49

Subject: Re: [PATCH] git-send-email: Add a --cc-nobody option
Message-ID: <46EFBB5A.7090505@op5.se>
URL: https://gitlist.dev/e/46EFBB5A.7090505%40op5.se
In-Reply-To: <11901157221792-git-send-email-felipebalbi@users.sourceforge.net>

```
felipebalbi@users.sourceforge.net wrote:
> From: Felipe Balbi <felipe.lima@indt.org.br>
> 
> This patch adds a --cc-nobody option to avoid sending emails
> to everybody but the ones listed by --to option.
> 

Sounds much better than --suppress-all. Thanks

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Felipe Balbi, 2007-09-18 11:51

Subject: Re: [PATCH] git-send-email: Add a --cc-nobody option
Message-ID: <31e679430709180451h6e451c33lcc9c07e06cc2a869@mail.gmail.com>
URL: https://gitlist.dev/e/31e679430709180451h6e451c33lcc9c07e06cc2a869%40mail.gmail.com
In-Reply-To: <46EFBB5A.7090505@op5.se>

```
On 9/18/07, Andreas Ericsson <ae@op5.se> wrote:
> felipebalbi@users.sourceforge.net wrote:
> > From: Felipe Balbi <felipe.lima@indt.org.br>
> >
> > This patch adds a --cc-nobody option to avoid sending emails
> > to everybody but the ones listed by --to option.
> >
>
> Sounds much better than --suppress-all. Thanks

Yeah, sure...
np :-)

>
> --
> Andreas Ericsson                   andreas.ericsson@op5.se
> OP5 AB                             www.op5.se
> Tel: +46 8-230225                  Fax: +46 8-230231
>


-- 
Best Regards,

Felipe Balbi
felipebalbi@users.sourceforge.net

```

## Alex Unleashed, 2007-09-18 12:50

Subject: Re: [PATCH] git-send-email: Add a --cc-nobody option
Message-ID: <5e4707340709180550w3211e95fqd9fd648aab8ce78a@mail.gmail.com>
URL: https://gitlist.dev/e/5e4707340709180550w3211e95fqd9fd648aab8ce78a%40mail.gmail.com
In-Reply-To: <11901157221792-git-send-email-felipebalbi@users.sourceforge.net>

```
On 9/18/07, felipebalbi@users.sourceforge.net
<felipebalbi@users.sourceforge.net> wrote:
> From: Felipe Balbi <felipe.lima@indt.org.br>
>
> This patch adds a --cc-nobody option to avoid sending emails
> to everybody but the ones listed by --to option.
>
> Signed-off-by: Felipe Balbi <felipe.lima@indt.org.br>

I wrote a similar patch a couple months ago, but they differ slightly,
maybe the code has changed somewhat:
http://marc.info/?l=git&m=118200193310898&w=2

--cc-nobody sounds better to me.

>                                 } elsif (/^(Cc|From):\s+(.*)$/) {
> -                                       if (unquote_rfc2047($2) eq $sender) {
> -                                               next if ($suppress_from);
> +                                       if (unquote_rfc2047($2)) {
> +                                               next if ($cc_nobody);
> +                                       }
> +                                       elsif (unquote_rfc2047($2) eq $sender) {
> +                                               next if ($suppress_from|$cc_nobody);
>                                         }
>                                         elsif ($1 eq 'From') {
>                                                 $author = unquote_rfc2047($2);

Here you could probably skip the whole branch if you check $cc_nobody
first of all.

> @@ -707,7 +715,7 @@ foreach my $t (@files) {
>                         }
>                 } else {
>                         $message .=  $_;
> -                       if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
> +                       if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc && !$cc_nobody) {

Minor, but almost the same here.

Alex

```

## Felipe Balbi, 2007-09-18 13:01

Subject: Re: [PATCH] git-send-email: Add a --cc-nobody option
Message-ID: <31e679430709180601h15d0d315ub13bfd2c6763f181@mail.gmail.com>
URL: https://gitlist.dev/e/31e679430709180601h15d0d315ub13bfd2c6763f181%40mail.gmail.com
In-Reply-To: <5e4707340709180550w3211e95fqd9fd648aab8ce78a@mail.gmail.com>

```
hi,

On 9/18/07, Alex Unleashed <unledev@gmail.com> wrote:
> On 9/18/07, felipebalbi@users.sourceforge.net
> <felipebalbi@users.sourceforge.net> wrote:
> > From: Felipe Balbi <felipe.lima@indt.org.br>
> >
> > This patch adds a --cc-nobody option to avoid sending emails
> > to everybody but the ones listed by --to option.
> >
> > Signed-off-by: Felipe Balbi <felipe.lima@indt.org.br>
>
> I wrote a similar patch a couple months ago, but they differ slightly,
> maybe the code has changed somewhat:
> http://marc.info/?l=git&m=118200193310898&w=2
>
> --cc-nobody sounds better to me.
>
> >                                 } elsif (/^(Cc|From):\s+(.*)$/) {
> > -                                       if (unquote_rfc2047($2) eq $sender) {
> > -                                               next if ($suppress_from);
> > +                                       if (unquote_rfc2047($2)) {
> > +                                               next if ($cc_nobody);
> > +                                       }
> > +                                       elsif (unquote_rfc2047($2) eq $sender) {
> > +                                               next if ($suppress_from|$cc_nobody);
> >                                         }
> >                                         elsif ($1 eq 'From') {
> >                                                 $author = unquote_rfc2047($2);
>
> Here you could probably skip the whole branch if you check $cc_nobody
> first of all.

Yeah, I tested this one too but when sending emails I was changing all
those From lines to my address, which means every mail I was sending
the patch would take my authorship.

So it looked better guaranteeing the authorship

>
> > @@ -707,7 +715,7 @@ foreach my $t (@files) {
> >                         }
> >                 } else {
> >                         $message .=  $_;
> > -                       if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
> > +                       if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc && !$cc_nobody) {
>
> Minor, but almost the same here.

sanity

>
> Alex
>


-- 
Best Regards,

Felipe Balbi
felipebalbi@users.sourceforge.net

```
