]> git.ipfire.org Git - thirdparty/git.git/commit
odb: handle initialization of sources in `odb_new()`
authorPatrick Steinhardt <ps@pks.im>
Wed, 19 Nov 2025 07:50:58 +0000 (08:50 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Nov 2025 20:16:00 +0000 (12:16 -0800)
commit35d9fc65edc0a5df9f714d02afaa2c942fb28570
treee468c9ab58a7c7c403b3c48ccd879effa9c3f43e
parentc257bd59165e2f55dfa2c97b0ca1e39131513654
odb: handle initialization of sources in `odb_new()`

The logic to set up a new object database is currently distributed
across two functions in "repository.c":

  - In `initialize_repository()` we initialize an empty object database.
    This object database is not fully initialized and doesn't have any
    sources attached to it.

  - The primary object database source is then created in
    `repo_set_gitdir()`.

Ideally though, the logic should be entirely self-contained so that we
can iterate more readily on how exactly the sources themselves get set
up.

Refactor `odb_new()` to handle both allocation and setup of the object
database. This ensures that the object database is always initialized
and ready for use, and it allows us to change how the sources get set up
eventually.

Note that `repo_set_gitdir()` still reaches into the sources when the
function gets called with an already-initialized object database. This
will be fixed in the next commit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb.c
odb.h
repository.c