diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-09-12 13:29:24 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-09-12 19:15:39 +0200 |
commit | 246deeac9517d6daba89bfcf6de6d290e39af585 (patch) | |
tree | d604806493140d8f3f9e26f705c749b4a0535311 /builtin/commit.c | |
parent | The tenth batch (diff) | |
download | git-246deeac9517d6daba89bfcf6de6d290e39af585.tar.xz git-246deeac9517d6daba89bfcf6de6d290e39af585.zip |
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>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r-- | builtin/commit.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index b2033c4887..a1c1d16a09 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -26,6 +26,7 @@ #include "path.h" #include "preload-index.h" #include "read-cache.h" +#include "repository.h" #include "string-list.h" #include "rerere.h" #include "unpack-trees.h" @@ -407,7 +408,7 @@ static const char *prepare_index(const char **argv, const char *prefix, discard_index(the_repository->index); read_index_from(the_repository->index, get_lock_file_path(&index_lock), - get_git_dir()); + repo_get_git_dir(the_repository)); if (cache_tree_update(the_repository->index, WRITE_TREE_SILENT) == 0) { if (reopen_lock_file(&index_lock) < 0) die(_("unable to write index file")); @@ -534,7 +535,7 @@ static const char *prepare_index(const char **argv, const char *prefix, discard_index(the_repository->index); ret = get_lock_file_path(&false_lock); - read_index_from(the_repository->index, ret, get_git_dir()); + read_index_from(the_repository->index, ret, repo_get_git_dir(the_repository)); out: string_list_clear(&partial, 0); clear_pathspec(&pathspec); @@ -1072,7 +1073,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, */ discard_index(the_repository->index); } - read_index_from(the_repository->index, index_file, get_git_dir()); + read_index_from(the_repository->index, index_file, repo_get_git_dir(the_repository)); if (cache_tree_update(the_repository->index, 0)) { error(_("Error building trees")); |