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:
authorMarc Pegon <pegon.marc@gmail.com>2011-05-28 00:37:10 +0400
committerVicent Marti <tanoku@gmail.com>2011-06-02 01:40:41 +0400
commit53c0bd81a2915d6f82ef2f9c0703770783a3dc89 (patch)
treee34fd5f5cd97b9738a49588fa889c8ee6819a63a /src/oid.c
parentecd6fdf1f70b785f24e2d17bec516ac88be0cf2c (diff)
Added error for ambiguous oid prefixes. Added methods to compare the first nth hexadecimal characters (i.e. packets of 4 bits) of OIDs.
Diffstat (limited to 'src/oid.c')
-rw-r--r--src/oid.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/oid.c b/src/oid.c
index 5c5238bb1..f743da8ac 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -173,6 +173,26 @@ int git_oid_cmp(const git_oid *a, const git_oid *b)
}
+int git_oid_match_raw(unsigned int len, const unsigned char *a, const unsigned char *b)
+{
+ do {
+ if (*a != *b)
+ return 0;
+ a++;
+ b++;
+ len -= 2;
+ } while (len > 1);
+ if (len)
+ if ((*a ^ *b) & 0xf0)
+ return 0;
+ return 1;
+}
+
+int gid_oid_match(unsigned int len, git_oid *a, git_oid *b)
+{
+ return git_oid_match_raw(len, a->id, b->id);
+}
+
typedef short node_index;
typedef union {