]> git.proxmox.com Git - libgit2.git/blame - src/oid.h
sha1_lookup: Hello my name is MSVC and how do I pointer
[libgit2.git] / src / oid.h
CommitLineData
e4af0f00
RB
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/*
13 * Compare two oid structures.
14 *
15 * @param a first oid structure.
16 * @param b second oid structure.
17 * @return <0, 0, >0 if a < b, a == b, a > b.
18 */
19GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b)
20{
21 const unsigned char *sha1 = a->id;
22 const unsigned char *sha2 = b->id;
23 int i;
24
25 for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) {
26 if (*sha1 != *sha2)
27 return *sha1 - *sha2;
28 }
29
30 return 0;
31}
32
33#endif