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

git-shortlog script

From
JGJeff Garzik <jgarzik@pobox.com>
Date
Jun 4, 2005, 22:33 UTC
Message-ID
<42A22C20.10002@pobox.com>

Attached is the 'git-shortlog' script I whipped up, to mimic the shortlog script that was used back in the BitKeeper days.

shortlog reads a changelog in the 'git-whatchanged' format, such as
	git-whatchanged | git-shortlog
		or
	git-shortlog changes.txt
and outputs the changes sorted by author:
	author1:
	  cset 1-line desc
	  cset 1-line desc
	  ...
	author2:
	  cset 1-line desc
	  ...
	...
Since git distinguishes 'author' from 'committer', I ran
	git-whatchanged | git-shortlog > changes.txt

to look at the kernel authors throughout the entire history [of which is in git].

It's fun to browse, since this is the first time we've been able to get a better picture who is actually writing the patches, versus committing them. See changes.txt.bz2, attached.

	Jeff
#!/usr/bin/perl -w
use strict;

my ($author, $desc, %map); my $pstate = 1;

while (<>) {
	# get author
	if ($pstate == 1) {
		next unless /^Author: (.*)$/;
		$author = $1;
		$pstate++;
	}
	# skip to blank line
	elsif ($pstate == 2) {
		next unless /^\s*$/;
		$pstate++;
	}
	# skip to non-blank line
	elsif ($pstate == 3) {
		next if /^\s*$/;
		chomp;
		$desc = $_;
		&shortlog_entry($author, $desc);
		$pstate = 1;
	}
	else {
		die "invalid parse state $pstate";
	}
}

&shortlog_output; exit(0);

sub shortlog_entry($$) {
	my ($tmp_author, $tmp_desc) = @_;
	$tmp_desc =~ s#/pub/scm/linux/kernel/git/#/.../#g;
	$tmp_desc =~ s#\[PATCH\] ##g;
	$tmp_desc =~ s#^\s+##g;
	if (exists $map{$tmp_author}) {
		# grab ref
		my $obj = $map{$tmp_author};
		# add desc to array
		push(@$obj, $tmp_desc);
	} else {
		# create new array, containing 1 item
		my @arr = ($tmp_desc);
		# store ref to array
		$map{$tmp_author} = \@arr;
	}
}
sub shortlog_output {
	my ($obj);
	foreach $author (sort keys %map) {
		print "$author:\n";
		$obj = $map{$author};
		foreach $desc (@$obj) {
			print "  $desc\n";
		}
		print "\n";
	}
}
Next: Linus Torvalds
Message 1 of 6 in “git-shortlog script”
  1. Jeff GarzikJun 4, 2005
  2. Linus TorvaldsJun 4, 2005
  3. Linus TorvaldsJun 4, 2005
  4. Jeff GarzikJun 5, 2005
  5. Linus TorvaldsJun 5, 2005
  6. Jeff GarzikJun 5, 2005

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.