diff options
author | nulltoken <emeric.fermas@gmail.com> | 2011-10-12 16:06:23 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2011-10-14 01:15:11 +0400 |
commit | 34aff0100248dbf349240fd8edff4cc440062b40 (patch) | |
tree | 7b65cac1a879ebd021d39564a15ee23bb3f29bf8 /src/oid.c | |
parent | a6c0e4d2028966c73525de020d4e500f272dfadf (diff) |
oid: Add git_oid_streq() which checks if an oid and an hex formatted string are equal
Diffstat (limited to 'src/oid.c')
-rw-r--r-- | src/oid.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -197,6 +197,17 @@ int git_oid_ncmp(const git_oid *oid_a, const git_oid *oid_b, unsigned int len) return 0; } +int git_oid_streq(const git_oid *a, const char *str) +{ + git_oid id; + int error; + + if ((error = git_oid_fromstr(&id, str)) < GIT_SUCCESS) + return git__rethrow(error, "Failed to convert '%s' to oid.", str); + + return git_oid_cmp(a, &id) == 0 ? GIT_SUCCESS : GIT_ERROR; +} + typedef short node_index; typedef union { |