Skip to contentSkip to conversation

git-send-email: Add auto-cc to all body signatures

PATCH In review Joe Perches 4 participants 10 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-send-email: Add auto-cc to all body signatures

Many types of signatures are used by various projects.

The most common type is formatted:
"[some_signature_type]-by: First Last <[email protected]>"
e.g:
"Reported-by: First Last <[email protected]>" (no quotes are used)

Make git-send-email use these signatures as "CC:" entries.

Add command line option --suppress-cc=signatures to avoid adding these entries to the cc.

---
 Documentation/git-send-email.txt |    3 ++-
 git-send-email.perl              |   11 ++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)
Documentation/git-send-email.txt +2 -1
index 327233c..17ea825 100644
@@ -246,8 +246,9 @@ Automating
   patch body (commit message) except for self (use 'self' for that).
 - 'sob' will avoid including anyone mentioned in Signed-off-by lines except
    for self (use 'self' for that).
+- 'signatures' will avoid including anyone mentioned in any "<foo>-by:" lines.
 - 'cccmd' will avoid running the --cc-cmd.
-- 'body' is equivalent to 'sob' + 'bodycc'
+- 'body' is equivalent to 'sob' + 'bodycc + signatures'
 - 'all' will suppress all auto cc values.
 --
 +
git-send-email.perl +6 -5
index 98ab33a..973ed65 100755
@@ -75,7 +75,7 @@ git send-email [options] <file | directory | rev-list options >
     --identity              <str>  * Use the sendemail.<id> options.
     --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, all.
+    --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, signatures, all.
     --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.
     --[no-]suppress-from           * Send to self. Default off.
     --[no-]chain-reply-to          * Chain In-Reply-To: fields. Default off.
@@ -374,13 +374,13 @@ 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|body|bodycc)$/;
+			unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc|signatures)$/;
 		$suppress_cc{$entry} = 1;
 	}
 }
 
 if ($suppress_cc{'all'}) {
-	foreach my $entry (qw (cccmd cc author self sob body bodycc)) {
+	foreach my $entry (qw (cccmd cc author self sob body bodycc signatures)) {
 		$suppress_cc{$entry} = 1;
 	}
 	delete $suppress_cc{'all'};
@@ -391,7 +391,7 @@ $suppress_cc{'self'} = $suppress_from if defined $suppress_from;
 $suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc;
 
 if ($suppress_cc{'body'}) {
-	foreach my $entry (qw (sob bodycc)) {
+	foreach my $entry (qw (sob bodycc signatures)) {
 		$suppress_cc{$entry} = 1;
 	}
 	delete $suppress_cc{'body'};
@@ -1251,7 +1251,7 @@ foreach my $t (@files) {
 	# Now parse the message body
 	while(<$fh>) {
 		$message .=  $_;
-		if (/^(Signed-off-by|Cc): (.*)$/i) {
+		if (/^(Signed-off-by|Cc|[a-z_-]+by): (.*)$/i) {
 			chomp;
 			my ($what, $c) = ($1, $2);
 			chomp $c;
@@ -1260,6 +1260,7 @@ foreach my $t (@files) {
 			} else {
 				next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
 				next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
+				next if $suppress_cc{'signatures'} and $what =~ /by$/i;
 			}
 			push @cc, $c;
 			printf("(body) Adding cc: %s from line '%s'\n",
Signature · 1 line
1.7.6.131.g99019
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Joe Perches

Many types of signatures are used by various projects.

The most common type is formatted:
"[some_signature_type]-by: First Last <[email protected]>"
e.g:
"Reported-by: First Last <[email protected]>" (no quotes are
used)

Quoted 6 lines

Make git-send-email use these signatures as "CC:" entries.

Add command line option --suppress-cc=signatures to avoid adding these entries to the cc.

Thanks, I was getting tired of having to add CC: <blah> especially since we already had Reported-by: <blah> and Tested-by: <blah>, yet they were never copied on the patch.

#2 lore raw

PATCH 1/1 git-send-email: Add auto-cc to all body signatures

Many types of signatures are used by various projects.

The most common type is formatted:
"[some_signature_type]-by: First Last <[email protected]>"
e.g:
"Reported-by: First Last <[email protected]>" (no quotes are used)

Make git-send-email use these signatures as "CC:" entries.

Add command line option --suppress-cc=signatures to avoid adding these entries to the cc.

---
 Documentation/git-send-email.txt |    3 ++-
 git-send-email.perl              |   11 ++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)
Documentation/git-send-email.txt +2 -1
index 327233c..17ea825 100644
@@ -246,8 +246,9 @@ Automating
   patch body (commit message) except for self (use 'self' for that).
 - 'sob' will avoid including anyone mentioned in Signed-off-by lines except
    for self (use 'self' for that).
+- 'signatures' will avoid including anyone mentioned in any "<foo>-by:" lines.
 - 'cccmd' will avoid running the --cc-cmd.
-- 'body' is equivalent to 'sob' + 'bodycc'
+- 'body' is equivalent to 'sob' + 'bodycc + signatures'
 - 'all' will suppress all auto cc values.
 --
 +
git-send-email.perl +6 -5
index d491db9..fc5bf41 100755
@@ -75,7 +75,7 @@ git send-email [options] <file | directory | rev-list options >
     --identity              <str>  * Use the sendemail.<id> options.
     --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, all.
+    --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, signatures, all.
     --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.
     --[no-]suppress-from           * Send to self. Default off.
     --[no-]chain-reply-to          * Chain In-Reply-To: fields. Default off.
@@ -393,13 +393,13 @@ 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|body|bodycc)$/;
+			unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc|signatures)$/;
 		$suppress_cc{$entry} = 1;
 	}
 }
 
 if ($suppress_cc{'all'}) {
-	foreach my $entry (qw (cccmd cc author self sob body bodycc)) {
+	foreach my $entry (qw (cccmd cc author self sob body bodycc signatures)) {
 		$suppress_cc{$entry} = 1;
 	}
 	delete $suppress_cc{'all'};
@@ -410,7 +410,7 @@ $suppress_cc{'self'} = $suppress_from if defined $suppress_from;
 $suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc;
 
 if ($suppress_cc{'body'}) {
-	foreach my $entry (qw (sob bodycc)) {
+	foreach my $entry (qw (sob bodycc signatures)) {
 		$suppress_cc{$entry} = 1;
 	}
 	delete $suppress_cc{'body'};
@@ -1276,7 +1276,7 @@ foreach my $t (@files) {
 	# Now parse the message body
 	while(<$fh>) {
 		$message .=  $_;
-		if (/^(Signed-off-by|Cc): (.*)$/i) {
+		if (/^(Signed-off-by|Cc|[a-z_-]+by): (.*)$/i) {
 			chomp;
 			my ($what, $c) = ($1, $2);
 			chomp $c;
@@ -1285,6 +1285,7 @@ foreach my $t (@files) {
 			} else {
 				next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
 				next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
+				next if $suppress_cc{'signatures'} and $what =~ /by$/i;
 			}
 			push @cc, $c;
 			printf("(body) Adding cc: %s from line '%s'\n",
Signature · 1 line
1.7.8.dirty
#3 lore raw
Quoted 6 lines · Joe Perches

Many types of signatures are used by various projects.

The most common type is formatted:
"[some_signature_type]-by: First Last <[email protected]>"
e.g:
"Reported-by: First Last <[email protected]>" (no quotes are used)

This is just a phrasing issue, but I am a bit reluctant about the name "signature". "Acked-by:", "Tested-by:" and "Reviewed-by:" are originally written in the message sent to the author by the person who is giving an Ack, a successful test report, and a review comment, and the author (at least in spirit) copies & pastes them to the final text used in the commit log message, so it would not be incorrect to call them "signatures". But other "Random-by:" would not fall into that pattern.

"Reported-by:" certainly does not. It is almost always added by the author of the patch that is different from the reporter, and the reporter wouldn't have written "Reported-by: me" in the original bug report that triggered the discussion and resulted in the commit to fix the bug. Such a line is certainly not a signature of/by the reporter. Same can be said for "Helped-by:" for the author to share credits.

Also I've seen these "Random-by:", especially the ones that the author adds on his own initiative like "Reported-by:", followed by just a name but not an addresses [*1*].

Does your change do the right thing on such an address-less entry? The answer to this question must start with the definition of "the right thing to do is X", of course.

Documentation/git-send-email.txt Automating · line 251

Quoted 12 lines
Documentation/git-send-email.txt +2 -1
index 327233c..17ea825 100644
@@ -246,8 +246,9 @@ Automating
   patch body (commit message) except for self (use 'self' for that).
 - 'sob' will avoid including anyone mentioned in Signed-off-by lines except
    for self (use 'self' for that).
+- 'signatures' will avoid including anyone mentioned in any "<foo>-by:" lines.
 - 'cccmd' will avoid running the --cc-cmd.
-- 'body' is equivalent to 'sob' + 'bodycc'
+- 'body' is equivalent to 'sob' + 'bodycc + signatures'

The quotes do not match quite well.

[Footnote]

*1* This seems to be done deliberately so; I understand that this is to avoid running afoul of EU privacy legislation or something.

#4 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Joe Perches

Many types of signatures are used by various projects.
The most common type is formatted:
"[some_signature_type]-by: First Last <[email protected]>"
e.g:
"Reported-by: First Last <[email protected]>" (no quotes are used)

This is just a phrasing issue, but I am a bit reluctant about the name "signature".

I've called all these markings signatures. Maybe email-address-tags or another name could be used. I'm not bothered one way or another by any chosen name.

Quoted 3 lines

Does your change do the right thing on such an address-less entry? The answer to this question must start with the definition of "the right thing to do is X", of course.

All addresses go through "extract_valid_address". Invalid addresses are not used.

#5 lore raw
Quoted 7 lines · Joe Perches
Quoted 6 lines · Junio C Hamano
Quoted 5 lines · Joe Perches

Many types of signatures are used by various projects.
The most common type is formatted:
"[some_signature_type]-by: First Last <[email protected]>"
e.g:
"Reported-by: First Last <[email protected]>" (no quotes are used)

Quoted 6 lines
Quoted 2 lines

This is just a phrasing issue, but I am a bit reluctant about the name "signature".

I've called all these markings signatures. Maybe email-address-tags or another name could be used. I'm not bothered one way or another by any chosen name.

It's been four years, but I recently ran into this. I mistakenly thought that git would actually pick up cc addresses also from Reported-by, so the reporter ended up not being cc'ed. Is there any chance this could be revisited, or should I use a --cc-cmd to do what I want?

Rasmus

#6 lore raw

PATCH v3 1/1 git-send-email: Add auto-cc to all body signatures

Many types of signatures are used by various projects.

The most common type is formatted:
"[some_signature_type]-by: First Last <email <at> domain.tld>"
e.g:
"Reported-by: First Last <email <at> domain.tld>" (no quotes are used)

Make git-send-email use these signatures as "CC:" entries.

Add command line option --suppress-cc=signatures to avoid adding these entries to the cc.

Signed-off-by Joe Perches <joe <at> perches.com>
Acked-by Jeff Kirsher <jeffrey.t.kirsher <at> intel.com>

---

Quoted 4 lines

It's been four years, but I recently ran into this. I mistakenly thought that git would actually pick up cc addresses also from Reported-by, so the reporter ended up not being cc'ed. Is there any chance this could be revisited,

Here's a refresh if desired.  I still think it's sensible.

 Documentation/git-send-email.txt |  3 ++- git-send-email.perl              | 11 ++++++-----

 2 files changed, 8 insertions(+), 6 deletions(-)
Documentation/git-send-email.txt +0 -0
index b9134d2..0866ae2 100644
@@ -306,8 +306,9 @@ Automating

   patch body (commit message) except for self (use 'self' for that).
 - 'sob' will avoid including anyone mentioned in Signed-off-by lines except for self (use 'self' for that).
+- 'signatures' will avoid including anyone mentioned in any "<foo>-by:" lines.
 - 'cccmd' will avoid running the --cc-cmd.
-- 'body' is equivalent to 'sob' + 'bodycc'
+- 'body' is equivalent to 'sob' + 'bodycc' + 'signatures'
 - 'all' will suppress all auto cc values.
 --
 +

git-send-email.perl +0 -0
index e907e0ea..536e264 100755
@@ -83,7 +83,7 @@ git send-email [options] <file | directory | rev-list options >

     --identity              <str>  * Use the sendemail.<id> options.
     --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, all. +    --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, signatures, all. --[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. @@ -421,13 +421,13 @@ 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|body|bodycc)$/;
+			unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc|signatures)$/;

  $suppress_cc{$entry} = 1;
  }
 }

 if ($suppress_cc{'all'}) {
- foreach my $entry (qw (cccmd cc author self sob body bodycc)) {
+ foreach my $entry (qw (cccmd cc author self sob body bodycc signatures)) {
  $suppress_cc{$entry} = 1;
  }
  delete $suppress_cc{'all'};
@@ -438,7 +438,7 @@ $suppress_cc{'self'} = $suppress_from if defined $suppress_from; $suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc;

 if ($suppress_cc{'body'}) {
- foreach my $entry (qw (sob bodycc)) {
+ foreach my $entry (qw (sob bodycc signatures)) {
  $suppress_cc{$entry} = 1;
  }
  delete $suppress_cc{'body'};
@@ -1516,7 +1516,7 @@ foreach my $t (@files) {
  # Now parse the message body
  while(<$fh>) {
  $message .=  $_;
- if (/^(Signed-off-by|Cc): (.*)$/i) {
+ if (/^(Signed-off-by|Cc|[^\s]+[_-]by): (.*)$/i) {
  chomp;
  my ($what, $c) = ($1, $2);
  chomp $c;
@@ -1526,6 +1526,7 @@ foreach my $t (@files) {
  } else {
  next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i; next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
+ next if $suppress_cc{'signatures'} and $what =~ /by$/i;
  }
  push @cc, $c;
  printf("(body) Adding cc: %s from line '%s'\n",

#7 lore raw
Quoted 7 lines · Joe Perches

Many types of signatures are used by various projects.

The most common type is formatted:
"[some_signature_type]-by: First Last <email <at> domain.tld>"
e.g:
"Reported-by: First Last <email <at> domain.tld>" (no quotes are used)

Quoted 7 lines

Make git-send-email use these signatures as "CC:" entries.

Add command line option --suppress-cc=signatures to avoid adding these entries to the cc.

Signed-off-by Joe Perches <joe <at> perches.com>
Acked-by Jeff Kirsher <jeffrey.t.kirsher <at> intel.com>

I wonder what send-email with this patch does to the above two lines with "<at>" not "@" ;-) How was this patch sent?

In any case, did you mean "Helped-by:" not "Acked-by:"? "git shortlog git-send-email.perl" does not show that name as one of the major stakeholders who would be capable of giving an Ack on it.

Quoted 7 lines

---

Quoted 4 lines

It's been four years, but I recently ran into this. I mistakenly thought that git would actually pick up cc addresses also from Reported-by, so the reporter ended up not being cc'ed. Is there any chance this could be revisited,

Here's a refresh if desired. I still think it's sensible.

What the patch tries to achieve may make a lot of sense. I however do not necessarily think this particular implementation does, unfortunately.

These "Random-by:", especially the ones that the author adds on his own initiative like "Reported-by:", are often followed by just a name but not an addresses. A "Signed-off-by:" and "Cc:" that is not followed by a valid e-mail address may deserve to get an error (or perhaps an end-user interaction "This is not a valid address. What do you want to do about it?") so "/^(Signed-off-by|Cc): (.*)$/i" does not need its own sanity check on $2, because a later call to extract-valid-address or extract-valid-address-or-die will take care of it.

It would however be wrong to cause the program to error out or even bother the user upon seeing such random trailer lines that the author did not mean to have an e-mail address on it in the first place. If you have a trailer line

Random-by: Joe Perches

without an address, I suspect you will end up adding "Joe" and "Perches" as two addresses on the Cc: line, which is most likely not what the user intended [*1*].

As to the lingo, these are still not signatures, but during the past years, it seems that we settled on using the term "trailers" for these e-mail header-like things at the end of the log message. "Trailers" are not limited to "*-by:" so this patch is not about adding auto-cc to all trailers--a retitle would be

send-email: add auto-cc to addresses that appear on *-by: trailers

or something (and the option and variable names may need to be updated to match).

[Footnote]

*1* I further suspect that the existing code shares a similar issue. Don't Cc: and Signed-off-by: expect a single address on each line in the usual fashion? Perhaps a two-patch series whose first part does

- if (/^(Signed-off-by|Cc): (.*)$/i) {
+ if (/^(Signed-off-by|Cc): (.*<[^>]*>)\s*$/i) {

to tighten it (so that "Cc: Joe Perches" would not result in two pieces of mail sent to Joe and Perches), with your patch as a follow up, may be a good way forward.

I dunno.

#8 lore raw
Quoted 11 lines · Junio C Hamano
Quoted 9 lines · Joe Perches

Many types of signatures are used by various projects.

The most common type is formatted:
"[some_signature_type]-by: First Last <email <at> domain.tld>"
e.g:
"Reported-by: First Last <email <at> domain.tld>" (no quotes are used)

Make git-send-email use these signatures as "CC:" entries.

Quoted 8 lines
Quoted 5 lines

Add command line option --suppress-cc=signatures to avoid adding these entries to the cc.

Signed-off-by Joe Perches perches.com>
Acked-by Jeff Kirsher intel.com>

I wonder what send-email with this patch does to the above two lines with "" not "@" ;-)  How was this patch sent?

gnome evolution v3.18.2 email client.

And it seems all newer versions of evolution beyond 3.12 are really, really poor at sending inline patches. <grumble>

I'll update and resend using git-send-email eventually

Quoted 3 lines

In any case, did you mean "Helped-by:" not "Acked-by:"?  "git shortlog git-send-email.perl" does not show that name as one of the major stakeholders who would be capable of giving an Ack on it.

At least for linux-kernel, "Acked-by:" doesn't mean a maintainer or a contributor to a particular module/file, just someone that has looked at the patch, tried it, and approved of the concept.

I don't know what process git uses for approval/signatures.

Quoted 27 lines
Quoted 7 lines

---

Quoted 4 lines

It's been four years, but I recently ran into this. I mistakenly thought that git would actually pick up cc addresses also from Reported-by, so the reporter ended up not being cc'ed. Is there any chance this could be revisited,

Here's a refresh if desired.  I still think it's sensible.

What the patch tries to achieve may make a lot of sense.  I however do not necessarily think this particular implementation does, unfortunately.

These "Random-by:", especially the ones that the author adds on his own initiative like "Reported-by:", are often followed by just a name but not an addresses.  A "Signed-off-by:" and "Cc:" that is not followed by a valid e-mail address may deserve to get an error (or perhaps an end-user interaction "This is not a valid address. What do you want to do about it?") so "/^(Signed-off-by|Cc): (.*)$/i" does not need its own sanity check on $2, because a later call to extract-valid-address or extract-valid-address-or-die will take care of it.

It would however be wrong to cause the program to error out or even bother the user upon seeing such random trailer lines that the author did not mean to have an e-mail address on it in the first place.  If you have a trailer line

Quoted 5 lines

    Random-by: Joe Perches

without an address, I suspect you will end up adding "Joe" and "Perches" as two addresses on the Cc: line, which is most likely not what the user intended [*1*].

At least with new versions of git-send-email.perl that's true so the patch will need to validate that there is an email address following.

Quoted 21 lines

As to the lingo, these are still not signatures, but during the past years, it seems that we settled on using the term "trailers" for these e-mail header-like things at the end of the log message. "Trailers" are not limited to "*-by:" so this patch is not about adding auto-cc to all trailers--a retitle would be

    send-email: add auto-cc to addresses that appear on *-by: trailers

or something (and the option and variable names may need to be updated to match).

[Footnote]

*1* I further suspect that the existing code shares a similar issue. Don't Cc: and Signed-off-by: expect a single address on each line in the usual fashion?  Perhaps a two-patch series whose first part does

(quoted diff) +1 -1
-		if (/^(Signed-off-by|Cc): (.*)$/i) {
+		if (/^(Signed-off-by|Cc): (.*<[^>]*>)\s*$/i) {
Quoted 5 lines

to tighten it (so that "Cc: Joe Perches" would not result in two pieces of mail sent to Joe and Perches), with your patch as a follow up, may be a good way forward.

I dunno.

I believe the old git-send-email code required addresses and validated the form after Signed-off-by:'s.

I haven't looked at the code for several years and just refreshed it without much thinking or testing.

I'll do a bit more and resend.