Skip to contentSkip to conversation

git-send-email.perl: Fix handling of suppresscc option.

PATCH In review Jens Stimpfle 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-send-email.perl: Fix handling of suppresscc option.

---

Notes:
This patch makes sure that "sob", "cc" and "bodycc" values for sendemail.suppresscc option are handled, even when the email-addresses in question are equal to the sender and "self" in not configured in sendemail.suppresscc.

Sounds complicated, I know. But the current behaviour is really confusing: For example, when sending, git-send-email logs

(mbox) Adding cc: Jens Stimpfle <[email protected]> from line 'From: Jens Stimpfle <[email protected]>' (body) Adding cc: Jens Stimpfle <[email protected]> from line 'Signed-off-by: Jens Stimpfle <[email protected]>'

even though I have "sob" configured in sendemail.suppresscc.

With this patch, the suppression handling is also made consistent with the handling of the "author" value.

 git-send-email.perl | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
git-send-email.perl +5 -11
index 9949db0..452a783 100755
@@ -1377,11 +1377,8 @@ foreach my $t (@files) {
 				foreach my $addr (parse_address_line($1)) {
 					my $qaddr = unquote_rfc2047($addr);
 					my $saddr = sanitize_address($qaddr);
-					if ($saddr eq $sender) {
-						next if ($suppress_cc{'self'});
-					} else {
-						next if ($suppress_cc{'cc'});
-					}
+					next if $suppress_cc{'cc'};
+					next if $suppress_cc{'self'} and $saddr eq $sender;
 					printf("(mbox) Adding cc: %s from line '%s'\n",
 						$addr, $_) unless $quiet;
 					push @cc, $addr;
@@ -1425,12 +1422,9 @@ foreach my $t (@files) {
 			my ($what, $c) = ($1, $2);
 			chomp $c;
 			my $sc = sanitize_address($c);
-			if ($sc eq $sender) {
-				next if ($suppress_cc{'self'});
-			} 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{'sob'} and $what =~ /Signed-off-by/i;
+			next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
+			next if $suppress_cc{'self'} and $sc eq $sender;
 			push @cc, $c;
 			printf("(body) Adding cc: %s from line '%s'\n",
 				$c, $_) unless $quiet;
Signature · 1 line
2.1.1
#1 lore raw
Quoted 2 lines · Jens Stimpfle

---

Thanks.

Please do better than saying "Fix" to explain your changes in your log message.

Also, on the Subject:, s/Fix/fix/; s/option./option/ to match other entries in "git shortlog" message.

"What you think is broken" is clear (i.e. "supresscc option" is broken) with the subject line alone, but "How it is broken", "How it should behave instead", and "What are the differences between the broken and the correct behaviour" should be explained in the log message.

In other words, most of what you wrote below should come before your
S-o-b: line.

Quoted 8 lines

Notes:
...

git-send-email.perl +0 -0
index 9949db0..452a783 100755

git-send-email.perl foreach my $t (@files) { · line 1381

Quoted 10 lines
git-send-email.perl +2 -5
@@ -1377,11 +1377,8 @@ foreach my $t (@files) {
 				foreach my $addr (parse_address_line($1)) {
 					my $qaddr = unquote_rfc2047($addr);
 					my $saddr = sanitize_address($qaddr);
-					if ($saddr eq $sender) {
-						next if ($suppress_cc{'self'});
-					} else {
-						next if ($suppress_cc{'cc'});
-					}
+					next if $suppress_cc{'cc'};
+					next if $suppress_cc{'self'} and $saddr eq $sender;

This smells more like a change in behaviour than bugfix from a cursory look, though. It used to be that I could receive a copy by adding me to cc as long as I did not suppress 'self', even I squelched everybody else by suppressing 'cc'. I do not use such a configuration myself but I wonder if people rely on this behaviour as a feature.

git-send-email.perl foreach my $t (@files) { · line 1427

Quoted 13 lines
git-send-email.perl +3 -6
@@ -1425,12 +1422,9 @@ foreach my $t (@files) {
 			my ($what, $c) = ($1, $2);
 			chomp $c;
 			my $sc = sanitize_address($c);
-			if ($sc eq $sender) {
-				next if ($suppress_cc{'self'});
-			} 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{'sob'} and $what =~ /Signed-off-by/i;
+			next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
+			next if $suppress_cc{'self'} and $sc eq $sender;

Likewise.

I do like the updated logic flow in both hunks, though.

"When I say addresses on Cc: does not matter, it doesn't. No matter what the address in question is" (likewise for S-o-b:) is what the updated logic says. It is easier to explain than the traditional "The way to squelch my address is by 'suppress self'; for all other addresses on Cc:/S-o-b:, there are separate suppression methods".

But I have a slight suspicion that this special casing of 'self' was done on purpose, and people may be relying on it.

#2 lore raw

Junio, thanks for reviewing.

Quoted 8 lines · Junio C Hamano

"When I say addresses on Cc: does not matter, it doesn't. No matter what the address in question is" (likewise for S-o-b:) is what the updated logic says. It is easier to explain than the traditional "The way to squelch my address is by 'suppress self'; for all other addresses on Cc:/S-o-b:, there are separate suppression methods".

But I have a slight suspicion that this special casing of 'self' was done on purpose, and people may be relying on it.

It seems the behaviour is exactly described in the manpage. Sorry for having missed that.

The behaviour is super-complex and confusing, though. It's easy to imagine much simpler, intuitive and "transparent" ones.

But I have no experience with distributed git workflows so I'm absolutely not in the position to call it broken or provide a "fix".

Sorry for the noise.