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

Re: A generalization of git blame

From
Xxmeng@cs.wisc.edu <xmeng@cs.wisc.edu>
Date
Sep 26, 2012, 15:36 UTC
Message-ID
<72fc15c78ddb6b5c9e95f6b0cd925a26.squirrel@webmail.cs.wisc.edu>
In-Reply-To
<7vsja5vh2z.fsf@alter.siamese.dyndns.org>
Show 76 quoted lines
> "Philip Oakley" <philipoakley@iee.org> writes:
>
>>> To get ground truth of authorship for each line, I start with
>>> git-blame.
>>> But later I find this is not sufficient because the last commit may
>>> only
>>> add comments or may only change a small part of the line, so that I
>>> shouldn't attribute the line of code to the last author.
>>
>> I would suggest there is:
>> - White space adjustment
>> - Comment or documentation (assumes you can parse the 'code' to decide
>> that it isn't executable code)
>> - word changes within expressions
>> - complete replacement of line (whole statement?)
>
> You are being generous by listing easier cases ;-) I'd add a couple
> more that are more problematic if your approach does not consider
> semantics.
>
>  - A function gained a new parameter, to which pretty much everbody
>    passes the same default value.
>
> 	-void fn(int a, int b, int c)
> 	+void fn(int a, int b, int c, int d)
> 	 {
> 	+	if (d) {
> 	+		...
> 	+		return;
> 	+	}
> 		...
> 	 }
>
>          void frotz(void)
> 	 {
> 		...
>         -	fn(a, b, c);
>         +	fn(a, b, c, 0);
>         	...
>         -	fn(a, b, d);
>         +	fn(a, b, d, 1);
>         	...
>
>    The same commit that changed the above call site must have
>    changed the definition of function "fn" and defined what the new
>    fourth parameter means.  It is likely that, when the default
>    value most everybody passes (perhaps "0") is given, "fn" does
>    what it used to do, and a different value may trigger a new
>    behaviour of "fn".  It could be argued that the former call
>    should not be blamed for this commit, while the latter callsite
>    should.
>
>  - A variable was renamed, and the meaning of a line suddenly
>    changed, even though the text of that line did not change at all.
>
> 	 static int foo;
>          ...
>         -int xyzzy(int foo)
> 	+int xyzzy(int bar)
> 	 {
> 		... some complex computation that
>                 ... involves foo and bar, resulting in
>                 ... updating of foo comes here ...
> 		return foo * 2;
>  	 }
>
>    Whom to blame the behaviour of (i.e. returned value from) the
>    function?  The "return foo * 2" never changed with this patch,
>    but the patch _is_ responsible for changing the behaviour.
>
>    As the OP is interested in tracking the origin of the _binary_,
>    this case is even more interesting, as the generated machine code
>    to compute the foo * 2 would likely to be very different before
>    and after the patch.
>
>

Thanks for both your great suggestions. Current my approach doesn't consider semantics yet and this should be an interesting to do.

Another question is that is it possible to include my tool as a git built-in tool in the future? I know that my tool is still not good for any release. But I would like to share my work with other people if other people are interested. And if it is possible, I think I will have a stronger motivation to make my tool more robust and useful.

Thanks
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 7 in “A generalization of git blame”
  1. xmeng@cs.wisc.eduSep 25, 2012
  2. Philip OakleySep 25, 2012
  3. Junio C HamanoSep 25, 2012
  4. xmeng@cs.wisc.eduSep 26, 2012
  5. Junio C HamanoSep 26, 2012
  6. xmeng@cs.wisc.eduSep 27, 2012
  7. Junio C HamanoSep 27, 2012

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.