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 <matheus@matheusmoreira.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matheus Afonso Martins Moreira committed May 2, 2026 at 05:28 UTC 51fcf73014f542f074a253add5867c24c82c854f
5 files changed +11 -9
connect.c
-8
@@ -707,14 +707,6 @@ enum url_scheme {
707 URL_SCHEME_GIT
708 };
709
710 -int url_is_local_not_ssh(const char *url)
711 -{
712 - const char *colon = strchr(url, ':');
713 - const char *slash = strchr(url, '/');
714 - return !colon || (slash && slash < colon) ||
715 - (has_dos_drive_prefix(url) && is_valid_path(url));
716 -}
717 -
710 static const char *url_scheme_name(enum url_scheme scheme)
711 {
712 switch (scheme) {
connect.h
-1
@@ -13,7 +13,6 @@ int git_connection_is_socket(struct child_process *conn);
13 int server_supports(const char *feature);
14 int parse_feature_request(const char *features, const char *feature);
15 const char *server_feature_value(const char *feature, size_t *len_ret);
16 -int url_is_local_not_ssh(const char *url);
16
17 struct packet_reader;
18 enum protocol_version discover_version(struct packet_reader *reader);
remote.c
+1
@@ -8,6 +8,7 @@
8 #include "gettext.h"
9 #include "hex.h"
10 #include "remote.h"
11 +#include "url.h"
12 #include "urlmatch.h"
13 #include "refs.h"
14 #include "refspec.h"
url.c
+8
@@ -132,3 +132,11 @@ void str_end_url_with_slash(const char *url, char **dest)
132 free(*dest);
133 *dest = strbuf_detach(&buf, NULL);
134 }
135 +
136 +int url_is_local_not_ssh(const char *url)
137 +{
138 + const char *colon = strchr(url, ':');
139 + const char *slash = strchr(url, '/');
140 + return !colon || (slash && slash < colon) ||
141 + (has_dos_drive_prefix(url) && is_valid_path(url));
142 +}
url.h
+2
@@ -21,6 +21,8 @@ char *url_decode_parameter_value(const char **query);
21 void end_url_with_slash(struct strbuf *buf, const char *url);
22 void str_end_url_with_slash(const char *url, char **dest);
23
24 +int url_is_local_not_ssh(const char *url);
25 +
26 /*
27 * The set of unreserved characters as per STD66 (RFC3986) is
28 * '[A-Za-z0-9-._~]'. These characters are safe to appear in URI