aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-06-18 15:18:44 -0700
committerJunio C Hamano <gitster@pobox.com>2008-06-18 16:50:35 -0700
commitaafe9fbaf4f1d1f27a6f6e3eb3e246fff81240ef (patch)
tree86e98a12cfeef6ed0cb1ab622dcdb8b9ace926ca /sha1_file.c
parent1141f4925c3f1d7c8cc476b10107209e56909c6d (diff)
downloadgit-aafe9fbaf4f1d1f27a6f6e3eb3e246fff81240ef.tar.gz
git-aafe9fbaf4f1d1f27a6f6e3eb3e246fff81240ef.tar.xz
Add config option to enable 'fsync()' of object files
As explained in the documentation[*] this is totally useless on filesystems that do ordered/journalled data writes, but it can be a useful safety feature on filesystems like HFS+ that only journal the metadata, not the actual file contents. It defaults to off, although we could presumably in theory some day auto-enable it on a per-filesystem basis. [*] Yes, I updated the docs for the thing. Hell really _has_ frozen over, and the four horsemen are probably just beyond the horizon. EVERYBODY PANIC! Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 191f814e0..fe4ee3ece 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2083,7 +2083,8 @@ int hash_sha1_file(const void *buf, unsigned long len, const char *type,
/* Finalize a file on disk, and close it. */
static void close_sha1_file(int fd)
{
- /* For safe-mode, we could fsync_or_die(fd, "sha1 file") here */
+ if (fsync_object_files)
+ fsync_or_die(fd, "sha1 file");
fchmod(fd, 0444);
if (close(fd) != 0)
die("unable to write sha1 file");