Re: git-who

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 07, 2008 at 05:02:46PM -0400, Kate Rhodes wrote:

> As is it's probably not worth including in git, but I'm thinking that  
> someone else can probably come up with some improvements, such as dates in 
> the verbose mode, support for a treeish instead of a single file path, and 
> / or rewriting it in C so that it can work on Windows.

Scripts like this often find a good home in git's contrib/ directory.
Consider submitting a patch which adds it there.

> git://github.com/masukomi/git_accessories.git

I took a look. My biggest complaint is that for many files, it produces
too many names. It would be nice to at least sort the names by number
of commits. But even more accurate might be the number of added lines.
Somebody who creates a 200-line file should surely come before somebody
who made a 1-line tweak, right?

But perhaps even more accurate would be to rely on blame output, since
it attributes not just added lines, but lines which have actually
survived into the current product. And fortunately that is relatively
easy to do (only lightly tested):

-- >8 --
#!/usr/bin/perl
#
# Invoke as 'git who -M -C file.c' (or whichever blame options
# you prefer). You can even check a particular set of lines
# with "git who -M -C -L 40,60 file.c".

use strict;

open(my $in, '-|', qw(git blame -p), @ARGV);

my %count;
my %author;
my $current_sha1;
while(<$in>) {
  if (!$current_sha1) {
    /^[0-9a-f]{40}/ or die "expected sha1, got $_";
    $current_sha1 = $&;
    $count{$current_sha1}++;
  }
  elsif (/^author (.*)/) {
    $author{$current_sha1} = $1;
  }
  elsif (/^\t/) {
    $current_sha1 = undef;
  }
}

my %acount;
while(my ($h, $c) = each %count) {
  $acount{$author{$h}} += $c;
}

foreach (sort { $acount{$b} <=> $acount{$a} } keys %acount) {
  print "$_ ($acount{$_})\n";
}
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux