[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