git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] xdiff-interface.c (buffer_is_binary): Remove buffer size limitation

From
Dmitry V. Levin <ldv@altlinux.org>
Date
Dec 1, 2007, 16:01 UTC
Message-ID
<20071201160113.GA20849@nomad.office.altlinux.org>

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
Next: Junio C Hamano
Message 1 of 7 in “xdiff-interface.c (buffer_is_binary): Remove buffer size limitation”
  1. xdiff-interface.c (buffer_is_binary): Remove buffer size limitationDmitry V. Levin, Dec 1, 2007
  2. Junio C HamanoDec 1, 2007
  3. Dmitry V. LevinDec 3, 2007
  4. Junio C HamanoDec 3, 2007
  5. Linus TorvaldsDec 4, 2007
  6. Johannes SchindelinDec 4, 2007
  7. David KastrupDec 5, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.