Hi,
Someone asked me a few days ago about their patches being merged yet (e.g., how to see their commits in a git tree). Someone else asked (in general) about commit or author counts.
I pointed the first person to "git log" and/or gitweb. For the second, there are probably lots of scripts out there but I didn't find them. Where are they?
Is this useful? or it needs fixing? or you already have better solutions?
example: git log v2.6.19.. | authorcount -m | less
# this is just the ones with >= 50 Author: lines
Al Viro : 213 Linus Torvalds : 94 Jiri Slaby : 90 Josef Sipek : 79 Gerrit Renker : 77 Adrian Bunk : 67 Andrew Morton : 59 Tejun Heo : 52 Mariusz Kozlowski : 52 Paul Mundt : 51 Ralf Baechle : 50 ---
#! /usr/bin/perl # Copyright (C) 2006, Randy Dunlap.
# read stdin, drop non-author: lines, count/sum/tally author: lines by # each author after sanitizing author-name somewhat. # # optionally print out in author-name (-a) alpha order # or in numeric/count (-n) order (low-to-high) # or in numeric/count (-m) order (high-to-low) ("max" first)
# hash for author names: my %authors; my $auth; my $sortby;
sub usage()
{
print "usage: authorcount [-a | -n | -m] < git.log.lines\n";
exit(1);
}$sortby = $ARGV[0];
if (($sortby ne "") && ($sortby ne "-a") && ($sortby ne "-n") &&
($sortby ne "-m"))
{
print "Invalid sort option: $sortby\n";
usage();
}READIN: while ($line = <STDIN>)
{
chomp $line;
next READIN if $line !~ /Author:/;$auth = $line; $auth =~ s/Author: //; $auth =~ s/<.*>//;
$authors{$auth}++;} # end READIN
sub byvalue
{
$authors{$a} <=> $authors{$b};
}# optionally sort by author name or author counts # print out the tally array
if ($sortby eq "-a")
{
foreach $auth (sort keys %authors)
{
print "$auth: $authors{$auth}\n";
}
}
elsif ($sortby eq "-n")
{
foreach $auth (sort byvalue keys %authors)
{
print "$auth: $authors{$auth}\n";
}
}
elsif ($sortby eq "-m")
{
foreach $auth (reverse sort byvalue keys %authors)
{
print "$auth: $authors{$auth}\n";
}
}
else # no sort, just hash order
{
while (($auth, $count) = each(%authors))
{
print "$auth: $count\n";
}
}