Re: [PATCH 2/2] tree: use size_t for the size of parsed trees
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 18, 2026, 03:47 UTC
- Message-ID
- <xmqqh5he94x7.fsf@gitster.g>
- In-Reply-To
- <0b1d1c5668c89e3329e246d787ec80a161bd1dac.1793357680.git.gitter.spiros@gmail.com>
Elia Pinto <gitter.spiros@gmail.com> writes:
Show 10 quoted lines
> struct tree stores the size of its buffer in an "unsigned long", which > is only 32 bits wide on Windows, and parse_tree_buffer() takes it as > such, although repo_parse_tree_gently() gets it from odb_read_object() > as a size_t. Callers then pass tree->size to init_tree_desc(), so with > the previous commit a tree of 4GiB or more is still truncated on > Windows before it gets there. > > Use size_t for both. parse_object_buffer() still hands an "unsigned > long" size to parse_tree_buffer(); it is shared with the other object > types and is left for a later change.
Sounds good to me.
Show 13 quoted lines
> diff --git a/tree.c b/tree.c
> index 53f7395e9f..d37b9bc7b1 100644
> --- a/tree.c
> +++ b/tree.c
> @@ -172,7 +172,7 @@ struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
> return object_as_type(obj, OBJ_TREE, 0);
> }
>
> -int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
> +int parse_tree_buffer(struct tree *item, void *buffer, size_t size)
> {
> if (item->object.parsed)
> return 0;The only caller of this function, object.c:parse_object_buffer(), has its size as ulong. Even though this alone would not help end-to-end, as a "one thing at a time" step, this patch may be OK.