]> git.ipfire.org Git - thirdparty/git.git/commit
repository: stop initializing the object database in `repo_set_gitdir()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 26 May 2026 05:56:59 +0000 (07:56 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 May 2026 11:07:02 +0000 (20:07 +0900)
commit56d8ff4aa9f8df1d0c4f010c28039e195497a7fc
treebde3100394ea2363e5e449cb31c2362271055b97
parent92f21def3fd5fe13a56216b56b7e1cd94a71e4b2
repository: stop initializing the object database in `repo_set_gitdir()`

The function `repo_set_gitdir()` obviously sets the Git directory for a
given repository. Less obviously though, the function also configures a
couple of auxiliary settings.

One such thing is that we create the object database in this function.
This logic only happens conditionally though, as `set_git_dir()` may be
called multiple times during repository setup, and we don't want to
create the object database multiple times. This is somewhat tangled and
hard to follow.

Remove the logic from `repo_set_gitdir()` and instead initialize the
object database outside of it. This leads to some duplication right now,
but that duplication will be removed in a subsequent step where we will
start initializing the object database as part of applying the repo's
format.

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