summaryrefslogtreecommitdiff
path: root/builtin-pack-objects.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2008-12-09 19:26:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-12-11 01:56:05 (GMT)
commitc74faea19e39ca933492f697596310397175c329 (patch)
tree8d98539f02bf7bcc82c43f466feae01dbf0de9bc /builtin-pack-objects.c
parentaa971cb9bf4105eefb435b9e6f282f019529c35f (diff)
downloadgit-c74faea19e39ca933492f697596310397175c329.zip
git-c74faea19e39ca933492f697596310397175c329.tar.gz
git-c74faea19e39ca933492f697596310397175c329.tar.bz2
make sure packs to be replaced are closed beforehand
Especially on Windows where an opened file cannot be replaced, make sure pack-objects always close packs it is about to replace. Even on non Windows systems, this could save potential bad results if ever objects were to be read from the new pack file using offset from the old index. This should fix t5303 on Windows. Signed-off-by: Nicolas Pitre <nico@cam.org> Tested-by: Johannes Sixt <j6t@kdbg.org> (MinGW) Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r--builtin-pack-objects.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 4411a48..fb5e14d 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -520,6 +520,7 @@ static void write_pack_file(void)
snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
base_name, sha1_to_hex(sha1));
+ free_pack_by_name(tmpname);
if (adjust_perm(pack_tmp_name, mode))
die("unable to make temporary pack file readable: %s",
strerror(errno));