git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Darrin Thompson <darrint@progeny.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/2] diff-delta.c: allow delta with empty blob.
Date: Mon, 12 Dec 2005 12:40:19 -0800	[thread overview]
Message-ID: <7vacf6hwwc.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <1134404990.5928.4.camel@localhost.localdomain> (Darrin Thompson's message of "Mon, 12 Dec 2005 11:29:50 -0500")

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

  parent reply	other threads:[~2005-12-12 20:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-12 16:29 diff-core segfault Darrin Thompson
2005-12-12 16:56 ` Johannes Schindelin
2005-12-12 18:50 ` Junio C Hamano
2005-12-12 18:59   ` Delitifier broken (Re: diff-core segfault) Junio C Hamano
2005-12-12 21:28     ` Nicolas Pitre
2005-12-12 21:54       ` Junio C Hamano
2005-12-12 23:31         ` Linus Torvalds
2005-12-13  1:08           ` Junio C Hamano
2005-12-13  1:34             ` Linus Torvalds
2005-12-13  1:41               ` Junio C Hamano
2005-12-13  2:05               ` Linus Torvalds
2005-12-13  2:45                 ` Nicolas Pitre
2005-12-13  3:23                   ` Junio C Hamano
2005-12-12 20:40 ` Junio C Hamano [this message]
2005-12-12 21:12   ` [PATCH 2/2] diff-delta.c: allow delta with empty blob Darrin Thompson

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=7vacf6hwwc.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=darrint@progeny.com \
    --cc=git@vger.kernel.org \
    /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).