diff options
author | Derrick Stolee <stolee@gmail.com> | 2018-07-12 22:39:28 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-07-20 21:27:28 +0300 |
commit | 3227565cfdeabcb06eede914d38c8729e6ff1434 (patch) | |
tree | 9ee4589cd669d497f09fe2e0992b5c2bcf7f2073 /midx.c | |
parent | 32f3c541e3c8b3ad225c36b1430c9483d0e427ad (diff) |
midx: read pack names into array
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'midx.c')
-rw-r--r-- | midx.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -37,6 +37,7 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir) uint32_t hash_version; char *midx_name = get_midx_filename(object_dir); uint32_t i; + const char *cur_pack_name; fd = git_open(midx_name); @@ -115,6 +116,22 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir) if (!m->chunk_pack_names) die(_("multi-pack-index missing required pack-name chunk")); + m->pack_names = xcalloc(m->num_packs, sizeof(*m->pack_names)); + + cur_pack_name = (const char *)m->chunk_pack_names; + for (i = 0; i < m->num_packs; i++) { + m->pack_names[i] = cur_pack_name; + + cur_pack_name += strlen(cur_pack_name) + 1; + + if (i && strcmp(m->pack_names[i], m->pack_names[i - 1]) <= 0) { + error(_("multi-pack-index pack names out of order: '%s' before '%s'"), + m->pack_names[i - 1], + m->pack_names[i]); + goto cleanup_fail; + } + } + return m; cleanup_fail: |