refspec: Add func to distinguish negative refspecs

Negative refspecs were added in Git v2.29.0 and are denoted by prefixing
a refspec with a caret. This adds a way to distinguish if a refspec is
negative and match negative refspecs.
This commit is contained in:
Ryan Pham
2024-11-28 13:35:11 +09:00
parent 3251d1bb62
commit 3d9f4061ca
3 changed files with 33 additions and 0 deletions

View File

@@ -78,6 +78,15 @@ GIT_EXTERN(int) git_refspec_force(const git_refspec *refspec);
*/
GIT_EXTERN(git_direction) git_refspec_direction(const git_refspec *spec);
/**
* Check if a refspec's source descriptor matches a negative reference
*
* @param refspec the refspec
* @param refname the name of the reference to check
* @return 1 if the refspec matches, 0 otherwise
*/
GIT_EXTERN(int) git_refspec_src_matches_negative(const git_refspec *refspec, const char *refname);
/**
* Check if a refspec's source descriptor matches a reference
*