[PATCH 2/2] tree: use size_t for the size of parsed trees
- From
Elia Pinto <gitter.spiros@gmail.com>
- Date
- Oct 30, 2026, 10:58 UTC
- Message-ID
- <0b1d1c5668c89e3329e246d787ec80a161bd1dac.1793357680.git.gitter.spiros@gmail.com>
- In-Reply-To
- <cover.1793357680.git.gitter.spiros@gmail.com>
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.
Signed-off-by: Elia Pinto <gitter.spiros@gmail.com> --- tree.c | 2 +- tree.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
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; diff --git a/tree.h b/tree.h index 677382eed8..50f0b15af4 100644 --- a/tree.h +++ b/tree.h @@ -10,14 +10,14 @@ struct strbuf; struct tree { struct object object; void *buffer; - unsigned long size; + size_t size; }; extern const char *tree_type; struct tree *lookup_tree(struct repository *r, const struct object_id *oid); -int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size); +int parse_tree_buffer(struct tree *item, void *buffer, size_t size); #define parse_tree_gently(t, q) repo_parse_tree_gently(the_repository, t, q) int repo_parse_tree_gently(struct repository *r, struct tree *item,
-- 2.53.0