threads / discuss / 6084

author/commit counts

Subject: author/commit counts

## tl;dr

12 messages between Dec 23, 2006 and Dec 23, 2006.

replies: 11people: 7as markdown or json

Randy Dunlap· Dec 23, 2006, 02:10 UTC · lore
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";
	}
}
Shawn Pearce· Dec 23, 2006, 02:37 UTC · re: Randy Dunlap · lore

Re: author/commit counts

Randy Dunlap <rdunlap@xenotime.net> wrote:
> 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 often do `git log --author=Shawn next@{1}..next` to see what
commits of mine Junio has recently merged into git.git since my
last fetch.  Since I'm the only Shawn (with that spelling) that
contributes to git.git this works rather well to show my work.  ;-)
 
> 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?

Here's another variant showing the top 20 committers to git.git, no Perl involved:

  $ git log | grep ^Author | cut -d\< -f1 | sort \
  	| uniq -c | sort -n -r | head -20
  3728 Author: Junio C Hamano 
   842 Author: Linus Torvalds 
   250 Author: Johannes Schindelin 
   217 Author: Jakub Narebski 
   194 Author: Eric Wong 
   166 Author: Petr Baudis 
   150 Author: Paul Mackerras 
   147 Author: Kay Sievers 
    88 Author: Nicolas Pitre 
    77 Author: Rene Scharfe 
    67 Author: Shawn Pearce 
    57 Author: Martin Langhoff 
    53 Author: Fredrik Kuivinen 
    52 Author: Nick Hengeveld 
    52 Author: Matthias Urlichs 
    49 Author: Daniel Barkalow 
    47 Author: Ryan Anderson 
    46 Author: Shawn O. Pearce 
    45 Author: Sergey Vlasov 
    45 Author: Luben Tuikov 

The only issue I have with that is I seem to have two attributions in git.git: 'Shawn Pearce' and 'Shawn O. Pearce'. Technically I'm in the top 10 by commit volume but its not immediately clear because of the two attributions being used. Really my only issue here is why sometimes my middle initial gets used and other times it doesn't.

You can also see the very clear gap between Junio and the rest of the world. There's very little dispute about who really codes Git. :-)

I'm personally suprised at Pasky's ranking: 166 commits! I did not realize he had contributed so frequently to git.git itself.

-- 
Shawn.
Linus Torvalds· Dec 23, 2006, 04:44 UTC · re: Shawn Pearce · lore

Re: author/commit counts

On Fri, 22 Dec 2006, Shawn Pearce wrote:
> 
> Here's another variant showing the top 20 committers to git.git,
> no Perl involved:

This is what I've done a few times. For the kernel, I actually find the "Signed-off-by:" lines to be more relevant to me (since it shows a combination of authorship and maintainership, something that I value a lot personally), but I've done statistics on both authors and signers-off )and committers, but that mainly just shows who uses git to sync and who does not), and I've never written any real scripts for it, I just end up doing it with some one-liner shell thing using grep, cut, sort and uniq.

		Linus
Johannes Schindelin· Dec 23, 2006, 14:28 UTC · re: Shawn Pearce · lore

Re: author/commit counts

Shawn Pearce <spearce <at> spearce.org> writes:
>   $ git log | grep ^Author | cut -d\< -f1 | sort \
>   	| uniq -c | sort -n -r | head -20

As Junio pointed out in another mail, "git shortlog -n -s | head -20" is shorter...

> You can also see the very clear gap between Junio and the rest of the
> world.  There's very little dispute about who really codes Git.  
Note that this still holds when doing the technically correct thing:
$ git shortlog -n -s --no-merges

Ciao, Dscho

Randal L. Schwartz· Dec 23, 2006, 04:37 UTC · re: Randy Dunlap · lore

Re: author/commit counts

>>>>> "Randy" == Randy Dunlap <rdunlap@xenotime.net> writes:

Randy> example: Randy> git log v2.6.19.. | authorcount -m | less

Randy> # this is just the ones with >= 50 Author: lines

Randy> Al Viro : 213 Randy> Linus Torvalds : 94 Randy> Jiri Slaby : 90 Randy> Josef Sipek : 79 Randy> Gerrit Renker : 77 Randy> Adrian Bunk : 67 Randy> Andrew Morton : 59 Randy> Tejun Heo : 52 Randy> Mariusz Kozlowski : 52 Randy> Paul Mundt : 51 Randy> Ralf Baechle : 50 Randy> ---

With
  git-log --pretty=short v2.6.19.. |  git-shortlog -n -s | head -10
and no additional tools, I get:
    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
Looky there.
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Randy Dunlap· Dec 23, 2006, 05:27 UTC · re: Randal L. Schwartz · lore

Re: author/commit counts

On 22 Dec 2006 20:37:00 -0800 Randal L. Schwartz wrote:
Show 38 quoted lines
> >>>>> "Randy" == Randy Dunlap <rdunlap@xenotime.net> writes:
> 
> Randy> example:
> Randy> git log v2.6.19.. | authorcount -m | less
> 
> Randy> # this is just the ones with >= 50 Author: lines
> 
> Randy> Al Viro : 213
> Randy> Linus Torvalds : 94
> Randy> Jiri Slaby : 90
> Randy> Josef Sipek : 79
> Randy> Gerrit Renker : 77
> Randy> Adrian Bunk : 67
> Randy> Andrew Morton : 59
> Randy> Tejun Heo : 52
> Randy> Mariusz Kozlowski : 52
> Randy> Paul Mundt : 51
> Randy> Ralf Baechle : 50
> Randy> ---
> 
> With
> 
>   git-log --pretty=short v2.6.19.. |  git-shortlog -n -s | head -10
> 
> and no additional tools, I get:
> 
>     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
> 
> Looky there.
Yep, that's nice.  Thanks.

--- ~Randy

Junio C Hamano· Dec 23, 2006, 04:43 UTC · re: Randy Dunlap · lore

Re: author/commit counts

Randy Dunlap <rdunlap@xenotime.net> writes:
Show 5 quoted lines
> Is this useful?  or it needs fixing?
> or you already have better solutions?
>
> example:
> git log v2.6.19.. | authorcount -m | less
Perhaps you are talking about this command?
$ git shortlog -n -s v2.6.19..
Randy Dunlap· Dec 23, 2006, 05:24 UTC · re: Junio C Hamano · lore

Re: author/commit counts

On Fri, 22 Dec 2006 20:43:54 -0800 Junio C Hamano wrote:
Show 11 quoted lines
> Randy Dunlap <rdunlap@xenotime.net> writes:
> 
> > Is this useful?  or it needs fixing?
> > or you already have better solutions?
> >
> > example:
> > git log v2.6.19.. | authorcount -m | less
> 
> Perhaps you are talking about this command?
> 
> $ git shortlog -n -s v2.6.19..
Yes, thanks, probably something like that....
git version 1.4.3.GIT
> git shortlog -n -s v2.6.19..
Can't open v2.6.19..: No such file or directory at /usr/local/bin/git-shortlog line 99.

--- ~Randy

Shawn Pearce· Dec 23, 2006, 05:29 UTC · re: Randy Dunlap · lore

Re: author/commit counts

Randy Dunlap <rdunlap@xenotime.net> wrote:
Show 6 quoted lines
> Yes, thanks, probably something like that....
> 
> git version 1.4.3.GIT
> 
> > git shortlog -n -s v2.6.19..
> Can't open v2.6.19..: No such file or directory at /usr/local/bin/git-shortlog line 99.

The git-shortlog being discussed is the new builtin shortlog, which has not been released yet. Try the 'master' branch in git.git.

-- 
Shawn.
Nicolas Pitre· Dec 23, 2006, 05:06 UTC · re: Randy Dunlap · lore

Re: author/commit counts

On Fri, 22 Dec 2006, Randy Dunlap wrote:
> 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).
See the --author=<string> option to git log.
Show 5 quoted lines
> 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?
Try git shortlog -s.  If you combine the two like:
	git log --author=<blah> | git shortlog -s
then you'll have a commit count for <blah> only.
Nicolas
Johannes Schindelin· Dec 23, 2006, 14:22 UTC · re: Nicolas Pitre · lore

Re: author/commit counts

Hi,
On Sat, 23 Dec 2006, Nicolas Pitre wrote:
> 	git log --author=<blah> | git shortlog -s
Note that the builtin shortlog reuses the fine revision walking machinery:
	git shortlog --author=<blah> -n -s
works like a charm.

Ciao, Dscho

Nicolas Pitre· Dec 23, 2006, 14:31 UTC · re: Johannes Schindelin · lore

Re: author/commit counts

On Sat, 23 Dec 2006, Johannes Schindelin wrote:
Show 11 quoted lines
> Hi,
> 
> On Sat, 23 Dec 2006, Nicolas Pitre wrote:
> 
> > 	git log --author=<blah> | git shortlog -s
> 
> Note that the builtin shortlog reuses the fine revision walking machinery:
> 
> 	git shortlog --author=<blah> -n -s
> 
> works like a charm.

I know and use it myself. But many people might not have a recent enough git version for that.

Nicolas

← back to recent threads