]> git.ipfire.org Git - thirdparty/git.git/commit - blame.c
blame: use the fingerprint heuristic to match ignored lines
authorBarret Rhoden <brho@google.com>
Thu, 20 Jun 2019 16:38:19 +0000 (12:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jun 2019 20:38:09 +0000 (13:38 -0700)
commita07a97760cbf2e794600157a5a9f61a888a17941
treeac22afcf779b28ef3456abd55a42656c37cd073f
parent1d028dc682d0cb4420fb124419ebc60e913d421c
blame: use the fingerprint heuristic to match ignored lines

This commit integrates the fuzzy fingerprint heuristic into
guess_line_blames().

We actually make two passes.  The first pass uses the fuzzy algorithm to
find a match within the current diff chunk.  If that fails, the second
pass searches the entire parent file for the best match.

For an example of scanning the entire parent for a match, consider:

commit-a 30) #include <sys/header_a.h>
commit-b 31) #include <header_b.h>
commit-c 32) #include <header_c.h>

Then commit X alphabetizes them:

commit-X 30) #include <header_b.h>
commit-X 31) #include <header_c.h>
commit-X 32) #include <sys/header_a.h>

If we just check the parent's chunk (i.e. the first pass), we'd get:

commit-b 30) #include <header_b.h>
commit-c 31) #include <header_c.h>
commit-X 32) #include <sys/header_a.h>

That's because commit X actually consists of two chunks: one chunk is
removing sys/header_a.h, then some context, and the second chunk is
adding sys/header_a.h.

If we scan the entire parent file, we get:

commit-b 30) #include <header_b.h>
commit-c 31) #include <header_c.h>
commit-a 32) #include <sys/header_a.h>

Signed-off-by: Barret Rhoden <brho@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
blame.c
t/t8014-blame-ignore-fuzzy.sh