git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Storing Maintainers info around the kernel tree

From
KMKyle Moffett <mrmacman_g4@mac.com>
Date
Aug 16, 2007, 13:04 UTC
Message-ID
<D31EF534-ACD1-426D-AF88-F152C23CB542@mac.com>
In-Reply-To
<200708151321.05959.rjw@sisk.pl>
Merging a couple related threads here:
On Aug 16, 2007, at 07:57:23, Rene Herman wrote:
Show 14 quoted lines
> On 08/16/2007 01:26 PM, Salikh Zakirov wrote:
>> Rene Herman wrote:
>>> Perhaps that immediately suggests an implementation to someone  
>>> already familiar with git internals?
>> perhaps http://www.kernel.org/pub/software/scm/git/docs/ 
>> gitattributes.html and http://www.kernel.org/pub/software/scm/git/ 
>> docs/git-check-attr.html can help you?
>
> No, thanks, saw them, but .gitattributes is in fact in the same  
> category as .gitignore, which would _be_ a property.
>
> If you do this stuff in files scattered around the tree, updating  
> and moving stuff becomes a pain -- the tool would need to go edit  
> files.
 From a practical standpoint we don't want to duplicate someone's  
maintainer information in the attributes of every file they  
maintain.  It would be much easier to put in the "kernel/somesubsys"  
directory a Maintainers file which has:
[SOME RANDOM SUBSYSTEM]
P: J. Random Hacker
M: j.random.hacker@localhost
L: random-subsys-devel@vger.kernel.org
F: *

Anywhere else you had files that you wanted to associate with J. Random Hacker's maintainership, you would just use:

[SOME RANDOM SUBSYSTEM]
F: somesubsys.h
I posted a comment describing a mechanism like this a couple days ago:
   http://lkml.org/lkml/2007/8/14/488

Executive overview: On Aug 15, 2007, at 07:21:04, Rafael J. Wysocki wrote:

Show 14 quoted lines
> On Wednesday, 15 August 2007 04:51, Kyle Moffett wrote:
>> (a) "Maintainers" files sprinkled around the source tree with  
>> relative pathnames and other data
>>
>> (b) Tool to generate a combined "MAINTAINERS" file from the ones  
>> sprinkled around the source tree
>>
>> (c) Tool to search through the generated "MAINTAINERS" file with  
>> all sorts of useful command-line options
>>
>> (d) Tool to check the generated "MAINTAINERS" file against recent  
>> git history and make suggestions
>
> I like this idea. :-)
Well, to back up this idea with some code, I'm attaching a little  
perl script which does part (b).  Basically you call it as:
   ./maint-combine $(find . -name Maintainers)

It will print any syntax errors on stderr during parsing. Once it's done it will dump to stdout its combined "MAINTAINERS" text. A couple notes:

*  It uses a little "priority" system to figure out what order to  
print the data from each origin in.  For example, the "F:" tag is  
given a score of 0, to force data consisting of just files towards  
the end.  The "P:", "M:", and "L:" tags are given scores of 5, since  
people are generally interesting to know about.  Everything else is  
given a score of "1".  The scores are added up per ($file,  
$subsystem) pair and then during printing each subsystem's data is  
ordered by score (highest comes first).
*  It generally allows any field at all; eventually we might want to  
limit it to a fixed list to help avoid typos.
*  It has a little bit of magic logic for the "F:" field so that it  
figures out the relative directory for each field when generating the  
output.  For example, an entry of "asm-*/suspend.h" in a file  
"include/Maintainers" will produce the output file entry: "F: include/ 
asm-*/suspend.h"
*  The format isn't quite the same as the current MAINTAINERS file,  
to make parsing easier and more dummy-proof I changed the syntax for  
a subsystem-name to use square brackets (IE: "[SUSPEND TO RAM]").   
The samples I gave in my previous email are what I used to test it  
with, plus a little dummy file with some syntax errors to check out  
the error messages:
Maintainers:
> [EVERYTHING ELSE]
> P: Various Linux Kernel Developers
> L: linux-kernel@vger.kernel.org
> F: *
kernel/power/Maintainers:
Show 8 quoted lines
> [SUSPEND TO RAM]
> P: Pavel Machek
> M: pavel@suse.cz
> P: Rafael J. Wysocki
> M: rjw@sisk.pl
> L: linux-pm@lists.linux-foundation.org
> S: Maintained
> F: *
include/Maintainers:
Show 5 quoted lines
> [SUSPEND TO RAM]
> F: linux/suspend.h
> F: linux/freezer.h
> F: linux/pm.h
> F: asm-*/suspend.h

If you have any other questions, the perl script is pretty self- explanatory and I'll be completely back online this weekend. With any luck I'll have some time in a hotel tomorrow (mmm, slow-as-dirt hotel wireless, what fun) to work on parts (c) and (d).

Cheers, Kyle Moffett

#! /usr/bin/perl

use strict; use warnings;

## This table is for determining what order to show entries from different
## source "Maintainers" files.  They are prioritized based on the number and
## significance of each field, as listed in this table.  Any field not found
## here will be assumed to have a significance of "1".
my %fieldprio = (
	p => 5,  ## Person
	m => 5,  ## Email
	l => 5,  ## Mailing List
	f => 0,  ## File
);

my %mprio; my %maint; my $section; my $origin; my $pathprefix; my $printorigin;

while (<>) {
	unless (defined $origin and $origin eq $ARGV) {
		undef $section;
		## Get rid of extra slashes, unnecessary "./" entries
		$ARGV =~ s{//+}{/}g;
		$ARGV =~ s{(^|/)\./}{$1};
		$origin = $ARGV;
	}
	chomp; s/\s+/ /g; s/^ //; s/ $//;
	/\S+/ or next;
	if (/^\[ ?([^]]+) ?\]$/) {
		$section = uc $1;
		$printorigin = 1 if $origin ne '-';
		$maint{$section}{$origin} ||= [];
		$mprio{$section}{$origin} ||= 0;
		## Figure out a useful path prefix if there is one
		$pathprefix = ($origin =~ m{(^.*/)(?!\.\.?$)[^/]+$})?$1:"";
		next;
	}
	unless (/^([^:]+?) ?: ?(.*)$/) {
		print STDERR "$ARGV:$.: Invalid line: $_\n";
		next;
	}
	my($field,$value) = (lc($1), $2);
	unless (defined $section) {
		print STDERR "$ARGV:$.: Found field '\u$field' before ",
				"any subsystem declaration: $_\n";
		next;
	}
	## Preprocess paths to make them absolute
	$value = $pathprefix.$value if $field eq 'f';
	## Update the sorting order
	if (exists $fieldprio{$field}) {
		$mprio{$section}{$origin} += $fieldprio{$field};
	} else {
		$mprio{$section}{$origin}++;
	}
	push @{$maint{$section}{$origin}}, [$field, $value];
}
sub priosort ( $@ )
{
	my $section = shift;
	return sort {$mprio{$section}{$b} <=> $mprio{$section}{$a}} @_;
}
for $section (sort {$a cmp $b} keys %maint) {
	print "[$section]\n";
	for my $origin (priosort $section, keys %{$maint{$section}}) {
		print "\nOrigin: $origin\n" if $printorigin;
		print "\u$_->[0]: $_->[1]\n" for @{$maint{$section}{$origin}};
	}
	print "\n\n";
}
# vim:set ft=perl:
Next: Rene Herman
Message 1 of 9 in “Storing Maintainers info around the kernel tree”
  1. Kyle MoffettAug 16, 2007
  2. Rene HermanAug 16, 2007
  3. Alan SternAug 16, 2007
  4. Rene HermanAug 16, 2007
  5. Stefan RichterAug 16, 2007
  6. Rene HermanAug 17, 2007
  7. Alan SternAug 17, 2007
  8. Rene HermanAug 17, 2007
  9. Stefan RichterAug 17, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.