summaryrefslogtreecommitdiff
path: root/builtin-pack-objects.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2008-11-12 13:23:58 -0500
committerJunio C Hamano <gitster@pobox.com>2008-11-12 14:55:03 -0800
commita1e4760fcfece8eb9b556f35a04a521fdee3963c (patch)
tree4923753aaa855dedfab330b250856b99cca5cea2 /builtin-pack-objects.c
parentfa7b3c2f752a10a5dca9989d4a1c4b93ffa7f943 (diff)
downloadgit-a1e4760fcfece8eb9b556f35a04a521fdee3963c.tar.gz
Fix pack.packSizeLimit and --max-pack-size handling
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>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r--builtin-pack-objects.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index b0dddbee4f..8fe51244e0 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -245,8 +245,16 @@ static unsigned long write_object(struct sha1file *f,
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 */