diff options
| author | Xavier L <xavier.l@afrosoft.tk> | 2013-03-21 11:59:01 -0400 |
|---|---|---|
| committer | Xavier L <xavier.l@afrosoft.tk> | 2013-03-21 11:59:01 -0400 |
| commit | 0c8efb38f9ffb1c4fffe620174669c51866eff79 (patch) | |
| tree | 64e65c6e0afe0af8fbc465e2747f07b59adedc6a | |
| parent | 7dbf4039ae0881407fc9ead24c09c1d7cfd4103a (diff) | |
| download | libgit2-0c8efb38f9ffb1c4fffe620174669c51866eff79.tar.gz | |
Added an oid function that accepts nul-terminated strings
| -rw-r--r-- | include/git2/oid.h | 10 | ||||
| -rw-r--r-- | src/oid.c | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/git2/oid.h b/include/git2/oid.h index 6be02da6e..d2f3f4a14 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -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); |
