diff options
Diffstat (limited to 'object-file.c')
| -rw-r--r-- | object-file.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/object-file.c b/object-file.c index bdc5cbdd38..b254bc50d7 100644 --- a/object-file.c +++ b/object-file.c @@ -274,10 +274,11 @@ static struct cached_object { static int cached_object_nr, cached_object_alloc; static struct cached_object empty_tree = { - { EMPTY_TREE_SHA1_BIN_LITERAL }, - OBJ_TREE, - "", - 0 + .oid = { + .hash = EMPTY_TREE_SHA1_BIN_LITERAL, + }, + .type = OBJ_TREE, + .buf = "", }; static struct cached_object *find_cached_object(const struct object_id *oid) @@ -1889,11 +1890,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")); } |
