Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/oid.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-10-12 16:06:23 +0400
committernulltoken <emeric.fermas@gmail.com>2011-10-14 01:15:11 +0400
commit34aff0100248dbf349240fd8edff4cc440062b40 (patch)
tree7b65cac1a879ebd021d39564a15ee23bb3f29bf8 /src/oid.c
parenta6c0e4d2028966c73525de020d4e500f272dfadf (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.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/oid.c b/src/oid.c
index b47fa2c77..bbf19ea20 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -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 {