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);
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:
const unsigned char *chunk_pack_names;
+ const char **pack_names;
char object_dir[FLEX_ARRAY];
};
static int read_midx_file(const char *object_dir)
{
+ uint32_t i;
struct multi_pack_index *m = load_multi_pack_index(object_dir);
if (!m)
printf("\n");
+ printf("packs:\n");
+ for (i = 0; i < m->num_packs; i++)
+ printf("%s\n", m->pack_names[i]);
+
printf("object-dir: %s\n", m->object_dir);
return 0;
midx_read_expect () {
NUM_PACKS=$1
- cat >expect <<-EOF
- header: 4d494458 1 1 $NUM_PACKS
- chunks: pack-names
- object-dir: .
- EOF
+ {
+ cat <<-EOF &&
+ header: 4d494458 1 1 $NUM_PACKS
+ chunks: pack-names
+ packs:
+ EOF
+ if test $NUM_PACKS -ge 1
+ then
+ ls pack/ | grep idx | sort
+ fi &&
+ printf "object-dir: .\n"
+ } >expect &&
test-tool read-midx . >actual &&
test_cmp expect actual
}