aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMeet Soni <meetsoni3017@gmail.com>2025-02-04 19:58:52 +0530
committerJunio C Hamano <gitster@pobox.com>2025-02-04 09:55:59 -0800
commitf21ea69d945f958704f2fe143c2638ecae6e0d12 (patch)
tree0a39bf5dd912a03b9716262f744ae7c1e1f4a3af
parentbc204b742735ae06f65bb20291c95985c9633b7f (diff)
downloadgit-f21ea69d945f958704f2fe143c2638ecae6e0d12.tar.gz
remote: relocate valid_remote_name
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>
-rw-r--r--refspec.c10
-rw-r--r--refspec.h1
-rw-r--r--remote.c10
-rw-r--r--remote.h2
4 files changed, 12 insertions, 11 deletions
diff --git a/refspec.c b/refspec.c
index 6d86e04442..83ec7d7e62 100644
--- 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)
{
diff --git a/refspec.h b/refspec.h
index 69d693c87d..dc428f86f2 100644
--- 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;
/*
diff --git a/remote.c b/remote.c
index 1779f0e7bb..2217eb0a3f 100644
--- 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;
+}
diff --git a/remote.h b/remote.h
index a19353f689..e4ab03104b 100644
--- 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