[PATCH 00/13] Centralize management of object database sources
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 19, 2025, 07:50 UTC
- Message-ID
- <20251119-b4-pks-odb-creation-v1-0-2b2ed2612cb6@pks.im>
Hi,
currently, the creation of the object databases is handled both by "setup.c" and by "odb.c". While it's expected that "setup.c" is the one setting up the object database itself, what's less so is that there is a shared responsibility for managing its sources:
- The primary object database source gets created in "setup.c".
- The temporary source used during ODB transactions is handled by
"setup.c" when changing the current working directory. - Relative paths stored in object database sources get updated by
"setup.c" when changing the current working directory.This means that the management of ODB sources is somewhat cluttered and thus hard to understand. Furthermore, it has the consequence that "setup.c" reaches into internals of the ODB that really shouldn't be any of its concern.
This patch series cleans that up and moves all handling of ODB sources into "odb.c". This hopefully makes the logic easier to understand and it will allow us to eventually handle the logic for different backends in a single central location.
The series is structured as follows:
- Patches 1 to 5 clean up some smaller nuisances in the vicinity.
- Patches 6 to 9 refactor a couple of callsites that play weird games
with the object database. These cause us to re-initialize the ODB
multiple times, which will not be allowed anymore at the end of this
series. - Patches 10 to 13 move the logic that manages object sources from
"setup.c" into "odb.c".This series is built on top of v2.52.0 with ps/object-source-loose at 3e5e360888 (object-file: refactor writing objects via a stream, 2025-11-03) merged into it.
Thanks!
Patrick
---
Patrick Steinhardt (13):
path: move `enter_repo()` into "setup.c"
setup: convert `set_git_dir()` to have file scope
odb: adopt logic to close object databases
odb: refactor `odb_clear()` to `odb_free()`
odb: move logic to disable ref updates into repo
oidset: introduce `oidset_equal()`
builtin/index-pack: fix deferred fsck outside repos
t/helper: stop setting up `the_repository` repeatedly
http-push: stop setting up `the_repository` for each reference
odb: handle initialization of sources in `odb_new()`
chdir-notify: add function to unregister listeners
odb: handle changing a repository's commondir
odb: handle recreation of quarantine directoriesbuiltin/clone.c | 2 +- builtin/gc.c | 2 +- builtin/index-pack.c | 21 ++++- builtin/receive-pack.c | 2 +- builtin/repack.c | 2 +- builtin/upload-archive.c | 2 +- builtin/upload-pack.c | 2 +- chdir-notify.c | 18 ++++ chdir-notify.h | 2 + fsck.c | 6 ++ fsck.h | 7 ++ http-backend.c | 1 + http-push.c | 5 +- midx-write.c | 2 +- odb.c | 98 +++++++++++++++++---- odb.h | 37 +++++--- oidset.c | 16 ++++ oidset.h | 9 +- packfile.c | 15 ---- packfile.h | 1 - path.c | 100 --------------------- path.h | 15 ---- refs.c | 2 +- repository.c | 27 ++---- repository.h | 10 ++- run-command.c | 2 +- scalar.c | 2 +- setup.c | 214 +++++++++++++++++++++++++++++++-------------- setup.h | 39 ++++++++- t/helper/test-repository.c | 16 +--- t/t5302-pack-index.sh | 16 ++++ 31 files changed, 414 insertions(+), 279 deletions(-)
--- base-commit: 0ce8ad0c2b447fea8e7abd0236367a9f38ce92fe change-id: 20251107-b4-pks-odb-creation-96c18fdab1d2