multi-pack-index: store local property
A pack-file is 'local' if it is stored within the usual object directory. If it is stored in an alternate, it is non-local. Pack-files are stored using a 'pack_local' member in the packed_git struct. Add a similar 'local' member to the multi_pack_index struct and 'local' parameters to the methods that load and prepare multi- pack-indexes. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
6d68e6a461
commit
2cf489a3bf
11
midx.c
11
midx.c
@ -37,7 +37,7 @@ static char *get_midx_filename(const char *object_dir)
|
||||
return xstrfmt("%s/pack/multi-pack-index", object_dir);
|
||||
}
|
||||
|
||||
struct multi_pack_index *load_multi_pack_index(const char *object_dir)
|
||||
struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local)
|
||||
{
|
||||
struct multi_pack_index *m = NULL;
|
||||
int fd;
|
||||
@ -73,6 +73,7 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir)
|
||||
m->fd = fd;
|
||||
m->data = midx_map;
|
||||
m->data_len = midx_size;
|
||||
m->local = local;
|
||||
|
||||
m->signature = get_be32(m->data);
|
||||
if (m->signature != MIDX_SIGNATURE) {
|
||||
@ -209,7 +210,7 @@ static int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id)
|
||||
strbuf_addf(&pack_name, "%s/pack/%s", m->object_dir,
|
||||
m->pack_names[pack_int_id]);
|
||||
|
||||
m->packs[pack_int_id] = add_packed_git(pack_name.buf, pack_name.len, 1);
|
||||
m->packs[pack_int_id] = add_packed_git(pack_name.buf, pack_name.len, m->local);
|
||||
strbuf_release(&pack_name);
|
||||
return !m->packs[pack_int_id];
|
||||
}
|
||||
@ -318,7 +319,7 @@ int midx_contains_pack(struct multi_pack_index *m, const char *idx_name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int prepare_multi_pack_index_one(struct repository *r, const char *object_dir)
|
||||
int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local)
|
||||
{
|
||||
struct multi_pack_index *m = r->objects->multi_pack_index;
|
||||
struct multi_pack_index *m_search;
|
||||
@ -332,7 +333,7 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir)
|
||||
if (!strcmp(object_dir, m_search->object_dir))
|
||||
return 1;
|
||||
|
||||
r->objects->multi_pack_index = load_multi_pack_index(object_dir);
|
||||
r->objects->multi_pack_index = load_multi_pack_index(object_dir, local);
|
||||
|
||||
if (r->objects->multi_pack_index) {
|
||||
r->objects->multi_pack_index->next = m;
|
||||
@ -746,7 +747,7 @@ int write_midx_file(const char *object_dir)
|
||||
midx_name);
|
||||
}
|
||||
|
||||
packs.m = load_multi_pack_index(object_dir);
|
||||
packs.m = load_multi_pack_index(object_dir, 1);
|
||||
|
||||
packs.nr = 0;
|
||||
packs.alloc_list = packs.m ? packs.m->num_packs : 16;
|
||||
|
Reference in New Issue
Block a user