Expose got_ref_name_is_valid() for general purpose use. This will be needed for a future 'got send' command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/include/got_reference.h b/include/got_reference.h
index 57e9e86..927c10b 100644
--- a/include/got_reference.h
+++ b/include/got_reference.h
@@ -26,6 +26,9 @@ struct got_reference;
struct got_repository;
struct got_object_id;
+/* Determine whether a given reference name is valid. */
+int got_ref_name_is_valid(const char *);
+
/*
* Attempt to open the reference with the provided name in a repository.
* The caller must dispose of the reference with got_ref_close().
diff --git a/lib/reference.c b/lib/reference.c
index 951594f..6f10967 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -265,8 +265,8 @@ get_refs_dir_path(struct got_repository *repo, const char *refname)
return got_repo_get_path_refs(repo);
}
-static int
-is_valid_ref_name(const char *name)
+int
+got_ref_name_is_valid(const char *name)
{
const char *s, *seg;
const char forbidden[] = { ' ', '~', '^', ':', '?', '*', '[' , '\\' };
@@ -320,7 +320,7 @@ const struct got_error *
got_ref_alloc(struct got_reference **ref, const char *name,
struct got_object_id *id)
{
- if (!is_valid_ref_name(name))
+ if (!got_ref_name_is_valid(name))
return got_error_path(name, GOT_ERR_BAD_REF_NAME);
return alloc_ref(ref, name, id, 0, 0);
@@ -330,7 +330,7 @@ const struct got_error *
got_ref_alloc_symref(struct got_reference **ref, const char *name,
struct got_reference *target_ref)
{
- if (!is_valid_ref_name(name))
+ if (!got_ref_name_is_valid(name))
return got_error_path(name, GOT_ERR_BAD_REF_NAME);
return alloc_symref(ref, name, got_ref_get_name(target_ref), 0);
@@ -418,7 +418,7 @@ open_ref(struct got_reference **ref, const char *path_refs, const char *subdir,
*ref = NULL;
- if (!is_valid_ref_name(name))
+ if (!got_ref_name_is_valid(name))
return got_error_path(name, GOT_ERR_BAD_REF_NAME);
if (ref_is_absolute || ref_is_well_known) {