From: Matheus Afonso Martins Moreira Date: Sat, 2 May 2026 05:28:36 +0000 (+0000) Subject: url: move url_is_local_not_ssh to url.h X-Git-Tag: v2.55.0-rc0~73^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51fcf73014f542f074a253add5867c24c82c854f;p=thirdparty%2Fgit.git url: move url_is_local_not_ssh to url.h Move url_is_local_not_ssh from connect.c/connect.h to url.c/url.h so that the new url_parse function in urlmatch.c, and any future code that needs to distinguish a local path from an scp style SSH URL, can reuse the heuristic without depending on connect.c. No behavior change. Signed-off-by: Matheus Afonso Martins Moreira Signed-off-by: Junio C Hamano --- diff --git a/connect.c b/connect.c index 46da89905e..cb145de30e 100644 --- a/connect.c +++ b/connect.c @@ -707,14 +707,6 @@ enum url_scheme { URL_SCHEME_GIT }; -int url_is_local_not_ssh(const char *url) -{ - const char *colon = strchr(url, ':'); - const char *slash = strchr(url, '/'); - return !colon || (slash && slash < colon) || - (has_dos_drive_prefix(url) && is_valid_path(url)); -} - static const char *url_scheme_name(enum url_scheme scheme) { switch (scheme) { diff --git a/connect.h b/connect.h index 1645126c17..8d84f6656b 100644 --- a/connect.h +++ b/connect.h @@ -13,7 +13,6 @@ int git_connection_is_socket(struct child_process *conn); int server_supports(const char *feature); int parse_feature_request(const char *features, const char *feature); const char *server_feature_value(const char *feature, size_t *len_ret); -int url_is_local_not_ssh(const char *url); struct packet_reader; enum protocol_version discover_version(struct packet_reader *reader); diff --git a/remote.c b/remote.c index a664cd166a..24a8118d25 100644 --- a/remote.c +++ b/remote.c @@ -8,6 +8,7 @@ #include "gettext.h" #include "hex.h" #include "remote.h" +#include "url.h" #include "urlmatch.h" #include "refs.h" #include "refspec.h" diff --git a/url.c b/url.c index 3ca5987e90..057576042a 100644 --- a/url.c +++ b/url.c @@ -132,3 +132,11 @@ void str_end_url_with_slash(const char *url, char **dest) free(*dest); *dest = strbuf_detach(&buf, NULL); } + +int url_is_local_not_ssh(const char *url) +{ + const char *colon = strchr(url, ':'); + const char *slash = strchr(url, '/'); + return !colon || (slash && slash < colon) || + (has_dos_drive_prefix(url) && is_valid_path(url)); +} diff --git a/url.h b/url.h index cd9140e994..39d621312f 100644 --- a/url.h +++ b/url.h @@ -21,6 +21,8 @@ char *url_decode_parameter_value(const char **query); void end_url_with_slash(struct strbuf *buf, const char *url); void str_end_url_with_slash(const char *url, char **dest); +int url_is_local_not_ssh(const char *url); + /* * The set of unreserved characters as per STD66 (RFC3986) is * '[A-Za-z0-9-._~]'. These characters are safe to appear in URI