aboutsummaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-11-18 16:33:57 +0100
committerJunio C Hamano <gitster@pobox.com>2024-11-19 12:23:10 +0900
commitc2f08236ed786a48e50af33ecc5c0f951c14761b (patch)
tree2bf85fa99746b31ee4b1b3fc5d53bb5ce1c5ea6b /refs
parent88e297275b94f2fbbc60b770f37654796799b907 (diff)
downloadgit-c2f08236ed786a48e50af33ecc5c0f951c14761b.tar.xz
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 'refs')
-rw-r--r--refs/reftable-backend.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index 3c6107c7ce..7d86d92097 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -15,6 +15,7 @@
#include "../object.h"
#include "../path.h"
#include "../refs.h"
+#include "../reftable/reftable-basics.h"
#include "../reftable/reftable-stack.h"
#include "../reftable/reftable-record.h"
#include "../reftable/reftable-error.h"
@@ -289,7 +290,16 @@ static struct ref_store *reftable_be_init(struct repository *repo,
refs->store_flags = store_flags;
refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
- refs->write_options.hash_id = repo->hash_algo->format_id;
+ switch (repo->hash_algo->format_id) {
+ case GIT_SHA1_FORMAT_ID:
+ refs->write_options.hash_id = REFTABLE_HASH_SHA1;
+ break;
+ case GIT_SHA256_FORMAT_ID:
+ refs->write_options.hash_id = REFTABLE_HASH_SHA256;
+ break;
+ default:
+ BUG("unknown hash algorithm %d", repo->hash_algo->format_id);
+ }
refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
refs->write_options.disable_auto_compact =
!git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);