Signed-off-by: Derrick Stolee <dstolee@xxxxxxxxxxxxx> --- midx.c | 22 ++++++++++++++++++++++ midx.h | 3 +++ object-store.h | 9 +++++++++ packfile.c | 6 +++++- 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/midx.c b/midx.c index 71ca493107..3dd5027dc6 100644 --- a/midx.c +++ b/midx.c @@ -176,6 +176,28 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir) return NULL; } +int prepare_multi_pack_index_one(struct repository *r, const char *object_dir) +{ + struct multi_pack_index *m = r->objects->multi_pack_index; + struct multi_pack_index *m_search; + + if (!core_multi_pack_index) + return 0; + + for (m_search = m; m_search; m_search = m_search->next) + if (!strcmp(object_dir, m_search->object_dir)) + return 1; + + r->objects->multi_pack_index = load_multi_pack_index(object_dir); + + if (r->objects->multi_pack_index) { + r->objects->multi_pack_index->next = m; + return 1; + } + + return 0; +} + static size_t write_midx_header(struct hashfile *f, unsigned char num_chunks, uint32_t num_packs) diff --git a/midx.h b/midx.h index 2d83dd9ec1..731ad6f094 100644 --- a/midx.h +++ b/midx.h @@ -1,9 +1,12 @@ #ifndef __MIDX_H__ #define __MIDX_H__ +#include "repository.h" + struct multi_pack_index; struct multi_pack_index *load_multi_pack_index(const char *object_dir); +int prepare_multi_pack_index_one(struct repository *r, const char *object_dir); int write_midx_file(const char *object_dir); diff --git a/object-store.h b/object-store.h index 07bcc80e02..7d67ad7aa9 100644 --- a/object-store.h +++ b/object-store.h @@ -85,6 +85,8 @@ struct packed_git { }; struct multi_pack_index { + struct multi_pack_index *next; + int fd; const unsigned char *data; @@ -126,6 +128,13 @@ struct raw_object_store { */ struct oidmap *replace_map; + /* + * private data + * + * should only be accessed directly by packfile.c and midx.c + */ + struct multi_pack_index *multi_pack_index; + /* * private data * diff --git a/packfile.c b/packfile.c index 39d6b66337..ff2df22a0b 100644 --- a/packfile.c +++ b/packfile.c @@ -15,6 +15,7 @@ #include "tree-walk.h" #include "tree.h" #include "object-store.h" +#include "midx.h" char *odb_pack_name(struct strbuf *buf, const unsigned char *sha1, @@ -937,10 +938,13 @@ static void prepare_packed_git(struct repository *r) if (r->objects->packed_git_initialized) return; + prepare_multi_pack_index_one(r, r->objects->objectdir); prepare_packed_git_one(r, r->objects->objectdir, 1); prepare_alt_odb(r); - for (alt = r->objects->alt_odb_list; alt; alt = alt->next) + for (alt = r->objects->alt_odb_list; alt; alt = alt->next) { + prepare_multi_pack_index_one(r, alt->path); prepare_packed_git_one(r, alt->path, 0); + } rearrange_packed_git(r); prepare_packed_git_mru(r); r->objects->packed_git_initialized = 1; -- 2.18.0.24.g1b579a2ee9