linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3] get_maintainer: Prepare for separate MAINTAINERS files
@ 2017-08-05  4:45 Joe Perches
  2017-08-07  2:16 ` Frank Rowand
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2017-08-05  4:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, linux-kernel

Allow for MAINTAINERS to become a directory and if it is,
read all the files in the directory for maintained sections.

Optionally look for all files named MAINTAINERS in directories
excluding the .git directory by using --find-maintainer-files.

This optional feature adds ~.3 seconds of CPU on an Intel
i5-6200 with an SSD.

Miscellanea:

o Create a read_maintainer_file subroutine from the existing code
o Test only the existence of MAINTAINERS, not whether it's a file

Signed-off-by: Joe Perches <joe@perches.com>
---

v2: Search for MAINTAINERS in subdirectories, ignoring .git
v3: Make searching for MAINTAINERS in subdirectories optional

 scripts/get_maintainer.pl | 91 ++++++++++++++++++++++++++++++++++-------------
 1 file changed, 66 insertions(+), 25 deletions(-)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 3bd5f4f30235..bc443201d3ef 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -18,6 +18,7 @@ my $V = '0.26';
 
 use Getopt::Long qw(:config no_auto_abbrev);
 use Cwd;
+use File::Find;
 
 my $cur_path = fastgetcwd() . '/';
 my $lk_path = "./";
@@ -58,6 +59,7 @@ my $from_filename = 0;
 my $pattern_depth = 0;
 my $version = 0;
 my $help = 0;
+my $find_maintainer_files = 0;
 
 my $vcs_used = 0;
 
@@ -249,6 +251,7 @@ if (!GetOptions(
 		'sections!' => \$sections,
 		'fe|file-emails!' => \$file_emails,
 		'f|file' => \$from_filename,
+		'find-maintainer-files' => \$find_maintainer_files,
 		'v|version' => \$version,
 		'h|help|usage' => \$help,
 		)) {
@@ -307,36 +310,74 @@ if (!top_of_kernel_tree($lk_path)) {
 
 my @typevalue = ();
 my %keyword_hash;
+my @mfiles = ();
 
-open (my $maint, '<', "${lk_path}MAINTAINERS")
-    or die "$P: Can't open MAINTAINERS: $!\n";
-while (<$maint>) {
-    my $line = $_;
-
-    if ($line =~ m/^([A-Z]):\s*(.*)/) {
-	my $type = $1;
-	my $value = $2;
-
-	##Filename pattern matching
-	if ($type eq "F" || $type eq "X") {
-	    $value =~ s@\.@\\\.@g;       ##Convert . to \.
-	    $value =~ s/\*/\.\*/g;       ##Convert * to .*
-	    $value =~ s/\?/\./g;         ##Convert ? to .
-	    ##if pattern is a directory and it lacks a trailing slash, add one
-	    if ((-d $value)) {
-		$value =~ s@([^/])$@$1/@;
+sub read_maintainer_file {
+    my ($file) = @_;
+
+    open (my $maint, '<', "$file")
+	or die "$P: Can't open MAINTAINERS file '$file': $!\n";
+    while (<$maint>) {
+	my $line = $_;
+
+	if ($line =~ m/^([A-Z]):\s*(.*)/) {
+	    my $type = $1;
+	    my $value = $2;
+
+	    ##Filename pattern matching
+	    if ($type eq "F" || $type eq "X") {
+		$value =~ s@\.@\\\.@g;       ##Convert . to \.
+		$value =~ s/\*/\.\*/g;       ##Convert * to .*
+		$value =~ s/\?/\./g;         ##Convert ? to .
+		##if pattern is a directory and it lacks a trailing slash, add one
+		if ((-d $value)) {
+		    $value =~ s@([^/])$@$1/@;
+		}
+	    } elsif ($type eq "K") {
+		$keyword_hash{@typevalue} = $value;
 	    }
-	} elsif ($type eq "K") {
-	    $keyword_hash{@typevalue} = $value;
+	    push(@typevalue, "$type:$value");
+	} elsif (!(/^\s*$/ || /^\s*\#/)) {
+	    $line =~ s/\n$//g;
+	    push(@typevalue, $line);
 	}
-	push(@typevalue, "$type:$value");
-    } elsif (!/^(\s)*$/) {
-	$line =~ s/\n$//g;
-	push(@typevalue, $line);
     }
+    close($maint);
+}
+
+sub find_is_maintainer_file {
+    my ($file) = $_;
+    return if ($file !~ m@/MAINTAINERS$@);
+    $file = $File::Find::name;
+    return if (! -f $file);
+    push(@mfiles, $file);
 }
-close($maint);
 
+sub find_ignore_git {
+    return grep { $_ !~ /^\.git$/; } @_;
+}
+
+if (-d "${lk_path}MAINTAINERS") {
+    opendir(DIR, "${lk_path}MAINTAINERS") or die $!;
+    my @files = readdir(DIR);
+    closedir(DIR);
+    foreach my $file (@files) {
+	push(@mfiles, "${lk_path}MAINTAINERS/$file") if ($file !~ /^\./);
+    }
+}
+
+if ($find_maintainer_files) {
+    find( { wanted => \&find_is_maintainer_file,
+	    preprocess => \&find_ignore_git,
+	    no_chdir => 1,
+	}, "${lk_path}");
+} else {
+    push(@mfiles, "${lk_path}MAINTAINERS") if -f "${lk_path}MAINTAINERS";
+}
+
+foreach my $file (@mfiles) {
+    read_maintainer_file("$file");
+}
 
 #
 # Read mail address map
@@ -873,7 +914,7 @@ sub top_of_kernel_tree {
     if (   (-f "${lk_path}COPYING")
 	&& (-f "${lk_path}CREDITS")
 	&& (-f "${lk_path}Kbuild")
-	&& (-f "${lk_path}MAINTAINERS")
+	&& (-e "${lk_path}MAINTAINERS")
 	&& (-f "${lk_path}Makefile")
 	&& (-f "${lk_path}README")
 	&& (-d "${lk_path}Documentation")
-- 
2.10.0.rc2.1.g053435c

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] get_maintainer: Prepare for separate MAINTAINERS files
  2017-08-05  4:45 [PATCH V3] get_maintainer: Prepare for separate MAINTAINERS files Joe Perches
@ 2017-08-07  2:16 ` Frank Rowand
  2017-08-07  3:32   ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Rowand @ 2017-08-07  2:16 UTC (permalink / raw)
  To: Joe Perches, Linus Torvalds; +Cc: Andrew Morton, linux-kernel

On 08/04/17 21:45, Joe Perches wrote:
> Allow for MAINTAINERS to become a directory and if it is,
> read all the files in the directory for maintained sections.
> 
> Optionally look for all files named MAINTAINERS in directories
> excluding the .git directory by using --find-maintainer-files.
> 
> This optional feature adds ~.3 seconds of CPU on an Intel
> i5-6200 with an SSD.
> 
> Miscellanea:
> 
> o Create a read_maintainer_file subroutine from the existing code
> o Test only the existence of MAINTAINERS, not whether it's a file
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---

< snip >

Hi Joe,

In the three versions of this patch, I have not seen any description
of what is wrong with the current single MAINTAINERS file, or why the
proposed change is an improvement. Could you please add that
information?

-Frank

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] get_maintainer: Prepare for separate MAINTAINERS files
  2017-08-07  2:16 ` Frank Rowand
@ 2017-08-07  3:32   ` Joe Perches
  2017-08-07 19:33     ` Frank Rowand
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2017-08-07  3:32 UTC (permalink / raw)
  To: Frank Rowand, Linus Torvalds; +Cc: Andrew Morton, linux-kernel

On Sun, 2017-08-06 at 19:16 -0700, Frank Rowand wrote:
> On 08/04/17 21:45, Joe Perches wrote:
> > Allow for MAINTAINERS to become a directory and if it is,
> > read all the files in the directory for maintained sections.
> > 
> > Optionally look for all files named MAINTAINERS in directories
> > excluding the .git directory by using --find-maintainer-files.
> > 
> > This optional feature adds ~.3 seconds of CPU on an Intel
> > i5-6200 with an SSD.
> > 
> > Miscellanea:
> > 
> > o Create a read_maintainer_file subroutine from the existing code
> > o Test only the existence of MAINTAINERS, not whether it's a file
> > 
> > Signed-off-by: Joe Perches <joe@perches.com>
> > ---
> 
> < snip > 
> 
> Hi Joe,
> 
> In the three versions of this patch, I have not seen any description
> of what is wrong with the current single MAINTAINERS file, or why the
> proposed change is an improvement. Could you please add that
> information?

It's really up to Linus.

He's the one who wants to separate the MAINTAINERS
file as he's the one that has to deal with the
merges.

This is only to enable the script to still function
if the file is split up.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V3] get_maintainer: Prepare for separate MAINTAINERS files
  2017-08-07  3:32   ` Joe Perches
@ 2017-08-07 19:33     ` Frank Rowand
  0 siblings, 0 replies; 4+ messages in thread
From: Frank Rowand @ 2017-08-07 19:33 UTC (permalink / raw)
  To: Joe Perches, Linus Torvalds; +Cc: Andrew Morton, linux-kernel

On 08/06/17 20:32, Joe Perches wrote:
> On Sun, 2017-08-06 at 19:16 -0700, Frank Rowand wrote:
>> On 08/04/17 21:45, Joe Perches wrote:
>>> Allow for MAINTAINERS to become a directory and if it is,
>>> read all the files in the directory for maintained sections.
>>>
>>> Optionally look for all files named MAINTAINERS in directories
>>> excluding the .git directory by using --find-maintainer-files.
>>>
>>> This optional feature adds ~.3 seconds of CPU on an Intel
>>> i5-6200 with an SSD.
>>>
>>> Miscellanea:
>>>
>>> o Create a read_maintainer_file subroutine from the existing code
>>> o Test only the existence of MAINTAINERS, not whether it's a file
>>>
>>> Signed-off-by: Joe Perches <joe@perches.com>
>>> ---
>>
>> < snip > 
>>
>> Hi Joe,
>>
>> In the three versions of this patch, I have not seen any description
>> of what is wrong with the current single MAINTAINERS file, or why the
>> proposed change is an improvement. Could you please add that
>> information?
> 
> It's really up to Linus.
> 
> He's the one who wants to separate the MAINTAINERS
> file as he's the one that has to deal with the
> merges.
> 
> This is only to enable the script to still function
> if the file is split up.


Thanks, that gave me enough of a clue to find the threads titled

   [PATCH Y.A. RESEND] MAINTAINERS: fix alpha. ordering

and

   [PATCH RESEND v4] MAINTAINERS: fix lots of alphabetic ordering

tl;dr is that MAINTAINERS causes annoying merge conflicts for Linus,
and he is open to ideas to reduce that pain, including possibly
splitting MAINTAINERS into a number of files.

-Frank

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-07 19:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-05  4:45 [PATCH V3] get_maintainer: Prepare for separate MAINTAINERS files Joe Perches
2017-08-07  2:16 ` Frank Rowand
2017-08-07  3:32   ` Joe Perches
2017-08-07 19:33     ` Frank Rowand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).