git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] xdiff-interface.c (buffer_is_binary): Remove buffer size limitation
Date: Sat, 1 Dec 2007 19:01:13 +0300	[thread overview]
Message-ID: <20071201160113.GA20849@nomad.office.altlinux.org> (raw)

When checking buffer for NUL byte, do not limit size of buffer we check.
Otherwise we break git-rebase: git-format-patch may generate output which
git-mailinfo cannot handle properly.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 t/t3407-rebase-binary.sh |   32 ++++++++++++++++++++++++++++++++
 xdiff-interface.c        |    3 ---
 2 files changed, 32 insertions(+), 3 deletions(-)
 create mode 100755 t/t3407-rebase-binary.sh

diff --git a/t/t3407-rebase-binary.sh b/t/t3407-rebase-binary.sh
new file mode 100755
index 0000000..213dc9d
--- /dev/null
+++ b/t/t3407-rebase-binary.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+test_description='rebase binary test'
+
+. ./test-lib.sh
+
+yes 1234567 |head -n 2003 >text
+yes 1234567 |head -n 2000 >bin && printf 'binary\0bin\n' >>bin && yes 1234567 |head -n 3 >>bin
+
+test_expect_success setup '
+
+	cat text >file &&
+	git add file &&
+	git commit -m"text" &&
+
+	git branch bin &&
+
+	echo side >side &&
+	git add side &&
+	git commit -m"side" &&
+
+	git checkout bin &&
+	cat bin >file &&
+	git commit -a -m"bin"
+'
+
+test_expect_success rebase '
+
+	git rebase master
+'
+
+test_done
diff --git a/xdiff-interface.c b/xdiff-interface.c
index be866d1..fa9f58d 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -122,11 +122,8 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
 	return 0;
 }
 
-#define FIRST_FEW_BYTES 8000
 int buffer_is_binary(const char *ptr, unsigned long size)
 {
-	if (FIRST_FEW_BYTES < size)
-		size = FIRST_FEW_BYTES;
 	return !!memchr(ptr, 0, size);
 }
 
-- 
ldv

             reply	other threads:[~2007-12-01 16:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-01 16:01 Dmitry V. Levin [this message]
2007-12-01 19:46 ` [PATCH] xdiff-interface.c (buffer_is_binary): Remove buffer size limitation Junio C Hamano
2007-12-03 21:50   ` Dmitry V. Levin
2007-12-03 23:24     ` Junio C Hamano
2007-12-04  0:00     ` Linus Torvalds
2007-12-04  1:00       ` Johannes Schindelin
2007-12-05 10:47         ` David Kastrup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071201160113.GA20849@nomad.office.altlinux.org \
    --to=ldv@altlinux.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).