]> git.ipfire.org Git - thirdparty/git.git/blobdiff - refspec.c
refs: consolidate remote name validation
[thirdparty/git.git] / refspec.c
index f10ef284cef95aef60b8b485f5909ba9a8c76b50..98d1caaa0a9b37793e6ddf76959b448d7774d8ca 100644 (file)
--- a/refspec.c
+++ b/refspec.c
@@ -201,6 +201,16 @@ 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)
 {