From f527cb8c38964a90b1b13485f2ad46b72960d387 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 20 Apr 2006 23:36:22 -0700 Subject: pack-objects: do not stop at object that is "too small" Because we sort the delta window by name-hash and then size, hitting an object that is too small to consider as a delta base for the current object does not mean we do not have better candidate in the window beyond it. Noticed by Shawn Pearce, analyzed by Nico, Linus and me. Signed-off-by: Junio C Hamano --- pack-objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pack-objects.c') diff --git a/pack-objects.c b/pack-objects.c index 09f4f2c944..f7d621757a 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -1052,7 +1052,7 @@ static int try_delta(struct unpacked *cur, struct unpacked *old, unsigned max_de if (cur_entry->delta) max_size = cur_entry->delta_size-1; if (sizediff >= max_size) - return -1; + return 0; delta_buf = diff_delta(old->data, oldsize, cur->data, size, &delta_size, max_size); if (!delta_buf) -- cgit v1.2.1 From 0dec30b9788b12fdae5d5b69fc366a28bb688d80 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Thu, 20 Apr 2006 17:25:37 -0400 Subject: fix pack-object buffer size The input line has 40 _chars_ of sha1 and no 20 _bytes_. It should also account for the space before the pathname, and the terminating \n and \0. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- pack-objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pack-objects.c') diff --git a/pack-objects.c b/pack-objects.c index f7d621757a..c0acc460bb 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -1231,7 +1231,7 @@ static void setup_progress_signal(void) int main(int argc, char **argv) { SHA_CTX ctx; - char line[PATH_MAX + 20]; + char line[40 + 1 + PATH_MAX + 2]; int window = 10, depth = 10, pack_to_stdout = 0; struct object_entry **list; int num_preferred_base = 0; -- cgit v1.2.1