summaryrefslogtreecommitdiff
path: root/include/git2/oid.h
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-04-30 04:02:52 -0700
committerVicent Martí <vicent@github.com>2013-04-30 04:02:52 -0700
commitcd2ed9f0cc9d8e0e1724304e946adb28271e0669 (patch)
treecdf9e1dade9f0d6e0317735ac2d40d81ff074c16 /include/git2/oid.h
parentd76fb20ebce03b2fd87c2472d556bf9b64894efd (diff)
parent203d5b0e6829242ea412bbef7751e3c522ac5dd8 (diff)
downloadlibgit2-cd2ed9f0cc9d8e0e1724304e946adb28271e0669.tar.gz
Merge pull request #1518 from arrbee/export-oid-comparison
Remove most inlines from the public API
Diffstat (limited to 'include/git2/oid.h')
-rw-r--r--include/git2/oid.h24
1 files changed, 11 insertions, 13 deletions
diff --git a/include/git2/oid.h b/include/git2/oid.h
index 862f4b202..b20bb221a 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -145,19 +145,7 @@ GIT_EXTERN(void) git_oid_cpy(git_oid *out, const git_oid *src);
* @param b second oid structure.
* @return <0, 0, >0 if a < b, a == b, a > b.
*/
-GIT_INLINE(int) git_oid_cmp(const git_oid *a, const git_oid *b)
-{
- const unsigned char *sha1 = a->id;
- const unsigned char *sha2 = b->id;
- int i;
-
- for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) {
- if (*sha1 != *sha2)
- return *sha1 - *sha2;
- }
-
- return 0;
-}
+GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b);
/**
* Compare two oid structures for equality
@@ -193,6 +181,16 @@ GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len);
GIT_EXTERN(int) git_oid_streq(const git_oid *id, const char *str);
/**
+ * Compare an oid to an hex formatted object id.
+ *
+ * @param id oid structure.
+ * @param str input hex string of an object id.
+ * @return -1 if str is not valid, <0 if id sorts before str,
+ * 0 if id matches str, >0 if id sorts after str.
+ */
+GIT_EXTERN(int) git_oid_strcmp(const git_oid *id, const char *str);
+
+/**
* Check is an oid is all zeros.
*
* @return 1 if all zeros, 0 otherwise.