Re: git-who

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

 




On Oct 7, 2008, at 10:25 PM, Jeff King wrote:

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.

Yeah, I agree, I just haven't come up with a better idea that addresses the question of "who touched this". Maybe some sort of recency toggle.

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?

Yeah, I've considered maybe adding a -n (number) like that and ordering people by number of commits. I'm not convinced that, in most cases, size of changes is as important as number. I think it depends on the file. In some cases a person who's constantly mucking about with the file is a better go-to person when you have questions / issues, than someone who happened to make a few large commits a while ago. But then again....



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.

mmm good idea.


And fortunately that is relatively
easy to do (only lightly tested):

excellent! Thank you. I'll poke at this tomorrow. :)

-masukomi



-- >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