diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2022-01-26 13:08:24 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-06-20 17:05:29 -0400 |
commit | c50b280fa5bf525c6f84c39826a28ea9360e9136 (patch) | |
tree | 786e8a8d92f2830d2fef4ed651ee350d1e906c7b /src/libgit2/oid.h | |
parent | 14798060a639924c7cd9cae3234abfe2d5327aff (diff) | |
download | libgit2-c50b280fa5bf525c6f84c39826a28ea9360e9136.tar.gz |
oid: provide an oid type to hash type map
We intentionally separate oid types from hash types; a hash is a generic
hunk of bytes, an object id has meaning and backs an object on disk. As
a result of this separation, we need a 1:1 mapping.
Diffstat (limited to 'src/libgit2/oid.h')
-rw-r--r-- | src/libgit2/oid.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libgit2/oid.h b/src/libgit2/oid.h index 0503a18fb..5b467cb4e 100644 --- a/src/libgit2/oid.h +++ b/src/libgit2/oid.h @@ -10,6 +10,7 @@ #include "common.h" #include "git2/oid.h" +#include "hash.h" #define GIT_OID_NONE { 0, { 0 } } @@ -40,6 +41,18 @@ GIT_INLINE(size_t) git_oid_hexsize(git_oid_t type) return 0; } +GIT_INLINE(git_hash_algorithm_t) git_oid_algorithm(git_oid_t type) +{ + switch (type) { + case GIT_OID_SHA1: + return GIT_HASH_ALGORITHM_SHA1; + case GIT_OID_SHA256: + return GIT_HASH_ALGORITHM_SHA256; + } + + return 0; +} + /** * Format a git_oid into a newly allocated c-string. * |