summaryrefslogtreecommitdiff
path: root/midx.c
diff options
context:
space:
mode:
Diffstat (limited to 'midx.c')
-rw-r--r--midx.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/midx.c b/midx.c
index 7726c13d7e..1d6269f957 100644
--- a/midx.c
+++ b/midx.c
@@ -93,6 +93,12 @@ static int midx_read_object_offsets(const unsigned char *chunk_start,
return 0;
}
+struct multi_pack_index *get_multi_pack_index(struct odb_source *source)
+{
+ packfile_store_prepare(source->odb->packfiles);
+ return source->midx;
+}
+
static struct multi_pack_index *load_multi_pack_index_one(struct odb_source *source,
const char *midx_name)
{
@@ -443,7 +449,6 @@ int prepare_midx_pack(struct multi_pack_index *m,
{
struct repository *r = m->source->odb->repo;
struct strbuf pack_name = STRBUF_INIT;
- struct strbuf key = STRBUF_INIT;
struct packed_git *p;
pack_int_id = midx_for_pack(&m, pack_int_id);
@@ -455,25 +460,11 @@ int prepare_midx_pack(struct multi_pack_index *m,
strbuf_addf(&pack_name, "%s/pack/%s", m->source->path,
m->pack_names[pack_int_id]);
-
- /* pack_map holds the ".pack" name, but we have the .idx */
- strbuf_addbuf(&key, &pack_name);
- strbuf_strip_suffix(&key, ".idx");
- strbuf_addstr(&key, ".pack");
- p = hashmap_get_entry_from_hash(&r->objects->pack_map,
- strhash(key.buf), key.buf,
- struct packed_git, packmap_ent);
- if (!p) {
- p = add_packed_git(r, pack_name.buf, pack_name.len,
- m->source->local);
- if (p) {
- install_packed_git(r, p);
- list_add_tail(&p->mru, &r->objects->packed_git_mru);
- }
- }
-
+ p = packfile_store_load_pack(r->objects->packfiles,
+ pack_name.buf, m->source->local);
+ if (p)
+ list_add_tail(&p->mru, &r->objects->packfiles->mru);
strbuf_release(&pack_name);
- strbuf_release(&key);
if (!p) {
m->packs[pack_int_id] = MIDX_PACK_ERROR;