Merge branch 'ps/fsync-refs-fix'

Fix the sequence to fsync $GIT_DIR/packed-refs file that forgot to
flush its output to the disk..

* ps/fsync-refs-fix:
  refs: fix corruption by not correctly syncing packed-refs to disk
This commit is contained in:
Junio C Hamano 2023-01-02 21:37:19 +09:00
commit 3ed91c5f22
1 changed files with 2 additions and 1 deletions

View File

@ -1263,7 +1263,8 @@ static int write_with_updates(struct packed_ref_store *refs,
goto error; goto error;
} }
if (fsync_component(FSYNC_COMPONENT_REFERENCE, get_tempfile_fd(refs->tempfile)) || if (fflush(out) ||
fsync_component(FSYNC_COMPONENT_REFERENCE, get_tempfile_fd(refs->tempfile)) ||
close_tempfile_gently(refs->tempfile)) { close_tempfile_gently(refs->tempfile)) {
strbuf_addf(err, "error closing file %s: %s", strbuf_addf(err, "error closing file %s: %s",
get_tempfile_path(refs->tempfile), get_tempfile_path(refs->tempfile),