summaryrefslogtreecommitdiff
path: root/refs/files-backend.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-03-25 23:38:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-03-25 23:38:25 (GMT)
commit6e1a8952e90e5d125177dbdee21425d1ba2d3584 (patch)
treecda2c48629c1e926d5b971954a038e79f0f0a325 /refs/files-backend.c
parenteb804cd405618ef78b772072685c39392aea4ac1 (diff)
parentbc22d845c4328f5bd896d019b3729f776ad4be4c (diff)
downloadgit-6e1a8952e90e5d125177dbdee21425d1ba2d3584.zip
git-6e1a8952e90e5d125177dbdee21425d1ba2d3584.tar.gz
git-6e1a8952e90e5d125177dbdee21425d1ba2d3584.tar.bz2
Merge branch 'ps/fsync-refs'
Updates to refs traditionally weren't fsync'ed, but we can configure using core.fsync variable to do so. * ps/fsync-refs: core.fsync: new option to harden references
Diffstat (limited to 'refs/files-backend.c')
-rw-r--r--refs/files-backend.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 0457ecd..bc81b52 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1809,6 +1809,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
fd = get_lock_file_fd(&lock->lk);
if (write_in_full(fd, oid_to_hex(oid), the_hash_algo->hexsz) < 0 ||
write_in_full(fd, &term, 1) < 0 ||
+ fsync_component(FSYNC_COMPONENT_REFERENCE, get_lock_file_fd(&lock->lk)) < 0 ||
close_ref_gently(lock) < 0) {
strbuf_addf(err,
"couldn't write '%s'", get_lock_file_path(&lock->lk));