]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remote: relocate valid_remote_name
authorMeet Soni <meetsoni3017@gmail.com>
Tue, 4 Feb 2025 14:28:52 +0000 (19:58 +0530)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Feb 2025 17:55:59 +0000 (09:55 -0800)
Move the `valid_remote_name()` function from the refspec subsystem to
the remote subsystem to better align with the separation of concerns.

Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refspec.c
refspec.h
remote.c
remote.h

index 6d86e04442ca2132c318616fd6ebd4b94a28e4eb..83ec7d7e621a1acee1cd3d4148e3c19476b29072 100644 (file)
--- a/refspec.c
+++ b/refspec.c
@@ -236,16 +236,6 @@ int valid_fetch_refspec(const char *fetch_refspec_str)
        return ret;
 }
 
-int valid_remote_name(const char *name)
-{
-       int result;
-       struct strbuf refspec = STRBUF_INIT;
-       strbuf_addf(&refspec, "refs/heads/test:refs/remotes/%s/test", name);
-       result = valid_fetch_refspec(refspec.buf);
-       strbuf_release(&refspec);
-       return result;
-}
-
 void refspec_ref_prefixes(const struct refspec *rs,
                          struct strvec *ref_prefixes)
 {
index 69d693c87d31a00dcaaccc40fe802f804cdbcbcb..dc428f86f2424fde426156e6fc82cc0c46edf7fc 100644 (file)
--- a/refspec.h
+++ b/refspec.h
@@ -61,7 +61,6 @@ void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
 void refspec_clear(struct refspec *rs);
 
 int valid_fetch_refspec(const char *refspec);
-int valid_remote_name(const char *name);
 
 struct strvec;
 /*
index 1779f0e7bbb8b88965f2fedf407e50ed20ea7a13..2217eb0a3fa8686da54e2594d9241e5c57e90562 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -3029,3 +3029,13 @@ char *relative_url(const char *remote_url, const char *url,
        free(out);
        return strbuf_detach(&sb, NULL);
 }
+
+int valid_remote_name(const char *name)
+{
+       int result;
+       struct strbuf refspec = STRBUF_INIT;
+       strbuf_addf(&refspec, "refs/heads/test:refs/remotes/%s/test", name);
+       result = valid_fetch_refspec(refspec.buf);
+       strbuf_release(&refspec);
+       return result;
+}
index a19353f68999f5440db7bf5f91dd4be8bcc1d8a5..e4ab03104bb8c17cdb6913371ae05b036ffa225c 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -463,4 +463,6 @@ void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);
 char *relative_url(const char *remote_url, const char *url,
                   const char *up_path);
 
+int valid_remote_name(const char *name);
+
 #endif