summaryrefslogtreecommitdiff
path: root/src/oid.c
diff options
context:
space:
mode:
authorMarc Pegon <pegon.marc@gmail.com>2011-05-29 11:45:34 +0200
committerVicent Marti <tanoku@gmail.com>2011-06-01 23:40:42 +0200
commitda03c9f35b282e70f0cb7e6ae1638df476c4e0df (patch)
tree5a053b89ce5c2acf97eaca1efc4b19a64e705beb /src/oid.c
parentac2b94ad7658b53035b8518842348a083decd418 (diff)
downloadlibgit2-da03c9f35b282e70f0cb7e6ae1638df476c4e0df.tar.gz
Changed return value of git_oid_match to be consistent with the other compare methods (0 means oids match). Added method to compare prefixes of hex formatted oids.
Diffstat (limited to 'src/oid.c')
-rw-r--r--src/oid.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/oid.c b/src/oid.c
index f743da8ac..8dc6903cd 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -177,15 +177,20 @@ int git_oid_match_raw(unsigned int len, const unsigned char *a, const unsigned c
{
do {
if (*a != *b)
- return 0;
+ return 1;
a++;
b++;
len -= 2;
} while (len > 1);
if (len)
if ((*a ^ *b) & 0xf0)
- return 0;
- return 1;
+ return 1;
+ return 0;
+}
+
+int git_oid_match_hex(unsigned int len, const unsigned char *a, const unsigned char *b)
+{
+ return memcmp(a, b, len);
}
int gid_oid_match(unsigned int len, git_oid *a, git_oid *b)