[PATCH v4 00/10] refs: stop using `chdir_notify_reparent()`
From: Patrick Steinhardt <hidden>
Date: 2026-06-19 11:28:05
Hi,
this patch series is a follow-up of the discussion at [1]. It converts
the reference backends to always use absolute paths internally, which
then allows us to drop the calls to `chdir_notify_reparent()`.
Unfortunately, the series has grown quite a bit larger than anticipated.
This is due to a couple of weirdnesses in how the reference database is
constructed with an "onbranch" condition. We essentially construct the
refdb twice and loose one, but we never noticed because the chdir
notification subsystem kept the pointer to it reachable.
Note that the first couple patches that touch "setup.c" aren't strictly
required. They are a remnant of a previous iteration where I tried to
solve the issue in a different way. But I ultimately figured that these
changes are worth it by themselves as they simplify "setup.c" a bit.
This series is built on top of 1ff279f340 (The 13th batch, 2026-06-09)
with ps/setup-centralize-odb-creation at 42b9d3dc9d (setup: construct
object database in `apply_repository_format()`, 2026-06-04) merged into
it.
Changes in v4:
- Fix the "onbranch" recursion at the root of the problem by
explicitly disabling the use of the ref store when parsing
configuration at ref store initialization time.
- Link to v3: https://patch.msgid.link/20260618-b4-pks-refs-avoid-chdir-notify-reparent-v3-0-2a5669e8f486@pks.im
Changes in v3:
- Reduce the scope of applying the GIT_REFERENCE_BACKEND environment
variable even further so that we really only do this when we end up
applying the reference format.
- Fix a commit message that still referred to the dropped last commit.
- Link to v2: https://patch.msgid.link/20260615-b4-pks-refs-avoid-chdir-notify-reparent-v2-0-f4854aa99859@pks.im
Changes in v2:
- Drop the last patch. This seemingly destroys the whole purpose of
the patch series, but after Peff's hint that this is actually a
performance optimization I'm less inclined to drop the chdir_notify
infra. I still think that the remainder of the patches make sense
standalone, as they simplify "setup.c" and clean memory leaks. Going
forward I'd like to investigate the idea of introducing a `struct
fsroot` infrastructure that uses the platform-equivalent of openat
et al.
- Improve a couple of commit messages.
- Link to v1: https://patch.msgid.link/20260610-b4-pks-refs-avoid-chdir-notify-reparent-v1-0-56c864b01c43@pks.im
Thanks!
Patrick
[1]: [ref]
---
Patrick Steinhardt (10):
setup: inline `check_and_apply_repository_format()`
setup: stop applying repository format twice
setup: don't apply "GIT_REFERENCE_BACKEND" without a repository
refs: unregister reference stores from "chdir_notify"
chdir-notify: drop unused `chdir_notify_reparent()`
repository: free main reference database
refs: move parsing of "core.logAllRefUpdates" back into ref stores
refs/reftable-backend: manually parse "core.sharedRepository"
refs: fix recursing `get_main_ref_store()` with "onbranch" config
refs: drop local buffer in `refs_compute_filesystem_location()`
builtin/checkout.c | 7 ++-
chdir-notify.c | 26 ------------
chdir-notify.h | 6 +--
config.c | 4 +-
config.h | 1 +
path.c | 11 ++---
path.h | 2 +-
refs.c | 25 ++++++++---
refs.h | 9 ++++
refs/files-backend.c | 48 ++++++++++++++++++---
refs/packed-backend.c | 16 ++++++-
refs/refs-internal.h | 6 ---
refs/reftable-backend.c | 50 +++++++++++++++++-----
repo-settings.c | 16 -------
repo-settings.h | 9 ----
repository.c | 5 +++
setup.c | 110 +++++++++++++++++++++---------------------------
17 files changed, 192 insertions(+), 159 deletions(-)
Range-diff versus v3:
1: 3ac83ba983 = 1: 3ae112f84b setup: inline `check_and_apply_repository_format()`
2: b6b15770eb = 2: d03fb25a01 setup: stop applying repository format twice
3: 5850f0602d = 3: f437af7ce6 setup: don't apply "GIT_REFERENCE_BACKEND" without a repository
4: e4b12483b4 = 4: 7704b7e5db refs: unregister reference stores from "chdir_notify"
5: 4a78c5080a = 5: 545fe82dda chdir-notify: drop unused `chdir_notify_reparent()`
6: 3f8ae36acc = 6: 5ac9f8c2b3 repository: free main reference database
7: 2a22f9a2e0 < -: ---------- refs: fix recursing `get_main_ref_store()` with "onbranch" config
-: ---------- > 7: 0482470af1 refs: move parsing of "core.logAllRefUpdates" back into ref stores
-: ---------- > 8: 1b2f9d4ff9 refs/reftable-backend: manually parse "core.sharedRepository"
-: ---------- > 9: c7ec7d887f refs: fix recursing `get_main_ref_store()` with "onbranch" config
8: 6bc943659d = 10: 5fb782268b refs: drop local buffer in `refs_compute_filesystem_location()`
---
base-commit: 255322df35357168daefec8523a3cdc849edd6c1
change-id: 20260609-b4-pks-refs-avoid-chdir-notify-reparent-a4eaf1edbcab