aboutsummaryrefslogtreecommitdiffstats
path: root/object-file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-04-06 13:01:54 -0700
committerJunio C Hamano <gitster@pobox.com>2022-04-06 13:01:54 -0700
commitfca85986bb936346d362c4802ebce5692fd257ee (patch)
treef7223aef7eb92a5ae483fe86b790c207f1f24043 /object-file.c
parentThe eleventh batch (diff)
parentconfigure.ac: fix HAVE_SYNC_FILE_RANGE definition (diff)
downloadgit-fca85986bb936346d362c4802ebce5692fd257ee.tar.gz
git-fca85986bb936346d362c4802ebce5692fd257ee.zip
Merge branch 'ns/core-fsyncmethod' into ns/batch-fsync
* ns/core-fsyncmethod: configure.ac: fix HAVE_SYNC_FILE_RANGE definition core.fsyncmethod: correctly camel-case warning message core.fsync: fix incorrect expression for default configuration core.fsync: documentation and user-friendly aggregate options core.fsync: new option to harden the index core.fsync: add configuration parsing core.fsync: introduce granular fsync control infrastructure core.fsyncmethod: add writeout-only mode wrapper: make inclusion of Windows csprng header tightly scoped
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/object-file.c b/object-file.c
index 03bd6a3baf..e3f0bf27ff 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1849,11 +1849,16 @@ int hash_object_file(const struct git_hash_algo *algo, const void *buf,
/* Finalize a file on disk, and close it. */
static void close_loose_object(int fd)
{
- if (!the_repository->objects->odb->will_destroy) {
- if (fsync_object_files)
- fsync_or_die(fd, "loose object file");
- }
+ if (the_repository->objects->odb->will_destroy)
+ goto out;
+ if (fsync_object_files > 0)
+ fsync_or_die(fd, "loose object file");
+ else
+ fsync_component_or_die(FSYNC_COMPONENT_LOOSE_OBJECT, fd,
+ "loose object file");
+
+out:
if (close(fd) != 0)
die_errno(_("error when closing loose object file"));
}