diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/oid.c | 11 | ||||
-rw-r--r-- | src/oid.h | 12 |
2 files changed, 19 insertions, 4 deletions
@@ -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) @@ -1,7 +1,17 @@ #ifndef INCLUDE_oid_h__ #define INCLUDE_oid_h__ -/* This can be useful for internal use */ +/** + * Compare the first ('len'*4) bits of two raw formatted oids. + * This can be useful for internal use. + * Return 0 if they match. + */ int git_oid_match_raw(unsigned int len, const unsigned char *a, const unsigned char *b); +/** + * Compare the first 'len' characters of two hex formatted oids. + * Return 0 if they match. + */ +int git_oid_match_hex(unsigned int len, const unsigned char *a, const unsigned char *b); + #endif |