diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2020-10-11 12:50:52 +0100 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2020-10-25 16:33:27 +0000 |
| commit | 29715d4082ef97d54ce2bf24943425f558335796 (patch) | |
| tree | 6219598466a730df1cc2af8003577beac3e1a12f /include | |
| parent | d70979cf891279e20a00bb04ece2f0ce129dd7e4 (diff) | |
| download | libgit2-29715d4082ef97d54ce2bf24943425f558335796.tar.gz | |
refs: introduce git_reference_name_is_valid
Provide a function that can check reference name validity but can also
signal when an error occurs. Use the name "name_is_valid", which is
more suggestive of checking a given name, rather than "is_valid_name",
which suggests that the function checks the validity of the current
reference's name.
Diffstat (limited to 'include')
| -rw-r--r-- | include/git2/refs.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/git2/refs.h b/include/git2/refs.h index c9cce2212..6145811bb 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -743,6 +743,23 @@ GIT_EXTERN(int) git_reference_peel( * the characters '~', '^', ':', '\\', '?', '[', and '*', and the * sequences ".." and "@{" which have special meaning to revparse. * + * @param valid output pointer to set with validity of given reference name + * @param refname name to be checked. + * @return 0 on success or an error code + */ +GIT_EXTERN(int) git_reference_name_is_valid(int *valid, const char *refname); + +/** + * Ensure the reference name is well-formed. + * + * Valid reference names must follow one of two patterns: + * + * 1. Top-level names must contain only capital letters and underscores, + * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). + * 2. Names prefixed with "refs/" can be almost anything. You must avoid + * the characters '~', '^', ':', '\\', '?', '[', and '*', and the + * sequences ".." and "@{" which have special meaning to revparse. + * * @param refname name to be checked. * @return 1 if the reference name is acceptable; 0 if it isn't */ |
