submodule: refactor submodule_to_gitdir() to accept a repo

The `submodule_to_gitdir()` function implicitly uses `the_repository` to
resolve submodule paths. Refactor the function to instead accept a repo
as parameter to remove the dependency on global state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-02-07 12:03:29 +01:00
committed by Junio C Hamano
parent 93a8cfaf3c
commit f9467895d8
5 changed files with 11 additions and 9 deletions

2
path.c
View File

@@ -567,7 +567,7 @@ static int do_submodule_path(struct strbuf *buf, const char *path,
struct strbuf git_submodule_dir = STRBUF_INIT;
int ret;
ret = submodule_to_gitdir(&git_submodule_dir, path);
ret = submodule_to_gitdir(the_repository, &git_submodule_dir, path);
if (ret)
goto cleanup;