summaryrefslogtreecommitdiffstats
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-09-12 13:29:24 +0200
committerJunio C Hamano <gitster@pobox.com>2024-09-12 19:15:39 +0200
commit246deeac9517d6daba89bfcf6de6d290e39af585 (patch)
treed604806493140d8f3f9e26f705c749b4a0535311 /builtin/commit.c
parentThe tenth batch (diff)
downloadgit-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.c7
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"));