setup: stop using the_repository in set_git_work_tree()

Stop using `the_repository` in `set_git_work_tree()` and instead accept
the repository as a parameter. The injection of `the_repository` is thus
bumped one level higher, where callers now pass it in explicitly.

Similar as with the preceding commit, we track whether the worktree has
been initialized already via a global variable so that we can die in
case the repository is re-initialized with a different worktree path.
Store this info in the `struct repository` instead so that we correctly
handle this per repository.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2026-05-19 11:52:14 +02:00
committed by Junio C Hamano
parent bd2851d84f
commit 7a6a82fba0
5 changed files with 17 additions and 18 deletions

View File

@@ -96,7 +96,7 @@ static inline int discover_git_directory(struct strbuf *commondir,
return 0;
}
void set_git_work_tree(const char *tree);
void set_git_work_tree(struct repository *repo, const char *tree);
/* Flags that can be passed to `enter_repo()`. */
enum {