summaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2006-02-17 14:23:16 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-02-18 00:32:41 (GMT)
commit5b5d4d9e1b31997b3179e6a253d47b7eea03d0fa (patch)
tree02d77f8531075a56ed6dc904a02b45c91b379ed3 /apply.c
parent8e1618f9612a78ea09b2a926797c781fe06027c9 (diff)
downloadgit-5b5d4d9e1b31997b3179e6a253d47b7eea03d0fa.zip
git-5b5d4d9e1b31997b3179e6a253d47b7eea03d0fa.tar.gz
git-5b5d4d9e1b31997b3179e6a253d47b7eea03d0fa.tar.bz2
Optionally support old diffs
Some versions of diff do not correctly detect a missing new-line at the end of the file under certain circumstances. When defining NO_ACCURATE_DIFF, work around this bug. Signed-off-by: Johannes E. Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/apply.c b/apply.c
index 2ad47fb..1083d4f 100644
--- a/apply.c
+++ b/apply.c
@@ -1142,6 +1142,14 @@ static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag)
size -= len;
}
+#ifdef NO_ACCURATE_DIFF
+ if (oldsize > 0 && old[oldsize - 1] == '\n' &&
+ newsize > 0 && new[newsize - 1] == '\n') {
+ oldsize--;
+ newsize--;
+ }
+#endif
+
offset = find_offset(buf, desc->size, old, oldsize, frag->newpos);
if (offset >= 0) {
int diff = newsize - oldsize;