]> Kevux Git Server - rit/commit
pack-objects: use size_t for in-core object sizes
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 15 Jun 2026 11:52:27 +0000 (11:52 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Jun 2026 14:45:41 +0000 (07:45 -0700)
commit188bac14f7258df67030dd3e244dd4a63a406df5
tree1491ac271994c2e05a0cc88a53e0af16fd4d701e
parent2d83cc3f84594dc1fb79626c3eae4af3e942e882
pack-objects: use size_t for in-core object sizes

`pack-objects` stores per-entry object sizes in either the 31-bit
`size_` member of the `struct object_entry` or, when the value does not
fit, the `pack->delta_size[]` spill array.  The accessors (`oe_size`,
`oe_delta_size`, `oe_get_size_slow`, `oe_size_*_than`) and the setters
(`oe_set_size`, `oe_set_delta_size`) used `unsigned long` for the spill
type, which on Windows means the spill silently caps at 4 GiB per entry.
That is what made `upload-pack` die with "object too large to read on
this platform" when serving the >4 GiB blob in `t5608` tests 5 and 6
when run with `GIT_TEST_CLONE_2GB`.

Widen them all to `size_t` (including `pack->delta_size`) and drop the
three `cast_size_t_to_ulong()` calls in `check_object()` that guarded
`in_pack_size`.  The two `SET_SIZE(entry, canonical_size)` calls in the
same function stay cast-free as before, since `canonical_size` is still
`unsigned long` until a later commit widens `object_info::sizep`.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
pack-objects.h