RE: Understanding behavior of git blame -M

2014-08-18 Thread Sokolov, Konstantin (ext)
Seems like not detecting single line movements is per design and just the 
documentation is not precise about this. Could such an enhancement be 
considered as a feature request? We're using git (blame) as a low level tool 
for building further functionality on top of it. Maintaining a custom version 
of git is a big step that we would like to avoid.

Regards
Konstantin

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Understanding behavior of git blame -M

2014-08-15 Thread Duy Nguyen
On Fri, Aug 15, 2014 at 9:42 PM, David Kastrup  wrote:
> The function diff_hunks is a wrapper for the diff engine.  Putting the
> context length explicitly into this wrapper (rather than not passing an
> argument and just setting the context length to zero anyway in the
> function) clearly indicates that somebody _wanted_ it called with
> different values.
>
> There is no documentation or rationale in the file _why_ as far as
> I remember.  Maybe it can crash or end up in an infinite loop.  Maybe it
> could do so at one point of time but no longer does.

Not sure if it helps, but ctxlen = 1 seems to be added back in d24bba8
(git-pickaxe -M: blame line movements within a file. - 2006-10-19), if
I track the changes correctly.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Understanding behavior of git blame -M

2014-08-15 Thread Junio C Hamano
"Sokolov, Konstantin (ext)" 
writes:

>>git blame -s -n -f -w -M20 file.txt
> ^2cd9f7f 1 1) A
> ^2cd9f7f 3 2) 2
> ^2cd9f7f 4 3) D
> d4bbd97e 4 4) B
> ^2cd9f7f 5 5) E
> ^2cd9f7f 6 6) G
> ^2cd9f7f 7 7) F
>
> I wonder, why line B is not recognized as moved. According to the
> documentation, I would expect git blame to report that it
> originates from line 2 in revision 2cd9f7f. Can anybody explain
> the behavior?

Interesting.  Would it make a difference if you move B further away
from lines A and C?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Understanding behavior of git blame -M

2014-08-15 Thread David Kastrup
"Sokolov, Konstantin (ext)"  writes:

> Hi Folks,
>
> I'm trying to understand the behavior of git blame -M and find that
> the actual results differ from what I understood from the
> documentation. I've already asked longer time ago on stackoverflow and
> on the user mailing list without any satisfactory results. So here is
> the example:
>
> Initial content of file.txt (2cd9f7f)
>
> A
> B
> 2
> D
> E
> G
> F
>
> Move line B to the middle (d4bbd97e):
>
> A
> 2
> D
> B
> E
> G
> F
>
>>git blame -s -n -f -w -M20 file.txt
> ^2cd9f7f 1 1) A
> ^2cd9f7f 3 2) 2
> ^2cd9f7f 4 3) D
> d4bbd97e 4 4) B
> ^2cd9f7f 5 5) E
> ^2cd9f7f 6 6) G
> ^2cd9f7f 7 7) F
>
> I wonder, why line B is not recognized as moved. According to the
> documentation, I would expect git blame to report that it originates
> from line 2 in revision 2cd9f7f. Can anybody explain the behavior?

Someone had reasons.  diff_hunks in builtin/blame.c is once called with
0 as third argument, once with 1.  Change the latter call to using 0 as
well and you get your expected result:

dak@lola:/tmp/test$ /usr/local/tmp/git/git blame -s -n -f -w -M20 file.txt
^2cab496 file.txt 1 1) A
^2cab496 file.txt 3 2) 2
^2cab496 file.txt 4 3) D
^2cab496 file.txt 2 4) B
^2cab496 file.txt 5 5) E
^2cab496 file.txt 6 6) G
^2cab496 file.txt 7 7) F

The function diff_hunks is a wrapper for the diff engine.  Putting the
context length explicitly into this wrapper (rather than not passing an
argument and just setting the context length to zero anyway in the
function) clearly indicates that somebody _wanted_ it called with
different values.

There is no documentation or rationale in the file _why_ as far as
I remember.  Maybe it can crash or end up in an infinite loop.  Maybe it
could do so at one point of time but no longer does.

Maybe Git is just a puzzle from genius to genius.  Good luck figuring it
out.

I have not touched this when rewriting git-blame recently, and I am not
interested in touching it.  I stand absolutely nothing to gain from
working on Git.

-- 
David Kastrup
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html