mirror of
https://github.com/git/git.git
synced 2026-08-09 01:21:47 +00:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
3d884b0b56
commit
6a2fbab4c9
7
setup.c
7
setup.c
@@ -1045,17 +1045,18 @@ static void setup_git_env_internal(struct repository *repo,
|
||||
struct strvec to_free = STRVEC_INIT;
|
||||
|
||||
args.commondir = getenv_safe(&to_free, GIT_COMMON_DIR_ENVIRONMENT);
|
||||
args.object_dir = getenv_safe(&to_free, DB_ENVIRONMENT);
|
||||
args.graft_file = getenv_safe(&to_free, GRAFT_ENVIRONMENT);
|
||||
args.index_file = getenv_safe(&to_free, INDEX_ENVIRONMENT);
|
||||
args.alternate_db = getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT);
|
||||
if (getenv(GIT_QUARANTINE_ENVIRONMENT))
|
||||
args.disable_ref_updates = true;
|
||||
args.skip_initializing_odb = skip_initializing_odb;
|
||||
|
||||
repo_set_gitdir(repo, git_dir, &args);
|
||||
strvec_clear(&to_free);
|
||||
|
||||
if (!skip_initializing_odb)
|
||||
repo->objects = odb_new(repo, getenv_safe(&to_free, DB_ENVIRONMENT),
|
||||
getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT));
|
||||
|
||||
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
|
||||
disable_replace_refs();
|
||||
replace_ref_base = getenv(GIT_REPLACE_REF_BASE_ENVIRONMENT);
|
||||
|
||||
Reference in New Issue
Block a user