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
This commit is contained in:
@ -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));
|
||||
|
@ -1262,7 +1262,8 @@ static int write_with_updates(struct packed_ref_store *refs,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (close_tempfile_gently(refs->tempfile)) {
|
||||
if (fsync_component(FSYNC_COMPONENT_REFERENCE, get_tempfile_fd(refs->tempfile)) ||
|
||||
close_tempfile_gently(refs->tempfile)) {
|
||||
strbuf_addf(err, "error closing file %s: %s",
|
||||
get_tempfile_path(refs->tempfile),
|
||||
strerror(errno));
|
||||
|
Reference in New Issue
Block a user