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

[PATCH 2/2] diff-delta.c: allow delta with empty blob.

From
Junio C Hamano <junkio@cox.net>
Date
Dec 12, 2005, 20:40 UTC
Message-ID
<7vacf6hwwc.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1134404990.5928.4.camel@localhost.localdomain>

Delta computation with an empty blob used to punt and returned NULL. This commit allows creation with empty blob; all combination of empty->empty, empty->something, and something->empty are allowed.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 Darrin Thompson <darrint@progeny.com> writes:
 > $ git-diff-files -B
 > Segmentation fault
 > Could someone confirm that this exists on more recent git heads and fix
 > if needed?
 Could you try this patch?  It is marked as 2/2 but 1/2 is a
 test script to reproduce the problem with the current code,
 which this patch is supposed to fix, and this should be the
 only fix you need.
 delta.h      |    4 ++--
 diff-delta.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
1e4d6f6618abb72e3948419d113a6f2f14c83ebc
diff --git a/delta.h b/delta.h
index 31d1820..c6a4763 100644
--- a/delta.h
+++ b/delta.h
@@ -9,8 +9,8 @@ extern void *patch_delta(void *src_buf, 
 			 void *delta_buf, unsigned long delta_size,
 			 unsigned long *dst_size);
 
-/* the smallest possible delta size is 4 bytes */
-#define DELTA_SIZE_MIN	4
+/* the smallest possible delta size is 2 bytes (empty to empty) */
+#define DELTA_SIZE_MIN	2
 
 /*
  * This must be called twice on the delta data buffer, first to get the
diff --git a/diff-delta.c b/diff-delta.c
index b2ae7b5..cf50138 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -213,7 +213,7 @@ void *diff_delta(void *from_buf, unsigne
 	bdrecord_t *brec;
 	bdfile_t bdf;
 
-	if (!from_size || !to_size || delta_prepare(from_buf, from_size, &bdf))
+	if (delta_prepare(from_buf, from_size, &bdf))
 		return NULL;
 	
 	outpos = 0;
-- 
0.99.9.GIT
Previous: Junio C HamanoNext: Darrin Thompson
Message 14 of 15 in “diff-core segfault”
  1. Darrin ThompsonDec 12, 2005
  2. Johannes SchindelinDec 12, 2005
  3. Junio C HamanoDec 12, 2005
  4. Delitifier broken (Re: diff-core segfault)Junio C Hamano, Dec 12, 2005
  5. Nicolas PitreDec 12, 2005
  6. Junio C HamanoDec 12, 2005
  7. Linus TorvaldsDec 12, 2005
  8. Junio C HamanoDec 13, 2005
  9. Linus TorvaldsDec 13, 2005
  10. Junio C HamanoDec 13, 2005
  11. Linus TorvaldsDec 13, 2005
  12. Nicolas PitreDec 13, 2005
  13. Junio C HamanoDec 13, 2005
  14. 2/2 diff-delta.c: allow delta with empty blob.Junio C Hamano, Dec 12, 2005
  15. Darrin ThompsonDec 12, 2005

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.