From: Derrick Stolee <stolee@gmail.com>
To: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Rasmus Villemoes <ravi@prevas.dk>,
Daniel Mach <daniel.mach@suse.com>
Subject: Re: [PATCH] commit: fall back to full read when maybe_tree is NULL
Date: Wed, 20 May 2026 12:22:02 -0400 [thread overview]
Message-ID: <478ff417-d5d0-458f-b5cd-472373eed7b2@gmail.com> (raw)
In-Reply-To: <20260519061534.GA1709881@coredump.intra.peff.net>
On 5/19/2026 2:15 AM, Jeff King wrote:
> On Tue, May 19, 2026 at 02:56:51PM +0900, Junio C Hamano wrote:
>> Looks quite straight-forward. Don't you need to pay attention to
>> r->hash_algo and call parse_oid_hex_algop() instead?
>>
>> Or are we pretty much sure that "r" is always "the_repository" here,
>> in which case parse_oid_hex() that uses "the_hash_algo" would be
>> sufficient?
>
> No, I didn't even think about it, since the use of the_hash_algo is
> hidden behind the function. We definitely should use the hash algo from
> "r", since we have access to it. I'm not even sure if you can have repos
> of two different hashes loaded in the same process at this point, but
> certainly it is the correct long-term direction.
>
> Here's a re-roll with the one-line fixup:
>
> diff --git a/commit.c b/commit.c
> index cfc87ad185..499a9602ad 100644
> --- a/commit.c
> +++ b/commit.c
> @@ -448,7 +448,7 @@ static void load_tree_from_commit_contents(struct repository *r, struct commit *
>
> if (type == OBJ_COMMIT &&
> skip_prefix(buf, "tree ", &p) &&
> - !parse_oid_hex(p, &tree_oid, &p) &&
> + !parse_oid_hex_algop(p, &tree_oid, &p, r->hash_algo) &&
> *p == '\n')
> set_commit_tree(commit, lookup_tree(r, &tree_oid));
>
I figured that this was already tested via the test variable that
runs the test with SHA256, but the multi-repo case is an interesting
one that I'm sure would catch us at some point in the future.
I'm happy with the re-roll here.
Thanks,
-Stolee
next prev parent reply other threads:[~2026-05-20 16:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 5:05 [PATCH] commit: fall back to full read when maybe_tree is NULL Jeff King
2026-05-19 5:56 ` Junio C Hamano
2026-05-19 6:15 ` Jeff King
2026-05-20 16:22 ` Derrick Stolee [this message]
2026-05-19 6:25 ` Rasmus Villemoes
2026-05-20 16:20 ` Derrick Stolee
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=478ff417-d5d0-458f-b5cd-472373eed7b2@gmail.com \
--to=stolee@gmail.com \
--cc=daniel.mach@suse.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=ravi@prevas.dk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.