line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 "common.h" |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#include "git2/oid.h" |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
/** |
15
|
|
|
|
|
|
|
* Format a git_oid into a newly allocated c-string. |
16
|
|
|
|
|
|
|
* |
17
|
|
|
|
|
|
|
* The c-string is owned by the caller and needs to be manually freed. |
18
|
|
|
|
|
|
|
* |
19
|
|
|
|
|
|
|
* @param id the oid structure to format |
20
|
|
|
|
|
|
|
* @return the c-string; NULL if memory is exhausted. Caller must |
21
|
|
|
|
|
|
|
* deallocate the string with git__free(). |
22
|
|
|
|
|
|
|
*/ |
23
|
|
|
|
|
|
|
char *git_oid_allocfmt(const git_oid *id); |
24
|
|
|
|
|
|
|
|
25
|
124
|
|
|
|
|
|
GIT_INLINE(int) git_oid__hashcmp(const unsigned char *sha1, const unsigned char *sha2) |
26
|
|
|
|
|
|
|
{ |
27
|
124
|
|
|
|
|
|
return memcmp(sha1, sha2, GIT_OID_RAWSZ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
/* |
31
|
|
|
|
|
|
|
* Compare two oid structures. |
32
|
|
|
|
|
|
|
* |
33
|
|
|
|
|
|
|
* @param a first oid structure. |
34
|
|
|
|
|
|
|
* @param b second oid structure. |
35
|
|
|
|
|
|
|
* @return <0, 0, >0 if a < b, a == b, a > b. |
36
|
|
|
|
|
|
|
*/ |
37
|
124
|
|
|
|
|
|
GIT_INLINE(int) git_oid__cmp(const git_oid *a, const git_oid *b) |
38
|
|
|
|
|
|
|
{ |
39
|
124
|
|
|
|
|
|
return git_oid__hashcmp(a->id, b->id); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
GIT_INLINE(void) git_oid__cpy_prefix( |
43
|
|
|
|
|
|
|
git_oid *out, const git_oid *id, size_t len) |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
memcpy(&out->id, id->id, (len + 1) / 2); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
if (len & 1) |
48
|
|
|
|
|
|
|
out->id[len / 2] &= 0xF0; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#endif |