diffcore-delta: avoid ignoring final 'line' of file
commit1c5bc6971e28c581b17b812cbbd1f09e39f0bb63
authorElijah Newren <newren@gmail.com>
Sat, 13 Jan 2024 04:26:13 +0000 (13 04:26 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Jan 2024 03:10:11 +0000 (18 19:10 -0800)
tree35205f57d7ae32ab60600d29dcc88857fea51853
parentec583449067bab5b800ecc63926f35c9dae96fa1
diffcore-delta: avoid ignoring final 'line' of file

hash_chars() would hash lines to integers, and store them in a spanhash,
but cut lines at 64 characters.  Thus, whenever it reached 64 characters
or a newline, it would create a new spanhash.  The problem is, the final
part of the file might not end 64 characters after the previous 'line'
and might not end with a newline.  This could, for example, cause an
85-byte file with 12 lines and only the first character in the file
differing to appear merely 23% similar rather than the expected 97%.
Ensure the last line is included, and add a testcase that would have
caught this problem.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diffcore-delta.c
t/t4001-diff-rename.sh