1035
}
1036
1037
static void setup_git_env_internal(struct repository *repo,
1038
- const char *git_dir,
1039
- bool skip_initializing_odb)
1038
+ const char *git_dir)
1039
{
1040
char *git_replace_ref_base;
1041
const char *shallow_file;
1052
repo_set_gitdir(repo, git_dir, &args);
1053
strvec_clear(&to_free);
1054
1056
- if (!skip_initializing_odb)
1057
- repo->objects = odb_new(repo, getenv_safe(&to_free, DB_ENVIRONMENT),
1058
- getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT));
1059
-
1055
if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
1056
disable_replace_refs();
1057
replace_ref_base = getenv(GIT_REPLACE_REF_BASE_ENVIRONMENT);
1067
fetch_if_missing = 0;
1068
}
1069
1075
-static void set_git_dir_1(struct repository *repo, const char *path, bool skip_initializing_odb)
1070
+static void set_git_dir_1(struct repository *repo, const char *path)
1071
{
1072
xsetenv(GIT_DIR_ENVIRONMENT, path, 1);
1078
- setup_git_env_internal(repo, path, skip_initializing_odb);
1073
+ setup_git_env_internal(repo, path);
1074
}
1075
1076
static void update_relative_gitdir(const char *name UNUSED,
1084
trace_printf_key(&trace_setup_key,
1085
"setup: move $GIT_DIR to '%s'",
1086
path);
1092
- set_git_dir_1(repo, path, true);
1087
+ set_git_dir_1(repo, path);
1088
free(path);
1089
}
1090
1097
path = realpath.buf;
1098
}
1099
1105
- set_git_dir_1(repo, path, false);
1100
+ set_git_dir_1(repo, path);
1101
if (!is_absolute_path(path))
1102
chdir_notify_register(NULL, update_relative_gitdir, repo);
1103
1874
}
1875
1876
if (is_git_directory(".")) {
1877
+ struct strvec to_free = STRVEC_INIT;
1878
+
1879
set_git_dir(repo, ".", 0);
1880
+ repo->objects = odb_new(repo,
1881
+ getenv_safe(&to_free, DB_ENVIRONMENT),
1882
+ getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT));
1883
check_and_apply_repository_format(repo, NULL);
1884
+
1885
+ strvec_clear(&to_free);
1886
return path;
1887
}
1888
2034
startup_info->have_repository ||
2035
/* GIT_DIR_EXPLICIT */
2036
getenv(GIT_DIR_ENVIRONMENT)) {
2037
+ struct strvec to_free = STRVEC_INIT;
2038
+
2039
if (!repo->gitdir) {
2040
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
2041
if (!gitdir)
2042
gitdir = DEFAULT_GIT_DIR_ENVIRONMENT;
2039
- setup_git_env_internal(repo, gitdir, false);
2043
+ setup_git_env_internal(repo, gitdir);
2044
}
2045
2046
+ repo->objects = odb_new(repo,
2047
+ getenv_safe(&to_free, DB_ENVIRONMENT),
2048
+ getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT));
2049
+
2050
if (startup_info->have_repository) {
2051
struct strbuf err = STRBUF_INIT;
2052
2056
clear_repository_format(&repo_fmt);
2057
strbuf_release(&err);
2058
}
2059
+
2060
+ strvec_clear(&to_free);
2061
}
2062
/*
2063
* Since precompose_string_if_needed() needs to look at
2806
int exist_ok = flags & INIT_DB_EXIST_OK;
2807
char *original_git_dir = real_pathdup(git_dir, 1);
2808
struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
2809
+ struct strvec to_free = STRVEC_INIT;
2810
2811
if (real_git_dir) {
2812
struct stat st;
2827
}
2828
startup_info->have_repository = 1;
2829
2830
+ repo->objects = odb_new(repo, getenv_safe(&to_free, DB_ENVIRONMENT),
2831
+ getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT));
2832
+
2833
/*
2834
* Check to see if the repository version is right.
2835
* Note that a newly created repository does not have
2893
}
2894
2895
clear_repository_format(&repo_fmt);
2896
+ strvec_clear(&to_free);
2897
free(original_git_dir);
2898
return 0;
2899
}