summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 162eb5f)
raw | patch | inline | side by side (parent: 162eb5f)
author | Shawn O. Pearce <spearce@spearce.org> | |
Mon, 19 Apr 2010 14:23:06 +0000 (07:23 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 20 Apr 2010 00:56:08 +0000 (17:56 -0700) |
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>
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>
cache.h | patch | blob | history | |
sha1_file.c | patch | blob | history |
index 6e54993256befed7b77fc54559ff196d01292ef2..0eba039dbfe581d057212efe6a21702fa736a980 100644 (file)
--- a/cache.h
+++ b/cache.h
extern void pack_report(void);
extern int open_pack_index(struct packed_git *);
+extern void close_pack_index(struct packed_git *);
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned int *);
extern void close_pack_windows(struct packed_git *);
extern void unuse_pack(struct pack_window **);
diff --git a/sha1_file.c b/sha1_file.c
index c23cc5e6e19a2d8c9a92161b0a5d62a5ef8e920b..4e82654d7c1636f22854f50219ee97bc4027c144 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
}
}
+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
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);