summaryrefslogtreecommitdiff
path: root/object-file.c
diff options
context:
space:
mode:
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 bdc5cbd..62ebe23 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1889,11 +1889,16 @@ void 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"));
}