refs: refactor resolve_gitlink_ref() to accept a repository

In `resolve_gitlink_ref()` we implicitly rely on `the_repository` to
look up the submodule ref store. Now that we can look up submodule ref
stores for arbitrary repositories we can improve this function to
instead accept a repository as parameter for which we want to resolve
the gitlink.

Do so and adjust callers accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-05-17 10:18:39 +02:00
committed by Junio C Hamano
parent 965f8991e5
commit e19488a60a
11 changed files with 29 additions and 18 deletions

View File

@ -349,7 +349,8 @@ static int process_directory(const char *path, int len, struct stat *st)
if (S_ISGITLINK(ce->ce_mode)) {
/* Do nothing to the index if there is no HEAD! */
if (resolve_gitlink_ref(path, "HEAD", &oid) < 0)
if (repo_resolve_gitlink_ref(the_repository, path,
"HEAD", &oid) < 0)
return 0;
return add_one_path(ce, path, len, st);
@ -375,7 +376,7 @@ static int process_directory(const char *path, int len, struct stat *st)
}
/* No match - should we add it as a gitlink? */
if (!resolve_gitlink_ref(path, "HEAD", &oid))
if (!repo_resolve_gitlink_ref(the_repository, path, "HEAD", &oid))
return add_one_path(NULL, path, len, st);
/* Error out. */