}
static void setup_git_env_internal(struct repository *repo,
- const char *git_dir,
- bool skip_initializing_odb)
+ const char *git_dir)
{
char *git_replace_ref_base;
const char *shallow_file;
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);
fetch_if_missing = 0;
}
-static void set_git_dir_1(struct repository *repo, const char *path, bool skip_initializing_odb)
+static void set_git_dir_1(struct repository *repo, const char *path)
{
xsetenv(GIT_DIR_ENVIRONMENT, path, 1);
- setup_git_env_internal(repo, path, skip_initializing_odb);
+ setup_git_env_internal(repo, path);
}
static void update_relative_gitdir(const char *name UNUSED,
trace_printf_key(&trace_setup_key,
"setup: move $GIT_DIR to '%s'",
path);
- set_git_dir_1(repo, path, true);
+ set_git_dir_1(repo, path);
free(path);
}
path = realpath.buf;
}
- set_git_dir_1(repo, path, false);
+ set_git_dir_1(repo, path);
if (!is_absolute_path(path))
chdir_notify_register(NULL, update_relative_gitdir, repo);
}
if (is_git_directory(".")) {
+ struct strvec to_free = STRVEC_INIT;
+
set_git_dir(repo, ".", 0);
+ repo->objects = odb_new(repo,
+ getenv_safe(&to_free, DB_ENVIRONMENT),
+ getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT));
check_and_apply_repository_format(repo, NULL);
+
+ strvec_clear(&to_free);
return path;
}
startup_info->have_repository ||
/* GIT_DIR_EXPLICIT */
getenv(GIT_DIR_ENVIRONMENT)) {
+ struct strvec to_free = STRVEC_INIT;
+
if (!repo->gitdir) {
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
if (!gitdir)
gitdir = DEFAULT_GIT_DIR_ENVIRONMENT;
- setup_git_env_internal(repo, gitdir, false);
+ setup_git_env_internal(repo, gitdir);
}
+ repo->objects = odb_new(repo,
+ getenv_safe(&to_free, DB_ENVIRONMENT),
+ getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT));
+
if (startup_info->have_repository) {
struct strbuf err = STRBUF_INIT;
clear_repository_format(&repo_fmt);
strbuf_release(&err);
}
+
+ strvec_clear(&to_free);
}
/*
* Since precompose_string_if_needed() needs to look at
int exist_ok = flags & INIT_DB_EXIST_OK;
char *original_git_dir = real_pathdup(git_dir, 1);
struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
+ struct strvec to_free = STRVEC_INIT;
if (real_git_dir) {
struct stat st;
}
startup_info->have_repository = 1;
+ repo->objects = odb_new(repo, getenv_safe(&to_free, DB_ENVIRONMENT),
+ getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT));
+
/*
* Check to see if the repository version is right.
* Note that a newly created repository does not have
}
clear_repository_format(&repo_fmt);
+ strvec_clear(&to_free);
free(original_git_dir);
return 0;
}