From 1f73de262961510318328463f943175833994a50 Mon Sep 17 00:00:00 2001 From: Bouke van der Bijl Date: Thu, 14 Mar 2024 16:51:44 +0100 Subject: [PATCH] git fetcher: relax absolute URL check of resolveSubmoduleUrl This matches up the behavior with the internals of libgit2 Fixes #9979 --- src/libfetchers/git-utils.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libfetchers/git-utils.cc b/src/libfetchers/git-utils.cc index 5e560f5f3..5777240ad 100644 --- a/src/libfetchers/git-utils.cc +++ b/src/libfetchers/git-utils.cc @@ -313,7 +313,11 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this std::string res(buf.ptr); - if (!hasPrefix(res, "/") && res.find("://") == res.npos) + // Git has a default protocol of 'ssh' for URLs without a protocol: + // https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols#_the_ssh_protocol + // This code matches what git_submodule_resolve_url does inside of itself to see if the URL is already absolute. + // Inside libgit2 it just checks whether there's any ':' in the URL to default to the ssh:// protocol. + if (!hasPrefix(res, "/") && res.find(":") == res.npos) res = parseURL(base + "/" + res).canonicalise().to_string(); return res;