aboutsummaryrefslogtreecommitdiffstats
path: root/worktree.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-17 10:18:44 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-17 10:33:38 -0700
commitdc7fb4f72c2e39ffbb98aee55ad7ea4c3f8e12fc (patch)
treeac6fe8d4aaff5edae0cf79545f9cdce1be9e8590 /worktree.c
parentrefs: refactor `resolve_gitlink_ref()` to accept a repository (diff)
downloadgit-dc7fb4f72c2e39ffbb98aee55ad7ea4c3f8e12fc.tar.gz
git-dc7fb4f72c2e39ffbb98aee55ad7ea4c3f8e12fc.zip
refs: retrieve worktree ref stores via associated repository
Similar as with the preceding commit, the worktree ref stores are always looked up via `the_repository`. Also, again, those ref stores are stored in a global map. Refactor the code so that worktrees have a pointer to their repository. Like this, we can move the global map into `struct repository` and stop using `the_repository`. With this change, we can now in theory look up worktree ref stores for repositories other than `the_repository`. In practice, the worktree code will need further changes to look up arbitrary worktrees. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.c')
-rw-r--r--worktree.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/worktree.c b/worktree.c
index cf5eea8c93..12eadacc61 100644
--- a/worktree.c
+++ b/worktree.c
@@ -65,6 +65,7 @@ static struct worktree *get_main_worktree(int skip_reading_head)
strbuf_strip_suffix(&worktree_path, "/.git");
CALLOC_ARRAY(worktree, 1);
+ worktree->repo = the_repository;
worktree->path = strbuf_detach(&worktree_path, NULL);
/*
* NEEDSWORK: If this function is called from a secondary worktree and
@@ -98,6 +99,7 @@ struct worktree *get_linked_worktree(const char *id,
strbuf_strip_suffix(&worktree_path, "/.git");
CALLOC_ARRAY(worktree, 1);
+ worktree->repo = the_repository;
worktree->path = strbuf_detach(&worktree_path, NULL);
worktree->id = xstrdup(id);
if (!skip_reading_head)