diff options
-rw-r--r-- | midx.c | 2 | ||||
-rw-r--r-- | midx.h | 1 | ||||
-rw-r--r-- | object-store.h | 6 | ||||
-rw-r--r-- | packfile.c | 27 | ||||
-rw-r--r-- | packfile.h | 1 |
5 files changed, 36 insertions, 1 deletions
@@ -197,7 +197,7 @@ static void close_midx(struct multi_pack_index *m) FREE_AND_NULL(m->pack_names); } -static int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id) +int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id) { struct strbuf pack_name = STRBUF_INIT; @@ -32,6 +32,7 @@ struct multi_pack_index { }; struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local); +int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id); int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result); struct object_id *nth_midxed_object_oid(struct object_id *oid, struct multi_pack_index *m, diff --git a/object-store.h b/object-store.h index 97f1c160e5..63b7605a3e 100644 --- a/object-store.h +++ b/object-store.h @@ -130,6 +130,12 @@ struct raw_object_store { struct list_head packed_git_mru; /* + * A linked list containing all packfiles, starting with those + * contained in the multi_pack_index. + */ + struct packed_git *all_packs; + + /* * A fast, rough count of the number of objects in the repository. * These two fields are not meant for direct access. Use * approximate_object_count() instead. diff --git a/packfile.c b/packfile.c index fe713a0242..adcf2e12a0 100644 --- a/packfile.c +++ b/packfile.c @@ -972,6 +972,9 @@ static void prepare_packed_git(struct repository *r) prepare_packed_git_one(r, alt->path, 0); } rearrange_packed_git(r); + + r->objects->all_packs = NULL; + prepare_packed_git_mru(r); r->objects->packed_git_initialized = 1; } @@ -995,6 +998,30 @@ struct multi_pack_index *get_multi_pack_index(struct repository *r) return r->objects->multi_pack_index; } +struct packed_git *get_all_packs(struct repository *r) +{ + prepare_packed_git(r); + + if (!r->objects->all_packs) { + struct packed_git *p = r->objects->packed_git; + struct multi_pack_index *m; + + for (m = r->objects->multi_pack_index; m; m = m->next) { + uint32_t i; + for (i = 0; i < m->num_packs; i++) { + if (!prepare_midx_pack(m, i)) { + m->packs[i]->next = p; + p = m->packs[i]; + } + } + } + + r->objects->all_packs = p; + } + + return r->objects->all_packs; +} + struct list_head *get_packed_git_mru(struct repository *r) { prepare_packed_git(r); diff --git a/packfile.h b/packfile.h index 5abfaf2ab5..442625723d 100644 --- a/packfile.h +++ b/packfile.h @@ -51,6 +51,7 @@ extern void install_packed_git(struct repository *r, struct packed_git *pack); struct packed_git *get_packed_git(struct repository *r); struct list_head *get_packed_git_mru(struct repository *r); struct multi_pack_index *get_multi_pack_index(struct repository *r); +struct packed_git *get_all_packs(struct repository *r); /* * Give a rough count of objects in the repository. This sacrifices accuracy |