threads / discuss / 37510

Check out git-author

Subject: Check out git-author

## tl;dr

3 messages between Sep 7, 2014 and Sep 8, 2014.

replies: 2people: 3as markdown or json

xmeng· Sep 7, 2014, 23:05 UTC · lore
Hi all,

I have been using git-blame to track who changed a line of code or who to blame for a line of code. It is easy to use. For example, for this particular line of code:

$ git blame -L 2235,2235 fs/ext4/mballoc.c 85556c9a (Wei Yongjun 2012-09-26 20:43:37 -0400 2235) meta_group_info[i] = kmem_cache_zalloc(cachep, GFP_KERNEL);

The problem with git-blame is that it only reports the last author/commit that changed the line, regardless of the magnitude of the change. Sometimes, the last author may only change a tiny part of the code and should not be blamed. I developed a built-in tool called "git-author" to address this problem. Git-author is designed to track the complete development history of a line. For the same line of code:

$ git author -c -L 2235,2235 fs/ext4/mballoc.c
        CURRENT LINE 2235:       meta_group_info[i] = 
kmem_cache_zalloc(cachep, GFP_KERNEL);
85556c9 Wei Yongjun     :       meta_group_info[i] = 
kmem_cache_zalloc(cachep, GFP_KERNEL);
fb1813f Curt Wohlgemuth :       meta_group_info[i] = 
kmem_cache_alloc(cachep, GFP_KERNEL);
5f21b0e Frederic Bohe   :       meta_group_info[i] = kzalloc(len, 
GFP_KERNEL);
c9de560 Alex Tomas      :               meta_group_info[j] = 
kzalloc(len, GFP_KERNEL);

Git-author shows the complete development history of this line code. We can see "Wei Yongjun" only changed the line to call a different function (from "kmem_cache_alloc" to "kmem_cache_zalloc"). "Wei yongjun" is not responsible for the other part of the line. "Curt Wohlgemuth" changed the line to call a different function (from "kzalloc" to "kmem_cache_alloc") and to use a different parameter (from "len" to "cachep") and "Frederic Bohe" changed the line to use a different array index (from "i" to "j").

Git-author should be useful to people who wants to see the complete history of lines of code.

If you are interested in git-author, you can check it out at https://github.com/mxz297/git/tree/git-author (please check out branch 'git-author'). Also we have a paper describing more technical details about git-author in ICSM 2013 (ftp://ftp.cs.wisc.edu/paradyn/papers/Meng13Authorship.pdf).

Let me know if you have any question, feedback, bug about git-author!
Thanks
--Xiaozhu
Jeff King· Sep 8, 2014, 05:19 UTC · re: xmeng · lore

Re: Check out git-author

On Sun, Sep 07, 2014 at 06:05:13PM -0500, xmeng wrote:
Show 9 quoted lines
> The problem with git-blame is that it only reports the last author/commit
> that changed the line, regardless of the magnitude of the change. Sometimes,
> the last author may only change a tiny part of the code and should not be
> blamed. I developed a built-in tool called "git-author" to address this
> problem. Git-author is designed to track the complete development history of
> a line. For the same line of code:
> 
> $ git author -c -L 2235,2235 fs/ext4/mballoc.c
> [...]

Have you tried "git log -L 2235,2235:fs/ext4/mballoc.c -- fs/ext4/mballoc.c"? Can you compare your approach to that of "log -L"?

-Peff
Torsten Bögershausen· Sep 8, 2014, 07:16 UTC · re: Jeff King · lore

Re: Check out git-author

On 09/08/2014 07:19 AM, Jeff King wrote:
Show 5 quoted lines
> Have you tried "git log -L 2235,2235:fs/ext4/mballoc.c --
> fs/ext4/mballoc.c"? Can you compare your approach to that of "log -L"?
>
> -Peff
>
Nice, but it doesn't seem to work 100 % (?)

tb@linux:~/projects/git/git.pu/t$ git log t3910-mac-os-precompose.sh | grep "^commit" commit 1265886303778b5a2631c41c6ee61094c5fda7b0 commit a4cf6b4b91835c1d8d13ebb5cf3ce9241e181f1b commit 750b2e4785e5956122b3c565af65eb1929714fba commit 92b0c8bed0d3f6ed5442e3ffa178413772faa31b commit 308566eb8b35b9279082bd5398c4252169d52b22 commit 76759c7dff53e8c84e975b88cb8245587c14c7ba

I'm quite sure that line 15 looks like this in the original commit 76759c7d:
">junk/"$Adiarnfc" &&"
But it is not shown:
tb@linux:~/projects/git/git.pu/t$ git log -L 
15,15:t3910-mac-os-precompose.sh -- t3910-mac-os-precompose.sh
commit 308566eb8b35b9279082bd5398c4252169d52b22
Author: Michael J Gruber <git@drmicha.warpmail.net>
Date:   Mon Jul 30 11:57:18 2012 +0200
     t3910: use the UTF8_NFD_TO_NFC test prereq
     Besides reusing the new test prerequisite, this fixes also the issue
     that the current output is not TAP compliant and produces the 
output "no
     reason given" [for skipping].
     Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
     Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/t/t3910-mac-os-precompose.sh b/t/t3910-mac-os-precompose.sh
--- a/t/t3910-mac-os-precompose.sh
+++ b/t/t3910-mac-os-precompose.sh
@@ -10,0 +15,1 @@
+
============================
But line 20 seems to work better (I shortened the output by using grep):

tb@linux:~/projects/git/git.pu/t$ git log -L 
20,20:t3910-mac-os-precompose.sh -- t3910-mac-os-precompose.sh | grep 
"^commit"
commit a4cf6b4b91835c1d8d13ebb5cf3ce9241e181f1b
commit 308566eb8b35b9279082bd5398c4252169d52b22
commit 76759c7dff53e8c84e975b88cb8245587c14c7ba

← back to recent threads