From: Patrick Steinhardt <ps@pks.im>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Karthik Nayak <karthik.188@gmail.com>
Subject: Re: [PATCH v2 7/8] refs: fix recursing `get_main_ref_store()` with "onbranch" config
Date: Mon, 22 Jun 2026 07:15:46 +0200 [thread overview]
Message-ID: <ajjFAjyGjk6q792L@pks.im> (raw)
In-Reply-To: <20260621211211.GA2297179@coredump.intra.peff.net>
On Sun, Jun 21, 2026 at 05:12:11PM -0400, Jeff King wrote:
> On Fri, Jun 19, 2026 at 08:25:42AM +0200, Patrick Steinhardt wrote:
> > On Thu, Jun 18, 2026 at 12:40:35PM -0400, Jeff King wrote:
> > > On Mon, Jun 15, 2026 at 03:56:53PM +0200, Patrick Steinhardt wrote:
> > I actually tried lazy-loading, but I found it to be quite painful
> > overall, as the above setting isn't the only one we use. The reftable
> > backend for example has a bunch of additional settings that it reads.
> >
> > We could of course start lazy-loading all of these. But that may not
> > work for future backends that really _need_ to parse some configuration
> > at initiation time.
>
> Yes, obviously there's some true chicken-and-egg issues if there are
> config keys that are needed to initialize the backend. But I think there
> are many that are not needed immediately (e.g., because they relate only
> to writes, not reads) but still block loading.
>
> For example, try this:
>
> git init
> git config core.logallrefupdates false
> git config includeIf.onbranch:main.path alt-config
> git config -f .git/alt-config core.logallrefupdates true
> git commit --allow-empty -qm foo
>
> echo "git-config => $(git config core.logallrefupdates)"
> echo "reflog => $(git reflog show)"
>
> git-config will report the value as true, but git-commit will not
> respect it. But this used to work! Back when onbranch was added, we'd
> create the reflog. Bisecting turns up eafb126456 (environment: stop
> storing "core.logAllRefUpdates" globally, 2024-09-12), which makes
> sense. That commit pushed the config read down into the ref
> initialization function, which created the chicken-and-egg.
>
> Now the config shown above is a bit silly, and I don't expect anybody to
> do it in real life. But what worries me is two-fold:
>
> 1. There are some magic variables that just won't work with onbranch
> includes, but the user doesn't necessarily know what they are.
>
> 2. We try to cache the results of config reads. Is it possible for an
> "early" request like this to cache a state that skipped the
> onbranch include, and then we use that state to look up other
> unrelated variables? Or could we see a partially completed state in
> the cache when we lookup a ref variable?
>
> I'm not sure. The actual backend lookups use the uncached
> repo_config() interface (and in your series here, explicitly
> disables the use of refs during that read). But the
> core.logallrefupdates lookup uses the cached version, and I think
> there are others (some of which happen deep under the hood
> through library calls, like calc_shared_perm()).
>
> I tried to construct a few cases that might tickle this behavior, but
> couldn't come up with one. But I have a nagging feeling that we are
> mostly getting lucky on some of the ordering, and a seemingly unrelated
> change could have bad effects.
>
> Sorry, I know that's kind of vague and hand-wavy.
>
> I'm not sure I have a specific recommendation for a direction. It just
> feels like we're piling up hacks to avoid infinite recursion without a
> clear model of what config is read when. I guess if I could suggest
> anything, it would be that ref backends initialize themselves to do
> reads while loading as little config as possible, and then perhaps load
> additional config through the non-caching repo_config() path.
Yeah, I thought more about this issue over the weekend and kind of got
to the same conclusion. Sure, the current version where we explicitly
handle the exclusion of "onbranch" conditions is at least less awkward.
But I have to agree that it's still not the right fix, as it doesn't
really solve the root issue.
Taking a step back: all the values that we currently parse are only
relevant when writing new refs. So in theory it should be possible to
lazy-load all of them on the first write. This should be rather easy to
do for the "files" backend. But for the "reftable" backend this will
result in a large refactoring because we require the configuration when
constructing the reftable stack.
That's kind of misdesigned though: the reftable stack shouldn't really
care about write options when being constructed. What it needs to know
about is the expected hash ID, and any optional stuff like the onreload
callback. The write options should then be passed by the caller when we
actually perform a write.
I'll iterate a bit on this idea and will see where I get. I really
shouldn't have opened this can of worms.
Thanks!
Patrick
next prev parent reply other threads:[~2026-06-22 5:15 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 14:57 [PATCH 0/9] refs: stop using `chdir_notify_reparent()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 1/9] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 2/9] setup: stop applying repository format twice Patrick Steinhardt
2026-06-12 9:00 ` Karthik Nayak
2026-06-15 12:36 ` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 3/9] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-10 17:32 ` Junio C Hamano
2026-06-12 6:18 ` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 4/9] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-12 9:18 ` Karthik Nayak
2026-06-15 12:36 ` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 5/9] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 6/9] repository: free main reference database Patrick Steinhardt
2026-06-12 9:20 ` Karthik Nayak
2026-06-10 14:57 ` [PATCH 7/9] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 8/9] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
2026-06-10 14:57 ` [PATCH 9/9] refs: always use absolute paths for reference stores Patrick Steinhardt
2026-06-12 9:58 ` Karthik Nayak
2026-06-15 12:36 ` Patrick Steinhardt
2026-06-11 6:53 ` [PATCH 0/9] refs: stop using `chdir_notify_reparent()` Jeff King
2026-06-12 6:18 ` Patrick Steinhardt
2026-06-13 14:00 ` Jeff King
2026-06-15 12:36 ` Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 0/8] " Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 1/8] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 2/8] setup: stop applying repository format twice Patrick Steinhardt
2026-06-17 17:22 ` Justin Tobler
2026-06-15 13:56 ` [PATCH v2 3/8] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-17 17:43 ` Justin Tobler
2026-06-18 6:53 ` Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 4/8] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-17 18:02 ` Justin Tobler
2026-06-17 18:07 ` Justin Tobler
2026-06-18 6:54 ` Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 5/8] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-15 13:56 ` [PATCH v2 6/8] repository: free main reference database Patrick Steinhardt
2026-06-17 18:09 ` Justin Tobler
2026-06-15 13:56 ` [PATCH v2 7/8] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-17 18:41 ` Justin Tobler
2026-06-18 5:59 ` Patrick Steinhardt
2026-06-18 14:15 ` Justin Tobler
2026-06-18 14:51 ` Patrick Steinhardt
2026-06-18 15:53 ` Justin Tobler
2026-06-18 16:40 ` Jeff King
2026-06-19 6:25 ` Patrick Steinhardt
2026-06-21 21:12 ` Jeff King
2026-06-22 5:15 ` Patrick Steinhardt [this message]
2026-06-15 13:56 ` [PATCH v2 8/8] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
2026-06-18 6:54 ` [PATCH v3 0/8] refs: stop using `chdir_notify_reparent()` Patrick Steinhardt
2026-06-18 6:54 ` [PATCH v3 1/8] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-18 6:54 ` [PATCH v3 2/8] setup: stop applying repository format twice Patrick Steinhardt
2026-06-18 6:54 ` [PATCH v3 3/8] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-18 6:54 ` [PATCH v3 4/8] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-18 6:54 ` [PATCH v3 5/8] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-18 6:54 ` [PATCH v3 6/8] repository: free main reference database Patrick Steinhardt
2026-06-18 6:54 ` [PATCH v3 7/8] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-18 6:54 ` [PATCH v3 8/8] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 00/10] refs: stop using `chdir_notify_reparent()` Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 01/10] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 02/10] setup: stop applying repository format twice Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 03/10] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 04/10] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 05/10] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 06/10] repository: free main reference database Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 07/10] refs: move parsing of "core.logAllRefUpdates" back into ref stores Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 08/10] refs/reftable-backend: manually parse "core.sharedRepository" Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 09/10] refs: fix recursing `get_main_ref_store()` with "onbranch" config Patrick Steinhardt
2026-06-19 11:27 ` [PATCH v4 10/10] refs: drop local buffer in `refs_compute_filesystem_location()` Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 00/11] refs: fix "onbranch" conditions Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 01/11] setup: inline `check_and_apply_repository_format()` Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 02/11] setup: stop applying repository format twice Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 03/11] setup: don't apply "GIT_REFERENCE_BACKEND" without a repository Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 04/11] refs: unregister reference stores from "chdir_notify" Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 05/11] chdir-notify: drop unused `chdir_notify_reparent()` Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 06/11] repository: free main reference database Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 07/11] refs: move parsing of "core.logAllRefUpdates" back into ref stores Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 08/11] refs/files: lazy-load configuration to fix chicken-and-egg Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 09/11] reftable: split up write options Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 10/11] refs/reftable: lazy-load configuration to fix chicken-and-egg Patrick Steinhardt
2026-06-22 8:28 ` [PATCH v5 11/11] refs: protect against chicken-and-egg recursion 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=ajjFAjyGjk6q792L@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=karthik.188@gmail.com \
--cc=peff@peff.net \
/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