From 0db1c57cf0cd555db456ebf854ac99aeb68b83cf Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Tue, 25 Jan 2022 10:32:47 -0500 Subject: oid: add sha256 typed oids --- include/git2/oid.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'include/git2') diff --git a/include/git2/oid.h b/include/git2/oid.h index 8feb0a358..924c680cc 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -19,18 +19,21 @@ */ GIT_BEGIN_DECL -/** The type of object id, currently only SHA1. */ +/** The type of object id. */ typedef enum { - GIT_OID_SHA1 = 1 /**< SHA1 */ + GIT_OID_SHA1 = 1, /**< SHA1 */ + GIT_OID_SHA256 = 2 /**< SHA256 */ } git_oid_t; /** Size (in bytes) of a raw/binary oid */ #define GIT_OID_SHA1_SIZE 20 -#define GIT_OID_MAX_SIZE GIT_OID_SHA1_SIZE +#define GIT_OID_SHA256_SIZE 32 +#define GIT_OID_MAX_SIZE GIT_OID_SHA256_SIZE /** Size (in bytes) of a hex formatted oid */ #define GIT_OID_SHA1_HEXSIZE (GIT_OID_SHA1_SIZE * 2) -#define GIT_OID_MAX_HEXSIZE GIT_OID_SHA1_HEXSIZE +#define GIT_OID_SHA256_HEXSIZE (GIT_OID_SHA256_SIZE * 2) +#define GIT_OID_MAX_HEXSIZE GIT_OID_SHA256_HEXSIZE /** Minimum length (in number of hex characters, * i.e. packets of 4 bits) of an oid prefix */ @@ -49,11 +52,13 @@ typedef struct git_oid { * The binary representation of the null object ID. */ #define GIT_OID_SHA1_ZERO { GIT_OID_SHA1, { 0 } } +#define GIT_OID_SHA256_ZERO { GIT_OID_SHA256, { 0 } } /** * The string representation of the null object ID. */ #define GIT_OID_SHA1_HEXZERO "0000000000000000000000000000000000000000" +#define GIT_OID_SHA256_HEXZERO "0000000000000000000000000000000000000000000000000000000000000000" /** * Parse a hex formatted object id into a git_oid. -- cgit v1.2.1