Merge branch 'tb/midx-race-in-pack-objects'
The multi-pack-index code did not protect the packfile it is going to depend on from getting removed while in use, which has been corrected. * tb/midx-race-in-pack-objects: builtin/pack-objects.c: ensure pack validity from MIDX bitmap objects builtin/pack-objects.c: ensure included `--stdin-packs` exist builtin/pack-objects.c: avoid redundant NULL check pack-bitmap.c: check preferred pack validity when opening MIDX bitmap
This commit is contained in:
commit
091680472d
@ -1357,6 +1357,9 @@ static int want_found_object(const struct object_id *oid, int exclude,
|
|||||||
if (incremental)
|
if (incremental)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (!is_pack_valid(p))
|
||||||
|
return -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When asked to do --local (do not include an object that appears in a
|
* When asked to do --local (do not include an object that appears in a
|
||||||
* pack we borrow from elsewhere) or --honor-pack-keep (do not include
|
* pack we borrow from elsewhere) or --honor-pack-keep (do not include
|
||||||
@ -1472,6 +1475,9 @@ static int want_object_in_pack(const struct object_id *oid,
|
|||||||
want = want_found_object(oid, exclude, *found_pack);
|
want = want_found_object(oid, exclude, *found_pack);
|
||||||
if (want != -1)
|
if (want != -1)
|
||||||
return want;
|
return want;
|
||||||
|
|
||||||
|
*found_pack = NULL;
|
||||||
|
*found_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (m = get_multi_pack_index(the_repository); m; m = m->next) {
|
for (m = get_multi_pack_index(the_repository); m; m = m->next) {
|
||||||
@ -3201,10 +3207,8 @@ static int add_object_entry_from_pack(const struct object_id *oid,
|
|||||||
uint32_t pos,
|
uint32_t pos,
|
||||||
void *_data)
|
void *_data)
|
||||||
{
|
{
|
||||||
struct rev_info *revs = _data;
|
|
||||||
struct object_info oi = OBJECT_INFO_INIT;
|
|
||||||
off_t ofs;
|
off_t ofs;
|
||||||
enum object_type type;
|
enum object_type type = OBJ_NONE;
|
||||||
|
|
||||||
display_progress(progress_state, ++nr_seen);
|
display_progress(progress_state, ++nr_seen);
|
||||||
|
|
||||||
@ -3215,19 +3219,24 @@ static int add_object_entry_from_pack(const struct object_id *oid,
|
|||||||
if (!want_object_in_pack(oid, 0, &p, &ofs))
|
if (!want_object_in_pack(oid, 0, &p, &ofs))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
oi.typep = &type;
|
if (p) {
|
||||||
if (packed_object_info(the_repository, p, ofs, &oi) < 0)
|
struct rev_info *revs = _data;
|
||||||
die(_("could not get type of object %s in pack %s"),
|
struct object_info oi = OBJECT_INFO_INIT;
|
||||||
oid_to_hex(oid), p->pack_name);
|
|
||||||
else if (type == OBJ_COMMIT) {
|
|
||||||
/*
|
|
||||||
* commits in included packs are used as starting points for the
|
|
||||||
* subsequent revision walk
|
|
||||||
*/
|
|
||||||
add_pending_oid(revs, NULL, oid, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
stdin_packs_found_nr++;
|
oi.typep = &type;
|
||||||
|
if (packed_object_info(the_repository, p, ofs, &oi) < 0) {
|
||||||
|
die(_("could not get type of object %s in pack %s"),
|
||||||
|
oid_to_hex(oid), p->pack_name);
|
||||||
|
} else if (type == OBJ_COMMIT) {
|
||||||
|
/*
|
||||||
|
* commits in included packs are used as starting points for the
|
||||||
|
* subsequent revision walk
|
||||||
|
*/
|
||||||
|
add_pending_oid(revs, NULL, oid, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
stdin_packs_found_nr++;
|
||||||
|
}
|
||||||
|
|
||||||
create_object_entry(oid, type, 0, 0, 0, p, ofs);
|
create_object_entry(oid, type, 0, 0, 0, p, ofs);
|
||||||
|
|
||||||
@ -3346,6 +3355,8 @@ static void read_packs_list_from_stdin(void)
|
|||||||
struct packed_git *p = item->util;
|
struct packed_git *p = item->util;
|
||||||
if (!p)
|
if (!p)
|
||||||
die(_("could not find pack '%s'"), item->string);
|
die(_("could not find pack '%s'"), item->string);
|
||||||
|
if (!is_pack_valid(p))
|
||||||
|
die(_("packfile %s cannot be accessed"), p->pack_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3369,8 +3380,6 @@ static void read_packs_list_from_stdin(void)
|
|||||||
|
|
||||||
for_each_string_list_item(item, &include_packs) {
|
for_each_string_list_item(item, &include_packs) {
|
||||||
struct packed_git *p = item->util;
|
struct packed_git *p = item->util;
|
||||||
if (!p)
|
|
||||||
die(_("could not find pack '%s'"), item->string);
|
|
||||||
for_each_object_in_pack(p,
|
for_each_object_in_pack(p,
|
||||||
add_object_entry_from_pack,
|
add_object_entry_from_pack,
|
||||||
&revs,
|
&revs,
|
||||||
|
@ -315,6 +315,8 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
char *idx_name = midx_bitmap_filename(midx);
|
char *idx_name = midx_bitmap_filename(midx);
|
||||||
int fd = git_open(idx_name);
|
int fd = git_open(idx_name);
|
||||||
|
uint32_t i;
|
||||||
|
struct packed_git *preferred;
|
||||||
|
|
||||||
free(idx_name);
|
free(idx_name);
|
||||||
|
|
||||||
@ -353,6 +355,20 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
|
|||||||
warning(_("multi-pack bitmap is missing required reverse index"));
|
warning(_("multi-pack bitmap is missing required reverse index"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < bitmap_git->midx->num_packs; i++) {
|
||||||
|
if (prepare_midx_pack(the_repository, bitmap_git->midx, i))
|
||||||
|
die(_("could not open pack %s"),
|
||||||
|
bitmap_git->midx->pack_names[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
preferred = bitmap_git->midx->packs[midx_preferred_pack(bitmap_git)];
|
||||||
|
if (!is_pack_valid(preferred)) {
|
||||||
|
warning(_("preferred pack (%s) is invalid"),
|
||||||
|
preferred->pack_name);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -429,8 +445,6 @@ static int load_reverse_index(struct bitmap_index *bitmap_git)
|
|||||||
* since we will need to make use of them in pack-objects.
|
* since we will need to make use of them in pack-objects.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < bitmap_git->midx->num_packs; i++) {
|
for (i = 0; i < bitmap_git->midx->num_packs; i++) {
|
||||||
if (prepare_midx_pack(the_repository, bitmap_git->midx, i))
|
|
||||||
die(_("load_reverse_index: could not open pack"));
|
|
||||||
ret = load_pack_revindex(bitmap_git->midx->packs[i]);
|
ret = load_pack_revindex(bitmap_git->midx->packs[i]);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user