Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Elia Pinto <gitter.spiros@gmail.com>
Cc: git@vger.kernel.org,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"René Scharfe" <l.s.r@web.de>
Subject: Re: [PATCH 2/2] tree: use size_t for the size of parsed trees
Date: Tue, 17 Nov 2026 19:47:32 -0800	[thread overview]
Message-ID: <xmqqh5he94x7.fsf@gitster.g> (raw)
In-Reply-To: <0b1d1c5668c89e3329e246d787ec80a161bd1dac.1793357680.git.gitter.spiros@gmail.com> (Elia Pinto's message of "Fri, 30 Oct 2026 11:58:23 +0100")

Elia Pinto <gitter.spiros@gmail.com> writes:

> 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.

> 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.


  reply	other threads:[~2026-11-18  3:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 10:58 [PATCH 0/2] tree-walk: use size_t for tree sizes Elia Pinto
2026-10-30 10:58 ` [PATCH 1/2] tree-walk: use size_t for the size of tree buffers Elia Pinto
2026-11-18  2:32   ` Junio C Hamano
2026-10-30 10:58 ` [PATCH 2/2] tree: use size_t for the size of parsed trees Elia Pinto
2026-11-18  3:47   ` Junio C Hamano [this message]
2026-11-17 21:42 ` [PATCH 0/2] tree-walk: use size_t for tree sizes Elia Pinto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqh5he94x7.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitter.spiros@gmail.com \
    --cc=l.s.r@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox