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>
Meet Soni committed
Feb 4, 2025 at 19:58 UTC
f21ea69d945f958704f2fe143c2638ecae6e0d12
4 files changed
+12
-11
refspec.c
-10
@@ -236,16 +236,6 @@ int valid_fetch_refspec(const char *fetch_refspec_str)
236
return ret;
237
}
238
239
-int valid_remote_name(const char *name)
240
-{
241
- int result;
242
- struct strbuf refspec = STRBUF_INIT;
243
- strbuf_addf(&refspec, "refs/heads/test:refs/remotes/%s/test", name);
244
- result = valid_fetch_refspec(refspec.buf);
245
- strbuf_release(&refspec);
246
- return result;
247
-}
248
-
239
void refspec_ref_prefixes(const struct refspec *rs,
240
struct strvec *ref_prefixes)
241
{
refspec.h
-1
@@ -61,7 +61,6 @@ void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
61
void refspec_clear(struct refspec *rs);
62
63
int valid_fetch_refspec(const char *refspec);
64
-int valid_remote_name(const char *name);
64
65
struct strvec;
66
/*
remote.c
+10
@@ -3029,3 +3029,13 @@ char *relative_url(const char *remote_url, const char *url,
3029
free(out);
3030
return strbuf_detach(&sb, NULL);
3031
}
3032
+
3033
+int valid_remote_name(const char *name)
3034
+{
3035
+ int result;
3036
+ struct strbuf refspec = STRBUF_INIT;
3037
+ strbuf_addf(&refspec, "refs/heads/test:refs/remotes/%s/test", name);
3038
+ result = valid_fetch_refspec(refspec.buf);
3039
+ strbuf_release(&refspec);
3040
+ return result;
3041
+}
remote.h
+2
@@ -463,4 +463,6 @@ void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);
463
char *relative_url(const char *remote_url, const char *url,
464
const char *up_path);
465
466
+int valid_remote_name(const char *name);
467
+
468
#endif