diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2021-12-11 15:34:27 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-06-14 22:29:57 -0400 |
commit | 0b068214a5a28afb949776097a1b6f9da65dffd2 (patch) | |
tree | 6ab75ef85cdec3b7ac5d306fa06a593de18fbea7 | |
parent | 74ffce20780783e20668f7ac9d543cfc3e03fe0c (diff) | |
download | libgit2-0b068214a5a28afb949776097a1b6f9da65dffd2.tar.gz |
oid: add functions to inspect oid information
Provide helper functions to provide information about the object id size
given its type.
-rw-r--r-- | src/libgit2/oid.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libgit2/oid.h b/src/libgit2/oid.h index b61a17f56..9548ba2ab 100644 --- a/src/libgit2/oid.h +++ b/src/libgit2/oid.h @@ -14,6 +14,26 @@ extern const git_oid git_oid__empty_blob_sha1; extern const git_oid git_oid__empty_tree_sha1; +GIT_INLINE(size_t) git_oid_size(git_oid_t type) +{ + switch (type) { + case GIT_OID_SHA1: + return GIT_OID_SHA1_SIZE; + } + + return 0; +} + +GIT_INLINE(size_t) git_oid_hexsize(git_oid_t type) +{ + switch (type) { + case GIT_OID_SHA1: + return GIT_OID_SHA1_HEXSIZE; + } + + return 0; +} + /** * Format a git_oid into a newly allocated c-string. * |