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/reftable-basics.h | |
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/reftable-basics.h')
-rw-r--r-- | reftable/reftable-basics.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/reftable/reftable-basics.h b/reftable/reftable-basics.h index 6e8e636b71..e0397ed583 100644 --- a/reftable/reftable-basics.h +++ b/reftable/reftable-basics.h @@ -11,6 +11,19 @@ #include <stddef.h> +/* + * Hash functions understood by the reftable library. Note that the values are + * arbitrary and somewhat random such that we can easily detect cases where the + * hash hasn't been properly set up. + */ +enum reftable_hash { + REFTABLE_HASH_SHA1 = 89, + REFTABLE_HASH_SHA256 = 247, +}; +#define REFTABLE_HASH_SIZE_SHA1 20 +#define REFTABLE_HASH_SIZE_SHA256 32 +#define REFTABLE_HASH_SIZE_MAX REFTABLE_HASH_SIZE_SHA256 + /* Overrides the functions to use for memory management. */ void reftable_set_alloc(void *(*malloc)(size_t), void *(*realloc)(void *, size_t), void (*free)(void *)); |