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

Re: How to efficiently blame an entire repo?

From
Jay Soffian <jaysoffian@gmail.com>
Date
Apr 30, 2010, 20:16 UTC
Message-ID
<o2m76718491004301316tfbaf434alb94e6bfd001d36b6@mail.gmail.com>
In-Reply-To
<x2s32541b131004301245o46d8e855va0b51ebce279398b@mail.gmail.com>
On Fri, Apr 30, 2010 at 3:45 PM, Avery Pennarun <apenwarr@gmail.com> wrote:
Show 12 quoted lines
> On Thu, Apr 29, 2010 at 7:12 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
>> Let's say you've got a repo with ~ 40K files and 35K commits.
>> Well-packed .git is about 800MB.
>>
>> You want to find out how many lines of code a particular group of
>> individuals has contributed to HEAD.
>>[...]
>> Am I missing a clever solution?
>
> How often do you need to do this?  If it's just once in your life,
> then the brute force solution of just letting 'git blame' grind
> through it for a few hours is probably the cleverest :)
Yeah, I ended up doing this basically.
Setup a .mailmap mapping the authors I was interested in to domain.com. Then:
$ git log --pretty='%H %aE' HEAD | grep domain.com |
  awk '{print $1}' |
  git log --no-walk --stdin --name-only --pretty=%n |
  grep -v '^$' | sort -u > files1
$ git ls-files | sort > files2
$ comm -12 files1 files2 > files
$ xargs < files -n1 git annotate | grep domain.com

I didn't use --author=domain.com w/the first log invocation because I wasn't sure if it respected .mailmap and was too lazy to look it up.

I probably I could've used --diff-filter in the second log invocation, but, meh.

So that worked. Took about 12 minutes to run on a recent Macbook Pro. Aside, blame's --porcelain switch is rather poorly documented and annotate seemed to have the right output for the job.

j.
Previous: Avery PennarunNext: Jeff King
Message 3 of 4 in “How to efficiently blame an entire repo?”
  1. Jay SoffianApr 29, 2010
  2. Avery PennarunApr 30, 2010
  3. Jay SoffianApr 30, 2010
  4. Jeff KingApr 30, 2010

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.