Ensure we close the packfile after creating it in fast-import.
Because we are renaming the packfile into its file destination we need to be sure its not open when the rename is called, otherwise some operating systems (e.g. Windows) may prevent the rename from occurring. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 16, 2007 at 01:17 UTC
1280158738333109cf0ada2fb378db2cdf7296ad
1 file changed
+2
-4
fast-import.c
+2
-4
@@ -645,6 +645,7 @@ static void fixup_header_footer()
645
646
SHA1_Final(pack_data->sha1, &c);
647
write_or_die(pack_fd, pack_data->sha1, sizeof(pack_data->sha1));
648
+ close(pack_fd);
649
}
650
651
static int oecmp (const void *a_, const void *b_)
@@ -768,14 +769,11 @@ static void end_packfile()
769
if (!new_p)
770
die("core git rejected index %s", idx_name);
771
new_p->windows = old_p->windows;
771
- new_p->pack_fd = old_p->pack_fd;
772
all_packs[pack_id++] = new_p;
773
install_packed_git(new_p);
774
}
775
- else {
776
- close(pack_fd);
775
+ else
776
unlink(old_p->pack_name);
778
- }
777
free(old_p);
778
779
/* We can't carry a delta across packfiles. */