environment: make get_git_dir()
accept a repository
The `get_git_dir()` function retrieves the path to the Git directory for `the_repository`. Make it accept a `struct repository` such that it can work on arbitrary repositories and make it part of the repository subsystem. This reduces our reliance on `the_repository` and clarifies scope. 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
17d4b10aea
commit
246deeac95
12
setup.c
12
setup.c
@ -149,7 +149,7 @@ char *prefix_path(const char *prefix, int len, const char *path)
|
||||
if (!r) {
|
||||
const char *hint_path = get_git_work_tree();
|
||||
if (!hint_path)
|
||||
hint_path = get_git_dir();
|
||||
hint_path = repo_get_git_dir(the_repository);
|
||||
die(_("'%s' is outside repository at '%s'"), path,
|
||||
absolute_path(hint_path));
|
||||
}
|
||||
@ -468,7 +468,7 @@ int is_nonbare_repository_dir(struct strbuf *path)
|
||||
int is_inside_git_dir(void)
|
||||
{
|
||||
if (inside_git_dir < 0)
|
||||
inside_git_dir = is_inside_dir(get_git_dir());
|
||||
inside_git_dir = is_inside_dir(repo_get_git_dir(the_repository));
|
||||
return inside_git_dir;
|
||||
}
|
||||
|
||||
@ -1836,7 +1836,7 @@ void check_repository_format(struct repository_format *fmt)
|
||||
struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
|
||||
if (!fmt)
|
||||
fmt = &repo_fmt;
|
||||
check_repository_format_gently(get_git_dir(), fmt, NULL);
|
||||
check_repository_format_gently(repo_get_git_dir(the_repository), fmt, NULL);
|
||||
startup_info->have_repository = 1;
|
||||
repo_set_hash_algo(the_repository, fmt->hash_algo);
|
||||
repo_set_compat_hash_algo(the_repository, fmt->compat_hash_algo);
|
||||
@ -2224,7 +2224,7 @@ static int create_default_files(const char *template_path,
|
||||
* shared-repository settings, we would need to fix them up.
|
||||
*/
|
||||
if (get_shared_repository()) {
|
||||
adjust_shared_perm(get_git_dir());
|
||||
adjust_shared_perm(repo_get_git_dir(the_repository));
|
||||
}
|
||||
|
||||
initialize_repository_version(fmt->hash_algo, fmt->ref_storage_format, 0);
|
||||
@ -2434,12 +2434,12 @@ int init_db(const char *git_dir, const char *real_git_dir,
|
||||
die(_("%s already exists"), real_git_dir);
|
||||
|
||||
set_git_dir(real_git_dir, 1);
|
||||
git_dir = get_git_dir();
|
||||
git_dir = repo_get_git_dir(the_repository);
|
||||
separate_git_dir(git_dir, original_git_dir);
|
||||
}
|
||||
else {
|
||||
set_git_dir(git_dir, 1);
|
||||
git_dir = get_git_dir();
|
||||
git_dir = repo_get_git_dir(the_repository);
|
||||
}
|
||||
startup_info->have_repository = 1;
|
||||
|
||||
|
Reference in New Issue
Block a user