aboutsummaryrefslogtreecommitdiffstats
path: root/builtin
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-08-13 11:13:37 +0200
committerJunio C Hamano <gitster@pobox.com>2024-08-13 10:01:01 -0700
commita973f60dc7c178828e351ec4e68886ffecfbcadc (patch)
tree1dc78a861d10f3df03ffee3ea0210be5985fd36d /builtin
parentpath: stop relying on `the_repository` when reporting garbage (diff)
downloadgit-a973f60dc7c178828e351ec4e68886ffecfbcadc.tar.gz
git-a973f60dc7c178828e351ec4e68886ffecfbcadc.zip
path: stop relying on `the_repository` in `worktree_git_path()`
When not provided a worktree, then `worktree_git_path()` will fall back to returning a path relative to the main repository. In this case, we implicitly rely on `the_repository` to derive the path. Remove this dependency by passing a `struct repository` as parameter. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fsck.c2
-rw-r--r--builtin/worktree.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index d13a226c2e..ad36df9628 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -1050,7 +1050,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
* and may get overwritten by other calls
* while we're examining the index.
*/
- path = xstrdup(worktree_git_path(wt, "index"));
+ path = xstrdup(worktree_git_path(the_repository, wt, "index"));
read_index_from(&istate, path, get_worktree_git_dir(wt));
fsck_index(&istate, path, wt->is_current);
discard_index(&istate);
diff --git a/builtin/worktree.c b/builtin/worktree.c
index a4b7f24e1e..eb0a386992 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -1146,14 +1146,14 @@ static void validate_no_submodules(const struct worktree *wt)
struct strbuf path = STRBUF_INIT;
int i, found_submodules = 0;
- if (is_directory(worktree_git_path(wt, "modules"))) {
+ if (is_directory(worktree_git_path(the_repository, wt, "modules"))) {
/*
* There could be false positives, e.g. the "modules"
* directory exists but is empty. But it's a rare case and
* this simpler check is probably good enough for now.
*/
found_submodules = 1;
- } else if (read_index_from(&istate, worktree_git_path(wt, "index"),
+ } else if (read_index_from(&istate, worktree_git_path(the_repository, wt, "index"),
get_worktree_git_dir(wt)) > 0) {
for (i = 0; i < istate.cache_nr; i++) {
struct cache_entry *ce = istate.cache[i];