aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-04-19 07:23:06 -0700
committerJunio C Hamano <gitster@pobox.com>2010-04-19 17:56:08 -0700
commitfa5fc15d6ecfb9452c578bb4c80e98ccca12750c (patch)
tree980077ada6085c5ea0be4f02d56b504de4b8c723 /sha1_file.c
parent162eb5f838630f75f78f26d28b46b02781724b7d (diff)
downloadgit-fa5fc15d6ecfb9452c578bb4c80e98ccca12750c.tar.gz
git-fa5fc15d6ecfb9452c578bb4c80e98ccca12750c.tar.xz
Introduce close_pack_index to permit replacement
By closing the pack index, a caller can later overwrite the index with an updated index file, possibly after converting from v1 to the v2 format. Because p->index_data is NULL after close, on the next access the index will be opened again and the other members will be updated with new data. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sha1_file.c b/sha1_file.c
index c23cc5e6e..4e82654d7 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -606,6 +606,14 @@ void unuse_pack(struct pack_window **w_cursor)
}
}
+void close_pack_index(struct packed_git *p)
+{
+ if (p->index_data) {
+ munmap((void *)p->index_data, p->index_size);
+ p->index_data = NULL;
+ }
+}
+
/*
* This is used by git-repack in case a newly created pack happens to
* contain the same set of objects as an existing one. In that case
@@ -627,8 +635,7 @@ void free_pack_by_name(const char *pack_name)
close_pack_windows(p);
if (p->pack_fd != -1)
close(p->pack_fd);
- if (p->index_data)
- munmap((void *)p->index_data, p->index_size);
+ close_pack_index(p);
free(p->bad_object_sha1);
*pp = p->next;
free(p);