summaryrefslogtreecommitdiff
path: root/builtin-pack-objects.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-05-30 15:42:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-05-31 21:46:57 (GMT)
commit4c81b03e30d13dbc93ea7071438ef2da0acd4189 (patch)
tree73459678fa41737c15a2957215d51bde97528ddf /builtin-pack-objects.c
parentd2b3691b61d516a0ad2bf700a2a5d9113ceff0b1 (diff)
downloadgit-4c81b03e30d13dbc93ea7071438ef2da0acd4189.zip
git-4c81b03e30d13dbc93ea7071438ef2da0acd4189.tar.gz
git-4c81b03e30d13dbc93ea7071438ef2da0acd4189.tar.bz2
Make pack creation always fsync() the result
This means that we can depend on packs always being stable on disk, simplifying a lot of the object serialization worries. And unlike loose objects, serializing pack creation IO isn't going to be a performance killer. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r--builtin-pack-objects.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 70d2f5d..4c2e0cd 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -515,10 +515,12 @@ static void write_pack_file(void)
* If so, rewrite it like in fast-import
*/
if (pack_to_stdout || nr_written == nr_remaining) {
- sha1close(f, sha1, 1);
+ unsigned flags = pack_to_stdout ? CSUM_CLOSE : CSUM_FSYNC;
+ sha1close(f, sha1, flags);
} else {
int fd = sha1close(f, NULL, 0);
fixup_pack_header_footer(fd, sha1, pack_tmp_name, nr_written);
+ fsync_or_die(fd, pack_tmp_name);
close(fd);
}