summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fa7b3c2)
raw | patch | inline | side by side (parent: fa7b3c2)
author | Nicolas Pitre <nico@cam.org> | |
Wed, 12 Nov 2008 18:23:58 +0000 (13:23 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 12 Nov 2008 22:55:03 +0000 (14:55 -0800) |
If the limit was sufficiently low, having a single object written
could bust the limit (by design), but caused the remaining allowed
size to go negative for subsequent objects, which for an unsigned
variable is a rather huge limit.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
could bust the limit (by design), but caused the remaining allowed
size to go negative for subsequent objects, which for an unsigned
variable is a rather huge limit.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-pack-objects.c | patch | blob | history | |
t/t5300-pack-object.sh | patch | blob | history |
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index b0dddbee4f93de462090218554e1b1b6d1038c34..8fe51244e069da96b669c260a37f4b7cf831026f 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
type = entry->type;
/* write limit if limited packsize and not first object */
- limit = pack_size_limit && nr_written ?
- pack_size_limit - write_offset : 0;
+ if (!pack_size_limit || !nr_written)
+ limit = 0;
+ else if (pack_size_limit <= write_offset)
+ /*
+ * the earlier object did not fit the limit; avoid
+ * mistaking this with unlimited (i.e. limit = 0).
+ */
+ limit = 1;
+ else
+ limit = pack_size_limit - write_offset;
if (!entry->delta)
usable_delta = 0; /* no delta */
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 3a0ef8759c9d7a55b95c56ca38cd3c37ac2432fa..2852a0326546f50f0cbefb4d5621c889b52f33c9 100755 (executable)
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
)
'
+test_expect_success 'tolerate absurdly small packsizelimit' '
+ git config pack.packSizeLimit 2 &&
+ packname_9=$(git pack-objects test-9 <obj-list) &&
+ test $(wc -l <obj-list) = $(ls test-9-*.pack | wc -l)
+'
+
test_done