diff options
author | Vicent Martà <vicent@github.com> | 2012-08-27 13:39:17 -0700 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2012-08-27 13:39:17 -0700 |
commit | b9d283d14aac37ed6b4e83aed2c17e0e7040d677 (patch) | |
tree | 619dabdd5bbfc551ea5eb3986a09fdb7de187b2d /include/git2/refs.h | |
parent | 05752700c70322a6812309bb47a3313464b677fd (diff) | |
parent | 2e0c881670678d18b912b57dd5825fec00167aad (diff) | |
download | libgit2-b9d283d14aac37ed6b4e83aed2c17e0e7040d677.tar.gz |
Merge pull request #897 from nulltoken/topic/git_reference_check_format
refs: expose git_reference_normalize_name()
Diffstat (limited to 'include/git2/refs.h')
-rw-r--r-- | include/git2/refs.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/git2/refs.h b/include/git2/refs.h index 9e706007..6a8513b3 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -376,6 +376,54 @@ GIT_EXTERN(int) git_reference_has_log(git_reference *ref); */ GIT_EXTERN(int) git_reference_is_branch(git_reference *ref); +enum { + GIT_REF_FORMAT_NORMAL = 0, + + /** + * Control whether one-level refnames are accepted + * (i.e., refnames that do not contain multiple /-separated + * components) + */ + GIT_REF_FORMAT_ALLOW_ONELEVEL = (1 << 0), + + /** + * Interpret the provided name as a reference pattern for a + * refspec (as used with remote repositories). If this option + * is enabled, the name is allowed to contain a single * (<star>) + * in place of a one full pathname component + * (e.g., foo/<star>/bar but not foo/bar<star>). + */ + GIT_REF_FORMAT_REFSPEC_PATTERN = (1 << 1), +}; + +/** + * Normalize the reference name by removing any leading + * slash (/) characters and collapsing runs of adjacent slashes + * between name components into a single slash. + * + * Once normalized, if the reference name is valid, it will be + * returned in the user allocated buffer. + * + * TODO: Implement handling of GIT_REF_FORMAT_REFSPEC_PATTERN + * + * @param buffer_out The user allocated buffer where the + * normalized name will be stored. + * + * @param buffer_size buffer_out size + * + * @param name name to be checked. + * + * @param flags Flags to determine the options to be applied while + * checking the validatity of the name. + * + * @return 0 or an error code. + */ +GIT_EXTERN(int) git_reference_normalize_name( + char *buffer_out, + size_t buffer_size, + const char *name, + unsigned int flags); + /** @} */ GIT_END_DECL #endif |