diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-08-20 18:52:02 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-21 00:31:40 +0200 |
commit | 0bff5269d3ed7124259bb3a5b33ddf2c4080b7e7 (patch) | |
tree | 9202a3c78155e5793caf511f00ad3d320634b949 /packfile.c | |
parent | midx: fix bug that skips midx with alternates (diff) | |
download | git-0bff5269d3ed7124259bb3a5b33ddf2c4080b7e7.tar.xz git-0bff5269d3ed7124259bb3a5b33ddf2c4080b7e7.zip |
packfile: add all_packs list
If a repo contains a multi-pack-index, then the packed_git list
does not contain the packfiles that are covered by the multi-pack-index.
This is important for doing object lookups, abbreviations, and
approximating object count. However, there are many operations that
really want to iterate over all packfiles.
Create a new 'all_packs' linked list that contains this list, starting
with the packfiles in the multi-pack-index and then continuing along
the packed_git linked list.
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.c | 27 |
1 files changed, 27 insertions, 0 deletions
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); |