Re: [PATCH 2/2] Add Author and Documentation sections to git-for-each-ref.txt

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

 



On Thu, Mar 17, 2011 at 02:20:08PM +0000, Will Palmer wrote:

> On Wed, 2011-03-09 at 14:14 +0200, Alexei Sholik wrote:
> > .................. Just ran this command
> > 
> > git blame -p "$1" | awk '$1 ~ /author$/ { print substr($0,
> > length("author  "), length($0)) }' | sort | uniq -c | sort -nr
> > 
> > on the for-each-ref.c and saw that Junio had the first place by a
> > relatively large margin.
> > 
> 
> Wrap that up in a script and submit /that/ as a patch ;)

That just counts the number of commits that have any surviving line in a
given file. So it's slightly better than "shortlog -ns" in that it
removes commits whose contents have been totally rewritten (and it
properly handles content-following). But if you are going to use blame,
the more interesting measure is probably a count of lines attributed to
each author.  Something like:

  git blame -p "$1" | perl -ne '
    if (/^([0-9a-f]{40})/) {
      $sha1 = $1;
      $count{$sha1}++;
    }
    elsif (/^author (.*)/) {
      $author{$sha1} = $1;
    }
    END {
      foreach my $sha1 (keys(%count)) {
        $r{$author{$sha1}} += $count{$sha1};
      }
      foreach my $a (sort { $r{$b} <=> $r{$a} } keys(%r)) {
        print "$r{$a} $a\n";
      }
    }
  '

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