patch-id: ignore newline at end of file in diff_flush_patch_id()
commit82a62015a7b55a56f779b9ddfb98a3b0552d2bb4
authorRené Scharfe <l.s.r@web.de>
Tue, 18 Aug 2020 22:08:54 +0000 (19 00:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Aug 2020 23:14:01 +0000 (18 16:14 -0700)
tree0000a420a30cea4448b2da8954ec3dce797dfcdf
parent47ae905ffb98cc4d4fd90083da6bc8dab55d9ecc
patch-id: ignore newline at end of file in diff_flush_patch_id()

Whitespace is ignored when calculating patch IDs.  This is done by
removing all whitespace from diff lines before hashing them, including
a newline at the end of a file.  If that newline is missing, however,
diff reports that fact in a separate line containing "\ No newline at
end of file\n", and this marker is hashed like a context line.

This goes against our goal of making patch IDs independent of
whitespace.  Use the same heuristic that 2485eab55cc (git-patch-id: do
not trip over "no newline" markers, 2011-02-17) added to git patch-id
instead and skip diff lines that start with a backslash and a space
and are longer than twelve characters.

Reported-by: Tilman Vogel <tilman.vogel@web.de>
Initial-test-by: Tilman Vogel <tilman.vogel@web.de>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t3500-cherry.sh