]> git.ipfire.org Git - thirdparty/git.git/commitdiff
url: move url_is_local_not_ssh to url.h
authorMatheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Sat, 2 May 2026 05:28:36 +0000 (05:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 May 2026 00:48:26 +0000 (09:48 +0900)
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>
connect.c
connect.h
remote.c
url.c
url.h

index 46da89905ee7c655656a7b5a64a20a3d4449cb73..cb145de30e502cf8f1aabfbfe4ca77225c5652ca 100644 (file)
--- 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) {
index 1645126c17f889659d84174210a43939ef67507f..8d84f6656b1a2a3bd492ca545654d946891ff1fd 100644 (file)
--- 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);
index a664cd166aa3b910c239645093782f7be475282f..24a8118d250c72f5eb1a8a8dab235ea3c67f543c 100644 (file)
--- 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 3ca5987e905d5943b9177a8a5b11fe374ac36373..057576042af1be4d6ee340f956a8d4357689c8f2 100644 (file)
--- 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 cd9140e9946b16d10989dbf11b4830d69fc72857..39d621312ffdcb554ded01c429b965e9e5d1d99c 100644 (file)
--- 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