sha1_file.c: move delayed getenv(altdb) back to setup_git_env()
getenv() is supposed to work on the main repository only. This delayed getenv() code in sha1_file.c makes it more difficult to convert sha1_file.c to a generic object store that could be used by both submodule and main repositories. Move the getenv() back in setup_git_env() where other env vars are also fetched. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
0ac5af5995
commit
7bc0dcaa61
|
@ -174,6 +174,7 @@ void setup_git_env(const char *git_dir)
|
||||||
args.object_dir = getenv_safe(&to_free, DB_ENVIRONMENT);
|
args.object_dir = getenv_safe(&to_free, DB_ENVIRONMENT);
|
||||||
args.graft_file = getenv_safe(&to_free, GRAFT_ENVIRONMENT);
|
args.graft_file = getenv_safe(&to_free, GRAFT_ENVIRONMENT);
|
||||||
args.index_file = getenv_safe(&to_free, INDEX_ENVIRONMENT);
|
args.index_file = getenv_safe(&to_free, INDEX_ENVIRONMENT);
|
||||||
|
args.alternate_db = getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT);
|
||||||
repo_set_gitdir(the_repository, git_dir, &args);
|
repo_set_gitdir(the_repository, git_dir, &args);
|
||||||
argv_array_clear(&to_free);
|
argv_array_clear(&to_free);
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@ void repo_set_gitdir(struct repository *repo,
|
||||||
repo_set_commondir(repo, o->commondir);
|
repo_set_commondir(repo, o->commondir);
|
||||||
expand_base_dir(&repo->objectdir, o->object_dir,
|
expand_base_dir(&repo->objectdir, o->object_dir,
|
||||||
repo->commondir, "objects");
|
repo->commondir, "objects");
|
||||||
|
free(repo->alternate_db);
|
||||||
|
repo->alternate_db = xstrdup_or_null(o->alternate_db);
|
||||||
expand_base_dir(&repo->graft_file, o->graft_file,
|
expand_base_dir(&repo->graft_file, o->graft_file,
|
||||||
repo->commondir, "info/grafts");
|
repo->commondir, "info/grafts");
|
||||||
expand_base_dir(&repo->index_file, o->index_file,
|
expand_base_dir(&repo->index_file, o->index_file,
|
||||||
|
@ -215,6 +217,7 @@ void repo_clear(struct repository *repo)
|
||||||
FREE_AND_NULL(repo->gitdir);
|
FREE_AND_NULL(repo->gitdir);
|
||||||
FREE_AND_NULL(repo->commondir);
|
FREE_AND_NULL(repo->commondir);
|
||||||
FREE_AND_NULL(repo->objectdir);
|
FREE_AND_NULL(repo->objectdir);
|
||||||
|
FREE_AND_NULL(repo->alternate_db);
|
||||||
FREE_AND_NULL(repo->graft_file);
|
FREE_AND_NULL(repo->graft_file);
|
||||||
FREE_AND_NULL(repo->index_file);
|
FREE_AND_NULL(repo->index_file);
|
||||||
FREE_AND_NULL(repo->worktree);
|
FREE_AND_NULL(repo->worktree);
|
||||||
|
|
|
@ -26,6 +26,9 @@ struct repository {
|
||||||
*/
|
*/
|
||||||
char *objectdir;
|
char *objectdir;
|
||||||
|
|
||||||
|
/* Path to extra alternate object database if not NULL */
|
||||||
|
char *alternate_db;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Path to the repository's graft file.
|
* Path to the repository's graft file.
|
||||||
* Cannot be NULL after initialization.
|
* Cannot be NULL after initialization.
|
||||||
|
@ -93,6 +96,7 @@ struct set_gitdir_args {
|
||||||
const char *object_dir;
|
const char *object_dir;
|
||||||
const char *graft_file;
|
const char *graft_file;
|
||||||
const char *index_file;
|
const char *index_file;
|
||||||
|
const char *alternate_db;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void repo_set_gitdir(struct repository *repo,
|
extern void repo_set_gitdir(struct repository *repo,
|
||||||
|
|
|
@ -667,15 +667,11 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)
|
||||||
|
|
||||||
void prepare_alt_odb(void)
|
void prepare_alt_odb(void)
|
||||||
{
|
{
|
||||||
const char *alt;
|
|
||||||
|
|
||||||
if (alt_odb_tail)
|
if (alt_odb_tail)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
alt = getenv(ALTERNATE_DB_ENVIRONMENT);
|
|
||||||
|
|
||||||
alt_odb_tail = &alt_odb_list;
|
alt_odb_tail = &alt_odb_list;
|
||||||
link_alt_odb_entries(alt, PATH_SEP, NULL, 0);
|
link_alt_odb_entries(the_repository->alternate_db, PATH_SEP, NULL, 0);
|
||||||
|
|
||||||
read_info_alternates(get_object_directory(), 0);
|
read_info_alternates(get_object_directory(), 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue