summaryrefslogtreecommitdiffstats
path: root/pack-bitmap.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-12-21 01:20:33 -0500
committerJunio C Hamano <gitster@pobox.com>2015-12-21 14:36:28 -0800
commit9d98bbf5785708da4effc9b8f34ba6e18d726625 (patch)
tree26258229df1ac0124b99f7d0005fb00ea6db77fc /pack-bitmap.c
parentf4015337daf130944393296550dd7d8a9c172325 (diff)
downloadgit-9d98bbf5785708da4effc9b8f34ba6e18d726625.tar.gz
git-9d98bbf5785708da4effc9b8f34ba6e18d726625.tar.xz
pack-revindex: store entries directly in packed_git
A pack_revindex struct has two elements: the revindex entries themselves, and a pointer to the packed_git. We need both to do lookups, because only the latter knows things like the number of objects in the pack. Now that packed_git contains the pack_revindex struct it's just as easy to pass around the packed_git itself, and we do not need the extra back-pointer. We can instead just store the entries directly in the pack. All functions which took a pack_revindex now just take a packed_git. We still lazy-load in find_pack_revindex, so most callers are unaffected. The exception is the bitmap code, which computes the revindex and caches the pointer when we load the bitmaps. We can continue to load, drop the extra cache pointer, and just access bitmap_git.pack.revindex directly. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-bitmap.c')
-rw-r--r--pack-bitmap.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 91e410153..ead6de07c 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -33,9 +33,6 @@ static struct bitmap_index {
/* Packfile to which this bitmap index belongs to */
struct packed_git *pack;
- /* reverse index for the packfile */
- struct pack_revindex *reverse_index;
-
/*
* Mark the first `reuse_objects` in the packfile as reused:
* they will be sent as-is without using them for repacking
@@ -293,7 +290,7 @@ static int load_pack_bitmap(void)
bitmap_git.bitmaps = kh_init_sha1();
bitmap_git.ext_index.positions = kh_init_sha1_pos();
- bitmap_git.reverse_index = revindex_for_pack(bitmap_git.pack);
+ load_pack_revindex(bitmap_git.pack);
if (!(bitmap_git.commits = read_bitmap_1(&bitmap_git)) ||
!(bitmap_git.trees = read_bitmap_1(&bitmap_git)) ||
@@ -379,7 +376,7 @@ static inline int bitmap_position_packfile(const unsigned char *sha1)
if (!offset)
return -1;
- return find_revindex_position(bitmap_git.reverse_index, offset);
+ return find_revindex_position(bitmap_git.pack, offset);
}
static int bitmap_position(const unsigned char *sha1)
@@ -631,7 +628,7 @@ static void show_objects_for_type(
if (pos + offset < bitmap_git.reuse_objects)
continue;
- entry = &bitmap_git.reverse_index->revindex[pos + offset];
+ entry = &bitmap_git.pack->revindex[pos + offset];
sha1 = nth_packed_object_sha1(bitmap_git.pack, entry->nr);
if (bitmap_git.hashes)
@@ -805,7 +802,7 @@ int reuse_partial_packfile_from_bitmap(struct packed_git **packfile,
return -1;
bitmap_git.reuse_objects = *entries = reuse_objects;
- *up_to = bitmap_git.reverse_index->revindex[reuse_objects].offset;
+ *up_to = bitmap_git.pack->revindex[reuse_objects].offset;
*packfile = bitmap_git.pack;
return 0;
@@ -1037,7 +1034,7 @@ int rebuild_existing_bitmaps(struct packing_data *mapping,
struct revindex_entry *entry;
struct object_entry *oe;
- entry = &bitmap_git.reverse_index->revindex[i];
+ entry = &bitmap_git.pack->revindex[i];
sha1 = nth_packed_object_sha1(bitmap_git.pack, entry->nr);
oe = packlist_find(mapping, sha1, NULL);