Skip to content

Commit ef0cc1d

Browse files
Villemoesgitster
authored andcommitted
send-email: also pick up cc addresses from -by trailers
When rerolling a patch series, including various Reviewed-by etc. that may have come in, it is quite convenient to have git-send-email automatically cc those people. So pick up any *-by lines, with a new suppression category 'misc-by', but special-case Signed-off-by, since that already has its own suppression category. It seems natural to make 'misc-by' implied by 'body'. Based-on-patch-by: Joe Perches <[email protected]> Signed-off-by: Rasmus Villemoes <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb34fe6 commit ef0cc1d

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

Documentation/git-send-email.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,11 @@ Automating
329329
patch body (commit message) except for self (use 'self' for that).
330330
- 'sob' will avoid including anyone mentioned in Signed-off-by lines except
331331
for self (use 'self' for that).
332+
- 'misc-by' will avoid including anyone mentioned in Acked-by,
333+
Reviewed-by, Tested-by and other "-by" lines in the patch body,
334+
except Signed-off-by (use 'sob' for that).
332335
- 'cccmd' will avoid running the --cc-cmd.
333-
- 'body' is equivalent to 'sob' + 'bodycc'.
336+
- 'body' is equivalent to 'sob' + 'bodycc' + 'misc-by'.
334337
- 'all' will suppress all auto cc values.
335338
--
336339
+

git-send-email.perl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ sub usage {
9494
--identity <str> * Use the sendemail.<id> options.
9595
--to-cmd <str> * Email To: via `<str> \$patch_path`
9696
--cc-cmd <str> * Email Cc: via `<str> \$patch_path`
97-
--suppress-cc <str> * author, self, sob, cc, cccmd, body, bodycc, all.
97+
--suppress-cc <str> * author, self, sob, cc, cccmd, body, bodycc, misc-by, all.
9898
--[no-]cc-cover * Email Cc: addresses in the cover letter.
9999
--[no-]to-cover * Email To: addresses in the cover letter.
100100
--[no-]signed-off-by-cc * Send to Signed-off-by: addresses. Default on.
@@ -454,13 +454,13 @@ sub read_config {
454454
if (@suppress_cc) {
455455
foreach my $entry (@suppress_cc) {
456456
die sprintf(__("Unknown --suppress-cc field: '%s'\n"), $entry)
457-
unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc)$/;
457+
unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc|misc-by)$/;
458458
$suppress_cc{$entry} = 1;
459459
}
460460
}
461461

462462
if ($suppress_cc{'all'}) {
463-
foreach my $entry (qw (cccmd cc author self sob body bodycc)) {
463+
foreach my $entry (qw (cccmd cc author self sob body bodycc misc-by)) {
464464
$suppress_cc{$entry} = 1;
465465
}
466466
delete $suppress_cc{'all'};
@@ -471,7 +471,7 @@ sub read_config {
471471
$suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc;
472472

473473
if ($suppress_cc{'body'}) {
474-
foreach my $entry (qw (sob bodycc)) {
474+
foreach my $entry (qw (sob bodycc misc-by)) {
475475
$suppress_cc{$entry} = 1;
476476
}
477477
delete $suppress_cc{'body'};
@@ -1681,7 +1681,7 @@ sub process_file {
16811681
# Now parse the message body
16821682
while(<$fh>) {
16831683
$message .= $_;
1684-
if (/^(Signed-off-by|Cc): (.*)/i) {
1684+
if (/^([a-z-]*-by|Cc): (.*)/i) {
16851685
chomp;
16861686
my ($what, $c) = ($1, $2);
16871687
# strip garbage for the address we'll use:
@@ -1691,8 +1691,13 @@ sub process_file {
16911691
if ($sc eq $sender) {
16921692
next if ($suppress_cc{'self'});
16931693
} else {
1694-
next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
1695-
next if $suppress_cc{'bodycc'} and $what =~ /Cc/i;
1694+
if ($what =~ /^Signed-off-by$/i) {
1695+
next if $suppress_cc{'sob'};
1696+
} elsif ($what =~ /-by$/i) {
1697+
next if $suppress_cc{'misc-by'};
1698+
} elsif ($what =~ /Cc/i) {
1699+
next if $suppress_cc{'bodycc'};
1700+
}
16961701
}
16971702
if ($c !~ /.+@.+|<.+>/) {
16981703
printf("(body) Ignoring %s from line '%s'\n",

0 commit comments

Comments
 (0)