diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-11-18 16:33:57 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-11-19 04:23:10 +0100 |
commit | c2f08236ed786a48e50af33ecc5c0f951c14761b (patch) | |
tree | 2bf85fa99746b31ee4b1b3fc5d53bb5ce1c5ea6b /reftable/basics.c | |
parent | reftable: explicitly handle hash format IDs (diff) | |
download | git-c2f08236ed786a48e50af33ecc5c0f951c14761b.tar.xz git-c2f08236ed786a48e50af33ecc5c0f951c14761b.zip |
reftable/system: stop depending on "hash.h"
We include "hash.h" in "reftable/system.h" such that we can use hash
format IDs as well as the raw size of SHA1 and SHA256. As we are in the
process of converting the reftable library to become standalone we of
course cannot rely on those constants anymore.
Introduce a new `enum reftable_hash` to replace internal uses of the
hash format IDs and new constants that replace internal uses of the hash
size. Adapt the reftable backend to set up the correct hash function.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/basics.c')
-rw-r--r-- | reftable/basics.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/reftable/basics.c b/reftable/basics.c index bc4fcc9144..7d84a5d62d 100644 --- a/reftable/basics.c +++ b/reftable/basics.c @@ -271,14 +271,15 @@ int common_prefix_size(struct reftable_buf *a, struct reftable_buf *b) return p; } -int hash_size(uint32_t id) +int hash_size(enum reftable_hash id) { + if (!id) + return REFTABLE_HASH_SIZE_SHA1; switch (id) { - case 0: - case GIT_SHA1_FORMAT_ID: - return GIT_SHA1_RAWSZ; - case GIT_SHA256_FORMAT_ID: - return GIT_SHA256_RAWSZ; + case REFTABLE_HASH_SHA1: + return REFTABLE_HASH_SIZE_SHA1; + case REFTABLE_HASH_SHA256: + return REFTABLE_HASH_SIZE_SHA256; } abort(); } |