Skip to main content

Module fsync

Module fsync 

Source
Expand description

Repository durability policy: core.fsync component selection and core.fsyncMethod barrier choice.

Promoted from sley-refs so every writer resolves one shared policy instead of hand-rolling barrier decisions. Mirrors upstream git 2.55:

  • component bit layout and aggregate groups (write-or-die.h),
  • the core.fsync grammar with negation accumulation order and prefix matching (environment.c parse_fsync_components),
  • method selection including the platform default (FSYNC_METHOD_DEFAULT; sley keeps the Windows batch mapping used by its reference store), and
  • the GIT_TEST_FSYNC kill switch (write-or-die.c maybe_fsync, default enabled).

Token handling follows the established sley grammar (sley-refs core_fsync_includes_reference): comma-separated components are trimmed, so unlike upstream’s raw strspn/strncmp scan a trailing space inside a token still matches. Unknown components are ignored.

Structs§

FsyncComponents
The set of repository parts to harden through an FsyncMethod barrier, mirroring upstream enum fsync_component (git 2.55 write-or-die.h).
Policy
Resolved durability policy for repository writes.

Enums§

FsyncMethod
Barrier implementation backing core.fsyncMethod, mirroring upstream enum fsync_method.

Traits§

FsyncConfigSource
Minimal read-only config lookup surface accepted by Policy::resolve.

Functions§

sync_file
Open path for writing (no truncate, no create) and apply policy’s barrier for component. Convenience for post-hoc hardening of already published files; write paths that hold the handle open should prefer Policy::apply directly. Requires write access because sync_all degrades to a permission error on read-only handles (Windows FlushFileBuffers semantics).
test_fsync_enabled
Whether GIT_TEST_FSYNC permits real barriers. Upstream reads this as a boolean through git_env_bool("GIT_TEST_FSYNC", 1) inside maybe_fsync; unrecognized spellings leave syncing enabled.