git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Will Palmer <wmpalmer@gmail.com>
Cc: Alexei Sholik <alcosholik@gmail.com>,
	Michael J Gruber <git@drmicha.warpmail.net>,
	git@vger.kernel.org
Subject: Re: [PATCH 2/2] Add Author and Documentation sections to git-for-each-ref.txt
Date: Thu, 17 Mar 2011 15:34:50 -0400	[thread overview]
Message-ID: <20110317193450.GD20508@sigill.intra.peff.net> (raw)
In-Reply-To: <1300371608.16335.1.camel@wpalmer.simply-domain>

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

  reply	other threads:[~2011-03-17 19:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-08 13:16 [PATCH 0/2] A couple of tweaks in git-for-each-ref.txt Alexei Sholik
2011-03-08 13:16 ` [PATCH 1/2] Documentation: remove redundant colons " Alexei Sholik
2011-03-09  7:55   ` Michael J Gruber
2011-03-08 13:16 ` [PATCH 2/2] Add Author and Documentation sections to git-for-each-ref.txt Alexei Sholik
2011-03-09  8:08   ` Michael J Gruber
2011-03-09 12:14     ` Alexei Sholik
2011-03-17 14:20       ` Will Palmer
2011-03-17 19:34         ` Jeff King [this message]
2011-03-17 19:51           ` Alexei Sholik
2011-03-17 19:54             ` Jeff King
2011-03-17 20:10               ` Alexei Sholik
2011-03-09 20:17     ` Junio C Hamano
2011-03-10 22:37       ` Jeff King
2011-03-10 23:09         ` Junio C Hamano
2011-03-11  6:20           ` Jeff King
2011-03-11  8:09             ` Junio C Hamano
2011-03-12  9:52         ` Alexei Sholik
2011-03-13  3:02           ` Jeff King
2011-03-13  6:34             ` Junio C Hamano
2011-03-13  6:47               ` Jeff King
2011-03-13  7:33                 ` Junio C Hamano
2011-03-13 13:27                   ` Michael J Gruber
2011-03-17  6:59                   ` Jeff King
2011-03-09 19:54 ` [PATCH 0/2] A couple of tweaks in git-for-each-ref.txt Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110317193450.GD20508@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=alcosholik@gmail.com \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=wmpalmer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).