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.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-04-30 05:15:43 +0400
committerRussell Belfer <rb@github.com>2013-04-30 05:15:43 +0400
commite4af0f001600cfe7d72cfb140fc7dc2d25be2c37 (patch)
treef1e9ddf44b3f7c49c8d7013fb5edc0302724447f /src/oid.h
parentd77611022c4a43d5e67cf52ce2bc2b11ee5bcdc0 (diff)
Add new src/oid.h
Diffstat (limited to 'src/oid.h')
-rw-r--r--src/oid.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/oid.h b/src/oid.h
new file mode 100644
index 000000000..077d0a4c8
--- /dev/null
+++ b/src/oid.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#ifndef INCLUDE_oid_h__
+#define INCLUDE_oid_h__
+
+#include "git2/oid.h"
+
+/*
+ * Compare two oid structures.
+ *
+ * @param a first oid structure.
+ * @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;
+}
+
+#endif