]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/stack: provide fsync(3p) via system header
authorPatrick Steinhardt <ps@pks.im>
Thu, 2 Apr 2026 07:31:15 +0000 (09:31 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Apr 2026 17:45:43 +0000 (10:45 -0700)
commitb45ea595e6f6b03a749abc2c8e508504429a4cf3
tree0d1402643c17e23d27e7d17334505f32de33e037
parent34c17b840d5bdb8060ef6309aee04f919616c9de
reftable/stack: provide fsync(3p) via system header

Users of the reftable library are expected to provide their own function
callback in cases they want to sync(3p) data to disk via the reftable
write options. But if no such function was provided we end up calling
fsync(3p) directly, which may not even be available on some systems.

While dropping the explicit call to fsync(3p) would work, it would lead
to an unsafe default behaviour where a project may have forgotten to set
up the callback function, and that could lead to potential data loss. So
this is not a great solution.

Instead, drop the callback function and make it mandatory for the
project to define fsync(3p). In the case of Git, we can then easily
inject our custom implementation via the "reftable-system.h" header so
that we continue to use `fsync_component()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/reftable-backend.c
reftable/reftable-system.h
reftable/reftable-writer.h
reftable/stack.c
reftable/system.c