summaryrefslogtreecommitdiff
path: root/packfile.c
diff options
context:
space:
mode:
authorDerrick Stolee <stolee@gmail.com>2018-07-12 19:39:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-20 18:27:29 (GMT)
commitf3a002bd84790e89399c3a18f1e7101b850ed6f8 (patch)
tree0ad8fdb436d6c9bfa37fb96558a55bddefeaa54f /packfile.c
parentb8990fbfedf7cd9fc92a5208b0fbbd7dad79be6d (diff)
downloadgit-f3a002bd84790e89399c3a18f1e7101b850ed6f8.zip
git-f3a002bd84790e89399c3a18f1e7101b850ed6f8.tar.gz
git-f3a002bd84790e89399c3a18f1e7101b850ed6f8.tar.bz2
midx: prevent duplicate packfile loads
The multi-pack-index, when present, tracks the existence of objects and their offsets within a list of packfiles. This allows us to use the multi-pack-index for object lookups, abbreviations, and object counts. When the multi-pack-index tracks a packfile, then we do not need to add that packfile to the packed_git linked list or the MRU list. We still need to load the packfiles that are not tracked by the multi-pack-index. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/packfile.c b/packfile.c
index 97e7812..2c819a0 100644
--- a/packfile.c
+++ b/packfile.c
@@ -795,6 +795,7 @@ struct prepare_pack_data {
struct repository *r;
struct string_list *garbage;
int local;
+ struct multi_pack_index *m;
};
static void prepare_pack(const char *full_name, size_t full_name_len,
@@ -805,6 +806,8 @@ static void prepare_pack(const char *full_name, size_t full_name_len,
size_t base_len = full_name_len;
if (strip_suffix_mem(full_name, &base_len, ".idx")) {
+ if (data->m && midx_contains_pack(data->m, file_name))
+ return;
/* Don't reopen a pack we already have. */
for (p = data->r->objects->packed_git; p; p = p->next) {
size_t len;
@@ -839,6 +842,12 @@ static void prepare_packed_git_one(struct repository *r, char *objdir, int local
struct prepare_pack_data data;
struct string_list garbage = STRING_LIST_INIT_DUP;
+ data.m = r->objects->multi_pack_index;
+
+ /* look for the multi-pack-index for this object directory */
+ while (data.m && strcmp(data.m->object_dir, objdir))
+ data.m = data.m->next;
+
data.r = r;
data.garbage = &garbage;
data.local = local;