Skip to content

Commit 2f5bd34

Browse files
JoePerchestorvalds
authored andcommitted
scripts/get_maintainer.pl: add signatures from Fixes: <badcommit> lines in commit message
A Fixes: lines in a commit message generally indicate that a previous commit was inadequate for whatever reason. The signers of the previous inadequate commit should also be cc'd on this new commit so update get_maintainer to find the old commit and add the original signers. Link: http://lkml.kernel.org/r/33605b9fc0e0f711236951ae84185a6218acff4f.camel@perches.com Signed-off-by: Joe Perches <joe@perches.com> Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 24b54fe commit 2f5bd34

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

‎scripts/get_maintainer.pl‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
my $email_usename = 1;
2727
my $email_maintainer = 1;
2828
my $email_reviewer = 1;
29+
my $email_fixes = 1;
2930
my $email_list = 1;
3031
my $email_moderated_list = 1;
3132
my $email_subscriber_list = 0;
@@ -249,6 +250,7 @@
249250
'r!' => \$email_reviewer,
250251
'n!' => \$email_usename,
251252
'l!' => \$email_list,
253+
'fixes!' => \$email_fixes,
252254
'moderated!' => \$email_moderated_list,
253255
's!' => \$email_subscriber_list,
254256
'multiline!' => \$output_multiline,
@@ -503,6 +505,7 @@ sub read_mailmap {
503505
## use the filenames on the command line or find the filenames in the patchfiles
504506

505507
my @files = ();
508+
my @fixes = (); # If a patch description includes Fixes: lines
506509
my @range = ();
507510
my @keyword_tvi = ();
508511
my @file_emails = ();
@@ -568,6 +571,8 @@ sub read_mailmap {
568571
my $filename2 = $2;
569572
push(@files, $filename1);
570573
push(@files, $filename2);
574+
} elsif (m/^Fixes:\s+([0-9a-fA-F]{6,40})/) {
575+
push(@fixes, $1) if ($email_fixes);
571576
} elsif (m/^\+\+\+\s+(\S+)/ or m/^---\s+(\S+)/) {
572577
my $filename = $1;
573578
$filename =~ s@^[^/]*/@@;
@@ -598,6 +603,7 @@ sub read_mailmap {
598603
}
599604

600605
@file_emails = uniq(@file_emails);
606+
@fixes = uniq(@fixes);
601607

602608
my %email_hash_name;
603609
my %email_hash_address;
@@ -612,7 +618,6 @@ sub read_mailmap {
612618
my %deduplicate_address_hash = ();
613619

614620
my @maintainers = get_maintainers();
615-
616621
if (@maintainers) {
617622
@maintainers = merge_email(@maintainers);
618623
output(@maintainers);
@@ -927,6 +932,10 @@ sub get_maintainers {
927932
}
928933
}
929934

935+
foreach my $fix (@fixes) {
936+
vcs_add_commit_signers($fix, "blamed_fixes");
937+
}
938+
930939
foreach my $email (@email_to, @list_to) {
931940
$email->[0] = deduplicate_email($email->[0]);
932941
}
@@ -1031,6 +1040,7 @@ sub usage {
10311040
--roles => show roles (status:subsystem, git-signer, list, etc...)
10321041
--rolestats => show roles and statistics (commits/total_commits, %)
10331042
--file-emails => add email addresses found in -f file (default: 0 (off))
1043+
--fixes => for patches, add signatures of commits with 'Fixes: <commit>' (default: 1 (on))
10341044
--scm => print SCM tree(s) if any
10351045
--status => print status if any
10361046
--subsystem => print subsystem name if any
@@ -1730,6 +1740,32 @@ sub vcs_is_hg {
17301740
return $vcs_used == 2;
17311741
}
17321742

1743+
sub vcs_add_commit_signers {
1744+
return if (!vcs_exists());
1745+
1746+
my ($commit, $desc) = @_;
1747+
my $commit_count = 0;
1748+
my $commit_authors_ref;
1749+
my $commit_signers_ref;
1750+
my $stats_ref;
1751+
my @commit_authors = ();
1752+
my @commit_signers = ();
1753+
my $cmd;
1754+
1755+
$cmd = $VCS_cmds{"find_commit_signers_cmd"};
1756+
$cmd =~ s/(\$\w+)/$1/eeg; #substitute variables in $cmd
1757+
1758+
($commit_count, $commit_signers_ref, $commit_authors_ref, $stats_ref) = vcs_find_signers($cmd, "");
1759+
@commit_authors = @{$commit_authors_ref} if defined $commit_authors_ref;
1760+
@commit_signers = @{$commit_signers_ref} if defined $commit_signers_ref;
1761+
1762+
foreach my $signer (@commit_signers) {
1763+
$signer = deduplicate_email($signer);
1764+
}
1765+
1766+
vcs_assign($desc, 1, @commit_signers);
1767+
}
1768+
17331769
sub interactive_get_maintainers {
17341770
my ($list_ref) = @_;
17351771
my @list = @$list_ref;

0 commit comments

Comments
 (0)