Windows: A rudimentary poll() emulation.
[gitweb.git] / builtin-pack-objects.c
index 70d2f5d4161a0bb62f4734be97d0a8dd2a5098dc..447d492dbbfb578b8903293fa1d2a988eecfefac 100644 (file)
@@ -514,11 +514,14 @@ static void write_pack_file(void)
                 * Did we write the wrong # entries in the header?
                 * If so, rewrite it like in fast-import
                 */
-               if (pack_to_stdout || nr_written == nr_remaining) {
-                       sha1close(f, sha1, 1);
+               if (pack_to_stdout) {
+                       sha1close(f, sha1, CSUM_CLOSE);
+               } else if (nr_written == nr_remaining) {
+                       sha1close(f, sha1, CSUM_FSYNC);
                } 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);
                }