mirror of
https://github.com/git/git
synced 2024-08-28 12:09:19 +00:00
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>
This commit is contained in:
parent
fa7b3c2f75
commit
a1e4760fcf
|
@ -245,8 +245,16 @@ static unsigned long write_object(struct sha1file *f,
|
||||||
type = entry->type;
|
type = entry->type;
|
||||||
|
|
||||||
/* write limit if limited packsize and not first object */
|
/* write limit if limited packsize and not first object */
|
||||||
limit = pack_size_limit && nr_written ?
|
if (!pack_size_limit || !nr_written)
|
||||||
pack_size_limit - write_offset : 0;
|
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)
|
if (!entry->delta)
|
||||||
usable_delta = 0; /* no delta */
|
usable_delta = 0; /* no delta */
|
||||||
|
|
|
@ -375,4 +375,10 @@ test_expect_success 'index-pack with --strict' '
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
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
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue