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

author/commit counts

From
RDRandy Dunlap <rdunlap@xenotime.net>
Date
Dec 23, 2006, 02:10 UTC
Message-ID
<20061222181030.d733deb3.rdunlap@xenotime.net>
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";
	}
}
Next: Shawn Pearce
Message 1 of 12 in “author/commit counts”
  1. Randy DunlapDec 23, 2006
  2. Shawn PearceDec 23, 2006
  3. Linus TorvaldsDec 23, 2006
  4. Johannes SchindelinDec 23, 2006
  5. Randal L. SchwartzDec 23, 2006
  6. Randy DunlapDec 23, 2006
  7. Junio C HamanoDec 23, 2006
  8. Randy DunlapDec 23, 2006
  9. Shawn PearceDec 23, 2006
  10. Nicolas PitreDec 23, 2006
  11. Johannes SchindelinDec 23, 2006
  12. Nicolas PitreDec 23, 2006

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.