summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-12-11 08:36:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-12-11 08:36:31 (GMT)
commitde0db422782ddaf7754ac5b03fdc6dc5de1a9ae4 (patch)
tree643c6f8be7804462cc1e21f95cd33bd8dfb27f5f /sha1_file.c
parent07e62b733fad4236371a8cd6abc32409fb1fb87d (diff)
parent04d39759373e5de017e7c17ef4b762ac5ad3afcc (diff)
downloadgit-de0db422782ddaf7754ac5b03fdc6dc5de1a9ae4.zip
git-de0db422782ddaf7754ac5b03fdc6dc5de1a9ae4.tar.gz
git-de0db422782ddaf7754ac5b03fdc6dc5de1a9ae4.tar.bz2
Merge branch 'maint'
* maint: fsck: reduce stack footprint make sure packs to be replaced are closed beforehand
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 6c0e251..0e021c5 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -673,6 +673,37 @@ void unuse_pack(struct pack_window **w_cursor)
}
/*
+ * 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
+ * the resulting file might be different even if its name would be the
+ * same. It is best to close any reference to the old pack before it is
+ * replaced on disk. Of course no index pointers nor windows for given pack
+ * must subsist at this point. If ever objects from this pack are requested
+ * again, the new version of the pack will be reinitialized through
+ * reprepare_packed_git().
+ */
+void free_pack_by_name(const char *pack_name)
+{
+ struct packed_git *p, **pp = &packed_git;
+
+ while (*pp) {
+ p = *pp;
+ if (strcmp(pack_name, p->pack_name) == 0) {
+ 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);
+ free(p->bad_object_sha1);
+ *pp = p->next;
+ free(p);
+ return;
+ }
+ pp = &p->next;
+ }
+}
+
+/*
* Do not call this directly as this leaks p->pack_fd on error return;
* call open_packed_git() instead.
*/