Skip to content

Commit 0b06821

Browse files
committed
oid: add functions to inspect oid information
Provide helper functions to provide information about the object id size given its type.
1 parent 74ffce2 commit 0b06821

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/libgit2/oid.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@
1414
extern const git_oid git_oid__empty_blob_sha1;
1515
extern const git_oid git_oid__empty_tree_sha1;
1616

17+
GIT_INLINE(size_t) git_oid_size(git_oid_t type)
18+
{
19+
switch (type) {
20+
case GIT_OID_SHA1:
21+
return GIT_OID_SHA1_SIZE;
22+
}
23+
24+
return 0;
25+
}
26+
27+
GIT_INLINE(size_t) git_oid_hexsize(git_oid_t type)
28+
{
29+
switch (type) {
30+
case GIT_OID_SHA1:
31+
return GIT_OID_SHA1_HEXSIZE;
32+
}
33+
34+
return 0;
35+
}
36+
1737
/**
1838
* Format a git_oid into a newly allocated c-string.
1939
*

0 commit comments

Comments
 (0)