]> git.proxmox.com Git - libgit2.git/blob - src/oid.h
remote: create FETCH_HEAD with a refspecless remote
[libgit2.git] / src / oid.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_oid_h__
8 #define INCLUDE_oid_h__
9
10 #include "git2/oid.h"
11
12 GIT_INLINE(int) git_oid__hashcmp(const unsigned char *sha1, const unsigned char *sha2)
13 {
14 int i;
15
16 for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) {
17 if (*sha1 != *sha2)
18 return *sha1 - *sha2;
19 }
20
21 return 0;
22 }
23
24 /*
25 * Compare two oid structures.
26 *
27 * @param a first oid structure.
28 * @param b second oid structure.
29 * @return <0, 0, >0 if a < b, a == b, a > b.
30 */
31 GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b)
32 {
33 return git_oid__hashcmp(a->id, b->id);
34 }
35
36 #endif