Commit 0c8efb38 by Xavier L

Added an oid function that accepts nul-terminated strings

parent 7dbf4039
......@@ -47,6 +47,16 @@ typedef struct git_oid {
GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
/**
* Parse a hex formatted null-terminated string into a git_oid.
*
* @param out oid structure the result is written into.
* @param str input hex string; must be at least 4 characters
* long and null-terminated.
* @return 0 or an error code
*/
GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str);
/**
* Parse N characters of a hex formatted object id into a git_oid
*
* If N is odd, N-1 characters will be parsed instead.
......
......@@ -51,6 +51,11 @@ int git_oid_fromstrn(git_oid *out, const char *str, size_t length)
return 0;
}
int git_oid_fromstrp(git_oid *out, const char *str)
{
return git_oid_fromstrn(out, str, min(strlen(str), GIT_OID_HEXSZ));
}
int git_oid_fromstr(git_oid *out, const char *str)
{
return git_oid_fromstrn(out, str, GIT_OID_HEXSZ);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment