aboutsummaryrefslogtreecommitdiffstats
path: root/refs
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-11-18 16:34:00 +0100
committerJunio C Hamano <gitster@pobox.com>2024-11-19 12:23:10 +0900
commit86b770b0bbf1aba3c8e43401936258c58648703a (patch)
tree97ca3a09de568434e512931d018d332d7ae61489 /refs
parentreftable/system: stop depending on "hash.h" (diff)
downloadgit-86b770b0bbf1aba3c8e43401936258c58648703a.tar.gz
git-86b770b0bbf1aba3c8e43401936258c58648703a.zip
reftable/stack: stop using `fsync_component()` directly
We're executing `fsync_component()` directly in the reftable library so that we can fsync data to disk depending on "core.fsync". But as we're in the process of converting the reftable library to become standalone we cannot use that function in the library anymore. Refactor the code such that users of the library can inject a custom fsync function via the write options. This allows us to get rid of the dependency on "write-or-die.h". 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.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index 7d86d92097..2e774176ed 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -24,6 +24,7 @@
#include "../setup.h"
#include "../strmap.h"
#include "../trace2.h"
+#include "../write-or-die.h"
#include "parse.h"
#include "refs-internal.h"
@@ -273,6 +274,11 @@ static int reftable_be_config(const char *var, const char *value,
return 0;
}
+static int reftable_be_fsync(int fd)
+{
+ return fsync_component(FSYNC_COMPONENT_REFERENCE, fd);
+}
+
static struct ref_store *reftable_be_init(struct repository *repo,
const char *gitdir,
unsigned int store_flags)
@@ -304,6 +310,7 @@ static struct ref_store *reftable_be_init(struct repository *repo,
refs->write_options.disable_auto_compact =
!git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
refs->write_options.lock_timeout_ms = 100;
+ refs->write_options.fsync = reftable_be_fsync;
git_config(reftable_be_config, &refs->write_options);