From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] unpack-trees: lose USE_THE_REPOSITORY
Date: Tue, 10 Nov 2026 08:04:45 +0100 [thread overview]
Message-ID: <avLCDTHuScp4iLyj@pks.im> (raw)
In-Reply-To: <xmqqecctzttt.fsf@gitster.g>
On Mon, Nov 09, 2026 at 11:30:06AM -0800, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> >> @@ -345,15 +394,16 @@ static void load_gitmodules_file(struct index_state *index,
> >> struct checkout *state)
> >> {
> >> int pos = index_name_pos(index, GITMODULES_FILE, strlen(GITMODULES_FILE));
> >> + struct repository *repo = unpack_repo(index, NULL);
> >
> > This conversion here raises the question what we want to do in the case
> > where the caller has both structures available, but we don't end up
> > passing them to the pointer. This could in theory hide a bug where we
> > have mismatching repositories when the entry points don't verify that
> > property.
>
> Puzzled. Here we do have an istate but have no unpack_trees_options
> available, so it is natural to pass NULL for the latter to tell the
> validator "we do not have unpack_trees_options".
It is natural, but the calling context _does_ have options available.
It's just that the caller of this function here decided to not pass it
down because we previously didn't need it. In fact, every new callsite
of `unpack_repo()` does have options available in their call stack.
> Are you worried about a case where a programmer who writes an
> unpack_repo() call passes NULL by mistake efven when istate or
> unpack_trees_options are available?
All I'm pointing out is that there are cases where we could be as
defensive as everywhere else if we started passing down the options to
calling contexts that don't have it yet. I wouldn't say I'm "worried"
though. The proposed patch is very defensive overall, and I'm not overly
concerned about us missing that defense in some cases.
Patrick
next prev parent reply other threads:[~2026-11-10 7:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 1:26 [PATCH 1/2] unpack-trees: lose USE_THE_REPOSITORY Junio C Hamano
2026-11-07 1:29 ` [PATCH 2/2] unpack-trees: consistently use "struct index_state *istate" Junio C Hamano
2026-11-09 13:46 ` Derrick Stolee
2026-11-09 13:41 ` [PATCH 1/2] unpack-trees: lose USE_THE_REPOSITORY Patrick Steinhardt
2026-11-09 19:30 ` Junio C Hamano
2026-11-10 7:04 ` Patrick Steinhardt [this message]
2026-11-10 16:13 ` Junio C Hamano
2026-11-10 16:40 ` Patrick Steinhardt
2026-11-09 13:45 ` Derrick Stolee
2026-11-09 20:54 ` [PATCH v2 0/2] unpack-trees.c w/o the_repository Junio C Hamano
2026-11-09 20:54 ` [PATCH v2 1/2] unpack-trees: lose USE_THE_REPOSITORY Junio C Hamano
2026-11-09 20:54 ` [PATCH v2 2/2] unpack-trees: consistently use "struct index_state *istate" Junio C Hamano
2026-11-10 13:22 ` [PATCH v2 0/2] unpack-trees.c w/o the_repository Derrick Stolee
2026-11-10 17:28 ` Junio C Hamano
2026-11-11 12:48 ` Patrick Steinhardt
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=avLCDTHuScp4iLyj@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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