hash.h: provide constants for the hash IDs
This will simplify referencing them from code that is not deeply integrated with Git, in particular, the reftable library. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Han-Wen Nienhuys committed
Aug 30, 2021 at 14:57 UTC
27f3796ac1f9b711fae506f63186034ed178690c
2 files changed
+8
-5
hash.h
+6
@@ -95,12 +95,18 @@ static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *s
95
/* Number of algorithms supported (including unknown). */
96
#define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
97
98
+/* "sha1", big-endian */
99
+#define GIT_SHA1_FORMAT_ID 0x73686131
100
+
101
/* The length in bytes and in hex digits of an object name (SHA-1 value). */
102
#define GIT_SHA1_RAWSZ 20
103
#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
104
/* The block size of SHA-1. */
105
#define GIT_SHA1_BLKSZ 64
106
107
+/* "s256", big-endian */
108
+#define GIT_SHA256_FORMAT_ID 0x73323536
109
+
110
/* The length in bytes and in hex digits of an object name (SHA-256 value). */
111
#define GIT_SHA256_RAWSZ 32
112
#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
object-file.c
+2
-5
@@ -164,7 +164,6 @@ static void git_hash_unknown_final_oid(struct object_id *oid, git_hash_ctx *ctx)
164
BUG("trying to finalize unknown hash");
165
}
166
167
-
167
const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
168
{
169
NULL,
@@ -183,8 +182,7 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
182
},
183
{
184
"sha1",
186
- /* "sha1", big-endian */
187
- 0x73686131,
185
+ GIT_SHA1_FORMAT_ID,
186
GIT_SHA1_RAWSZ,
187
GIT_SHA1_HEXSZ,
188
GIT_SHA1_BLKSZ,
@@ -199,8 +197,7 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
197
},
198
{
199
"sha256",
202
- /* "s256", big-endian */
203
- 0x73323536,
200
+ GIT_SHA256_FORMAT_ID,
201
GIT_SHA256_RAWSZ,
202
GIT_SHA256_HEXSZ,
203
GIT_SHA256_BLKSZ,