{"thread":{"id":"3369","subject":"[PATCH 3/5] Optionally support old diffs","startedAt":"2006-02-17T14:23:16Z","lastAt":"2006-02-17T14:23:16Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"16319","messageId":"Pine.LNX.4.63.0602171522560.24274@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"3369","inReplyTo":null,"subject":"[PATCH 3/5] Optionally support old diffs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-02-17T14:23:16Z","receivedAt":"2006-02-17T14:23:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSome versions of diff do not correctly detect a missing new-line at the end\nof the file under certain circumstances.\n\nWhen defining NO_ACCURATE_DIFF, work around this bug.\n\nSigned-off-by: Johannes E. Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n Makefile |    6 ++++++\n apply.c  |    8 ++++++++\n 2 files changed, 14 insertions(+), 0 deletions(-)\n\n46183bd251ffe3fc3cbbf4d94467627f922d6d43\ndiff --git a/Makefile b/Makefile\nindex b3401ac..6e00737 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -55,6 +55,9 @@ all:\n #\n # Define NO_ICONV if your libc does not properly support iconv.\n #\n+# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses\n+# a missing newline at the end of the file.\n+#\n # Define COLLISION_CHECK below if you believe that SHA1's\n # 1461501637330902918203684832716283019655932542976 hashes do not give you\n # sufficient guarantee that no collisions between objects will ever happen.\n@@ -405,6 +408,9 @@ else\n \tLIBS += $(LIB_4_CRYPTO)\n endif\n endif\n+endif\n+ifdef NO_ACCURATE_DIFF\n+\tALL_CFLAGS += -DNO_ACCURATE_DIFF\n endif\n \n # Shell quote (do not use $(call) to accomodate ancient setups);\ndiff --git a/apply.c b/apply.c\nindex 2ad47fb..1083d4f 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -1142,6 +1142,14 @@ static int apply_one_fragment(struct buf\n \t\tsize -= len;\n \t}\n \n+#ifdef NO_ACCURATE_DIFF\n+\tif (oldsize > 0 && old[oldsize - 1] == '\\n' &&\n+\t\t\tnewsize > 0 && new[newsize - 1] == '\\n') {\n+\t\toldsize--;\n+\t\tnewsize--;\n+\t}\n+#endif\n+\t\t\t\n \toffset = find_offset(buf, desc->size, old, oldsize, frag->newpos);\n \tif (offset >= 0) {\n \t\tint diff = newsize - oldsize;\n-- \n1.2.1.g09fe-dirty\n"}]}