This adds scoring logic to blame_entry to prevent blames on very
trivial chunks (e.g. lots of empty lines, indent followed by a
closing brace) from being passed down to unrelated lines in the
parent.
The current heuristics are quite simple and may need to be
tweaked later, but we need to start somewhere.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Instead of comparing number of lines matched, look at the
matched characters and count alnums, so that we do not pass
blame on not-so-interesting lines, such as an empty line and
a line that is indentation followed by a closing brace.
Add an option --score-debug to show the score of each
blame_entry while we cook this further on the "next" branch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
We would want to be able to refer to the end of the file as
"the beginning of Nth line" for a file that is N lines long.
Signed-off-by: Junio C Hamano <junkio@cox.net>
This completes the initial round of git-pickaxe. In addition to
the detection of line movements we already have, this finds new
lines that were created by moving or cutting-and-pasting lines
from different files in the parent.
With this,
git pickaxe -f -n -C v1.4.0 -- revision.c
finds that a major part of that file actually came from
rev-list.c when Linus split the latter at commit ae563642 and
blames them to earlier commits that touch rev-list.c.
Signed-off-by: Junio C Hamano <junkio@cox.net>
This makes pickaxe more intelligent than the classic blame.
A typical example is a change that moves one static C function
from lower part of the file to upper part of the same file,
because you added a new caller in the middle.
The versions in the parent and the child would look like this:
parent child
A static foo() {
B ...
C }
D A
E B
F C
G D
static foo() { ... call foo();
... E
} F
H G
H
With the classic blame algorithm, we can blame lines A B C D E F
G and H to the parent. The child is guilty of introducing the
line "... call foo();", and the blame is placed on the child.
However, the classic blame algorithm fails to notice that the
implementation of foo() at the top of the file is not new, and
moved from the lower part of the parent.
This commit introduces detection of such line movements, and
correctly blames the lines that were simply moved in the file to
the parent.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Currently it does what git-blame does, but only faster.
More importantly, its internal structure is designed to support
content movement (aka cut-and-paste) more easily by allowing
more than one paths to be taken from the same commit.
Signed-off-by: Junio C Hamano <junkio@cox.net>