@matheusbsbs / matheus-bagliano / commits / 0c68d386da
Fork 0

index-pack: be careful after fixing up the header/footer

The index-pack command, when processing a thin pack, fixed up the pack after-the-fact. It forgets to fsync the result, because it only did that in one path rather in all cases of fixup. This moves the fsync_or_die() to the fix-up routine itself, rather than doing it in one of the callers, so that all cases are covered. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Aug 27, 2008 at 12:48 UTC 0c68d386da710940a22712b8f3539f7e73ba1b8f
2 files changed +1 -1
builtin-pack-objects.c
-1
@@ -499,7 +499,6 @@ static void write_pack_file(void)
499 } else {
500 int fd = sha1close(f, NULL, 0);
501 fixup_pack_header_footer(fd, sha1, pack_tmp_name, nr_written);
502 - fsync_or_die(fd, pack_tmp_name);
502 close(fd);
503 }
504
pack-write.c
+1
@@ -179,6 +179,7 @@ void fixup_pack_header_footer(int pack_fd,
179
180 SHA1_Final(pack_file_sha1, &c);
181 write_or_die(pack_fd, pack_file_sha1, 20);
182 + fsync_or_die(pack_fd, pack_name);
183 }
184
185 char *index_pack_lockfile(int ip_out)