Commit 0b068214a5a28afb949776097a1b6f9da65dffd2

Edward Thomson 2021-12-11T15:34:27

oid: add functions to inspect oid information Provide helper functions to provide information about the object id size given its type.

diff --git a/src/libgit2/oid.h b/src/libgit2/oid.h
index b61a17f..9548ba2 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.
  *