Commit 1d606b4e authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

scripts/get_maintainer.pl: add sections in pattern match depth order

Before this change, matched sections were added in the order
of appearance in the normally alphabetic section order of
the MAINTAINERS file.

For instance, finding the maintainer for drivers/scsi/wd7000.c
would first find "SCSI SUBSYSTEM", then "WD7000 SCSI SUBSYSTEM",
then "THE REST".

before patch:

$ ./scripts/get_maintainer.pl --nogit -f drivers/scsi/wd7000.c
James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Miroslav Zagorac <zaga@fly.cc.fer.hr>
linux-scsi@vger.kernel.org
linux-kernel@vger.kernel.org

get_maintainer.pl now selects matched sections by longest pattern match.
Longest is the number of "/"s and any specific file pattern.

This changes the example output order of MAINTAINERS to whatever is
selected in "WD7000 SUBSYSTEM", then "SCSI SYSTEM", then "THE REST".

after patch:

$ ./scripts/get_maintainer.pl --nogit -f drivers/scsi/wd7000.c
Miroslav Zagorac <zaga@fly.cc.fer.hr>
James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
linux-scsi@vger.kernel.org
linux-kernel@vger.kernel.org
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f5492666
...@@ -211,6 +211,7 @@ foreach my $file (@files) { ...@@ -211,6 +211,7 @@ foreach my $file (@files) {
if ($type eq 'X') { if ($type eq 'X') {
if (file_match_pattern($file, $value)) { if (file_match_pattern($file, $value)) {
$exclude = 1; $exclude = 1;
last;
} }
} }
} }
...@@ -218,18 +219,24 @@ foreach my $file (@files) { ...@@ -218,18 +219,24 @@ foreach my $file (@files) {
if (!$exclude) { if (!$exclude) {
my $tvi = 0; my $tvi = 0;
my %hash;
foreach my $line (@typevalue) { foreach my $line (@typevalue) {
if ($line =~ m/^(\C):\s*(.*)/) { if ($line =~ m/^(\C):\s*(.*)/) {
my $type = $1; my $type = $1;
my $value = $2; my $value = $2;
if ($type eq 'F') { if ($type eq 'F') {
if (file_match_pattern($file, $value)) { if (file_match_pattern($file, $value)) {
add_categories($tvi); my $pattern_depth = ($value =~ tr@/@@);
$pattern_depth++ if (!(substr($value,-1,1) eq "/"));
$hash{$tvi} = $pattern_depth;
} }
} }
} }
$tvi++; $tvi++;
} }
foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
add_categories($line);
}
} }
if ($email && $email_git) { if ($email && $email_git) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment