mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
midx: drop redundant struct repository parameter
There are a couple of functions that take both a `struct repository` and a `struct multi_pack_index`. This provides redundant information though without much benefit given that the multi-pack index already has a pointer to its owning repository. Drop the `struct repository` parameter from such functions. While at it, reorder the list of parameters of `fill_midx_entry()` so that the MIDX comes first to better align with our coding guidelines. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
57363dfa0d
commit
9ff2129615
@@ -1733,7 +1733,7 @@ static int want_object_in_pack_mtime(const struct object_id *oid,
|
|||||||
struct multi_pack_index *m = get_multi_pack_index(source);
|
struct multi_pack_index *m = get_multi_pack_index(source);
|
||||||
struct pack_entry e;
|
struct pack_entry e;
|
||||||
|
|
||||||
if (m && fill_midx_entry(the_repository, oid, &e, m)) {
|
if (m && fill_midx_entry(m, oid, &e)) {
|
||||||
want = want_object_in_pack_one(e.p, oid, exclude, found_pack, found_offset, found_mtime);
|
want = want_object_in_pack_one(e.p, oid, exclude, found_pack, found_offset, found_mtime);
|
||||||
if (want != -1)
|
if (want != -1)
|
||||||
return want;
|
return want;
|
||||||
|
|||||||
16
midx-write.c
16
midx-write.c
@@ -942,8 +942,7 @@ static int fill_packs_from_midx(struct write_midx_context *ctx,
|
|||||||
*/
|
*/
|
||||||
if (flags & MIDX_WRITE_REV_INDEX ||
|
if (flags & MIDX_WRITE_REV_INDEX ||
|
||||||
preferred_pack_name) {
|
preferred_pack_name) {
|
||||||
if (prepare_midx_pack(ctx->repo, m,
|
if (prepare_midx_pack(m, m->num_packs_in_base + i)) {
|
||||||
m->num_packs_in_base + i)) {
|
|
||||||
error(_("could not load pack"));
|
error(_("could not load pack"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1566,7 +1565,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla
|
|||||||
if (count[i])
|
if (count[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (prepare_midx_pack(r, m, i))
|
if (prepare_midx_pack(m, i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (m->packs[i]->pack_keep || m->packs[i]->is_cruft)
|
if (m->packs[i]->pack_keep || m->packs[i]->is_cruft)
|
||||||
@@ -1612,13 +1611,12 @@ static int compare_by_mtime(const void *a_, const void *b_)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int want_included_pack(struct repository *r,
|
static int want_included_pack(struct multi_pack_index *m,
|
||||||
struct multi_pack_index *m,
|
|
||||||
int pack_kept_objects,
|
int pack_kept_objects,
|
||||||
uint32_t pack_int_id)
|
uint32_t pack_int_id)
|
||||||
{
|
{
|
||||||
struct packed_git *p;
|
struct packed_git *p;
|
||||||
if (prepare_midx_pack(r, m, pack_int_id))
|
if (prepare_midx_pack(m, pack_int_id))
|
||||||
return 0;
|
return 0;
|
||||||
p = m->packs[pack_int_id];
|
p = m->packs[pack_int_id];
|
||||||
if (!pack_kept_objects && p->pack_keep)
|
if (!pack_kept_objects && p->pack_keep)
|
||||||
@@ -1640,7 +1638,7 @@ static void fill_included_packs_all(struct repository *r,
|
|||||||
repo_config_get_bool(r, "repack.packkeptobjects", &pack_kept_objects);
|
repo_config_get_bool(r, "repack.packkeptobjects", &pack_kept_objects);
|
||||||
|
|
||||||
for (i = 0; i < m->num_packs; i++) {
|
for (i = 0; i < m->num_packs; i++) {
|
||||||
if (!want_included_pack(r, m, pack_kept_objects, i))
|
if (!want_included_pack(m, pack_kept_objects, i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
include_pack[i] = 1;
|
include_pack[i] = 1;
|
||||||
@@ -1664,7 +1662,7 @@ static void fill_included_packs_batch(struct repository *r,
|
|||||||
for (i = 0; i < m->num_packs; i++) {
|
for (i = 0; i < m->num_packs; i++) {
|
||||||
pack_info[i].pack_int_id = i;
|
pack_info[i].pack_int_id = i;
|
||||||
|
|
||||||
if (prepare_midx_pack(r, m, i))
|
if (prepare_midx_pack(m, i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pack_info[i].mtime = m->packs[i]->mtime;
|
pack_info[i].mtime = m->packs[i]->mtime;
|
||||||
@@ -1683,7 +1681,7 @@ static void fill_included_packs_batch(struct repository *r,
|
|||||||
struct packed_git *p = m->packs[pack_int_id];
|
struct packed_git *p = m->packs[pack_int_id];
|
||||||
uint64_t expected_size;
|
uint64_t expected_size;
|
||||||
|
|
||||||
if (!want_included_pack(r, m, pack_kept_objects, pack_int_id))
|
if (!want_included_pack(m, pack_kept_objects, pack_int_id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
18
midx.c
18
midx.c
@@ -450,9 +450,10 @@ static uint32_t midx_for_pack(struct multi_pack_index **_m,
|
|||||||
return pack_int_id - m->num_packs_in_base;
|
return pack_int_id - m->num_packs_in_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
int prepare_midx_pack(struct repository *r, struct multi_pack_index *m,
|
int prepare_midx_pack(struct multi_pack_index *m,
|
||||||
uint32_t pack_int_id)
|
uint32_t pack_int_id)
|
||||||
{
|
{
|
||||||
|
struct repository *r = m->repo;
|
||||||
struct strbuf pack_name = STRBUF_INIT;
|
struct strbuf pack_name = STRBUF_INIT;
|
||||||
struct strbuf key = STRBUF_INIT;
|
struct strbuf key = STRBUF_INIT;
|
||||||
struct packed_git *p;
|
struct packed_git *p;
|
||||||
@@ -507,7 +508,7 @@ struct packed_git *nth_midxed_pack(struct multi_pack_index *m,
|
|||||||
|
|
||||||
#define MIDX_CHUNK_BITMAPPED_PACKS_WIDTH (2 * sizeof(uint32_t))
|
#define MIDX_CHUNK_BITMAPPED_PACKS_WIDTH (2 * sizeof(uint32_t))
|
||||||
|
|
||||||
int nth_bitmapped_pack(struct repository *r, struct multi_pack_index *m,
|
int nth_bitmapped_pack(struct multi_pack_index *m,
|
||||||
struct bitmapped_pack *bp, uint32_t pack_int_id)
|
struct bitmapped_pack *bp, uint32_t pack_int_id)
|
||||||
{
|
{
|
||||||
uint32_t local_pack_int_id = midx_for_pack(&m, pack_int_id);
|
uint32_t local_pack_int_id = midx_for_pack(&m, pack_int_id);
|
||||||
@@ -515,7 +516,7 @@ int nth_bitmapped_pack(struct repository *r, struct multi_pack_index *m,
|
|||||||
if (!m->chunk_bitmapped_packs)
|
if (!m->chunk_bitmapped_packs)
|
||||||
return error(_("MIDX does not contain the BTMP chunk"));
|
return error(_("MIDX does not contain the BTMP chunk"));
|
||||||
|
|
||||||
if (prepare_midx_pack(r, m, pack_int_id))
|
if (prepare_midx_pack(m, pack_int_id))
|
||||||
return error(_("could not load bitmapped pack %"PRIu32), pack_int_id);
|
return error(_("could not load bitmapped pack %"PRIu32), pack_int_id);
|
||||||
|
|
||||||
bp->p = m->packs[local_pack_int_id];
|
bp->p = m->packs[local_pack_int_id];
|
||||||
@@ -600,10 +601,9 @@ uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos)
|
|||||||
(off_t)pos * MIDX_CHUNK_OFFSET_WIDTH);
|
(off_t)pos * MIDX_CHUNK_OFFSET_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fill_midx_entry(struct repository *r,
|
int fill_midx_entry(struct multi_pack_index *m,
|
||||||
const struct object_id *oid,
|
const struct object_id *oid,
|
||||||
struct pack_entry *e,
|
struct pack_entry *e)
|
||||||
struct multi_pack_index *m)
|
|
||||||
{
|
{
|
||||||
uint32_t pos;
|
uint32_t pos;
|
||||||
uint32_t pack_int_id;
|
uint32_t pack_int_id;
|
||||||
@@ -615,7 +615,7 @@ int fill_midx_entry(struct repository *r,
|
|||||||
midx_for_object(&m, pos);
|
midx_for_object(&m, pos);
|
||||||
pack_int_id = nth_midxed_pack_int_id(m, pos);
|
pack_int_id = nth_midxed_pack_int_id(m, pos);
|
||||||
|
|
||||||
if (prepare_midx_pack(r, m, pack_int_id))
|
if (prepare_midx_pack(m, pack_int_id))
|
||||||
return 0;
|
return 0;
|
||||||
p = m->packs[pack_int_id - m->num_packs_in_base];
|
p = m->packs[pack_int_id - m->num_packs_in_base];
|
||||||
|
|
||||||
@@ -912,7 +912,7 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
|
|||||||
_("Looking for referenced packfiles"),
|
_("Looking for referenced packfiles"),
|
||||||
m->num_packs + m->num_packs_in_base);
|
m->num_packs + m->num_packs_in_base);
|
||||||
for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
|
for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
|
||||||
if (prepare_midx_pack(r, m, i))
|
if (prepare_midx_pack(m, i))
|
||||||
midx_report("failed to load pack in position %d", i);
|
midx_report("failed to load pack in position %d", i);
|
||||||
|
|
||||||
display_progress(progress, i + 1);
|
display_progress(progress, i + 1);
|
||||||
@@ -989,7 +989,7 @@ int verify_midx_file(struct repository *r, const char *object_dir, unsigned flag
|
|||||||
|
|
||||||
nth_midxed_object_oid(&oid, m, pairs[i].pos);
|
nth_midxed_object_oid(&oid, m, pairs[i].pos);
|
||||||
|
|
||||||
if (!fill_midx_entry(r, &oid, &e, m)) {
|
if (!fill_midx_entry(m, &oid, &e)) {
|
||||||
midx_report(_("failed to load pack entry for oid[%d] = %s"),
|
midx_report(_("failed to load pack entry for oid[%d] = %s"),
|
||||||
pairs[i].pos, oid_to_hex(&oid));
|
pairs[i].pos, oid_to_hex(&oid));
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
6
midx.h
6
midx.h
@@ -103,10 +103,10 @@ void get_split_midx_filename_ext(const struct git_hash_algo *hash_algo,
|
|||||||
struct multi_pack_index *load_multi_pack_index(struct repository *r,
|
struct multi_pack_index *load_multi_pack_index(struct repository *r,
|
||||||
const char *object_dir,
|
const char *object_dir,
|
||||||
int local);
|
int local);
|
||||||
int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id);
|
int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id);
|
||||||
struct packed_git *nth_midxed_pack(struct multi_pack_index *m,
|
struct packed_git *nth_midxed_pack(struct multi_pack_index *m,
|
||||||
uint32_t pack_int_id);
|
uint32_t pack_int_id);
|
||||||
int nth_bitmapped_pack(struct repository *r, struct multi_pack_index *m,
|
int nth_bitmapped_pack(struct multi_pack_index *m,
|
||||||
struct bitmapped_pack *bp, uint32_t pack_int_id);
|
struct bitmapped_pack *bp, uint32_t pack_int_id);
|
||||||
int bsearch_one_midx(const struct object_id *oid, struct multi_pack_index *m,
|
int bsearch_one_midx(const struct object_id *oid, struct multi_pack_index *m,
|
||||||
uint32_t *result);
|
uint32_t *result);
|
||||||
@@ -118,7 +118,7 @@ uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos);
|
|||||||
struct object_id *nth_midxed_object_oid(struct object_id *oid,
|
struct object_id *nth_midxed_object_oid(struct object_id *oid,
|
||||||
struct multi_pack_index *m,
|
struct multi_pack_index *m,
|
||||||
uint32_t n);
|
uint32_t n);
|
||||||
int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
|
int fill_midx_entry(struct multi_pack_index *m, const struct object_id *oid, struct pack_entry *e);
|
||||||
int midx_contains_pack(struct multi_pack_index *m,
|
int midx_contains_pack(struct multi_pack_index *m,
|
||||||
const char *idx_or_pack_name);
|
const char *idx_or_pack_name);
|
||||||
int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id);
|
int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id);
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < bitmap_git->midx->num_packs + bitmap_git->midx->num_packs_in_base; i++) {
|
for (i = 0; i < bitmap_git->midx->num_packs + bitmap_git->midx->num_packs_in_base; i++) {
|
||||||
if (prepare_midx_pack(bitmap_repo(bitmap_git), bitmap_git->midx, i)) {
|
if (prepare_midx_pack(bitmap_git->midx, i)) {
|
||||||
warning(_("could not open pack %s"),
|
warning(_("could not open pack %s"),
|
||||||
bitmap_git->midx->pack_names[i]);
|
bitmap_git->midx->pack_names[i]);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -2466,7 +2466,7 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
|
|||||||
struct multi_pack_index *m = bitmap_git->midx;
|
struct multi_pack_index *m = bitmap_git->midx;
|
||||||
for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
|
for (i = 0; i < m->num_packs + m->num_packs_in_base; i++) {
|
||||||
struct bitmapped_pack pack;
|
struct bitmapped_pack pack;
|
||||||
if (nth_bitmapped_pack(r, bitmap_git->midx, &pack, i) < 0) {
|
if (nth_bitmapped_pack(bitmap_git->midx, &pack, i) < 0) {
|
||||||
warning(_("unable to load pack: '%s', disabling pack-reuse"),
|
warning(_("unable to load pack: '%s', disabling pack-reuse"),
|
||||||
bitmap_git->midx->pack_names[i]);
|
bitmap_git->midx->pack_names[i]);
|
||||||
free(packs);
|
free(packs);
|
||||||
|
|||||||
@@ -1091,7 +1091,7 @@ struct packed_git *get_all_packs(struct repository *r)
|
|||||||
if (!m)
|
if (!m)
|
||||||
continue;
|
continue;
|
||||||
for (uint32_t i = 0; i < m->num_packs + m->num_packs_in_base; i++)
|
for (uint32_t i = 0; i < m->num_packs + m->num_packs_in_base; i++)
|
||||||
prepare_midx_pack(r, m, i);
|
prepare_midx_pack(m, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r->objects->packed_git;
|
return r->objects->packed_git;
|
||||||
@@ -2077,7 +2077,7 @@ int find_pack_entry(struct repository *r, const struct object_id *oid, struct pa
|
|||||||
prepare_packed_git(r);
|
prepare_packed_git(r);
|
||||||
|
|
||||||
for (struct odb_source *source = r->objects->sources; source; source = source->next)
|
for (struct odb_source *source = r->objects->sources; source; source = source->next)
|
||||||
if (source->midx && fill_midx_entry(r, oid, e, source->midx))
|
if (source->midx && fill_midx_entry(source->midx, oid, e))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!r->objects->packed_git)
|
if (!r->objects->packed_git)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ static int read_midx_file(const char *object_dir, const char *checksum,
|
|||||||
for (i = 0; i < m->num_objects; i++) {
|
for (i = 0; i < m->num_objects; i++) {
|
||||||
nth_midxed_object_oid(&oid, m,
|
nth_midxed_object_oid(&oid, m,
|
||||||
i + m->num_objects_in_base);
|
i + m->num_objects_in_base);
|
||||||
fill_midx_entry(the_repository, &oid, &e, m);
|
fill_midx_entry(m, &oid, &e);
|
||||||
|
|
||||||
printf("%s %"PRIu64"\t%s\n",
|
printf("%s %"PRIu64"\t%s\n",
|
||||||
oid_to_hex(&oid), e.offset, e.p->pack_name);
|
oid_to_hex(&oid), e.offset, e.p->pack_name);
|
||||||
@@ -126,7 +126,7 @@ static int read_midx_bitmapped_packs(const char *object_dir)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i < midx->num_packs + midx->num_packs_in_base; i++) {
|
for (i = 0; i < midx->num_packs + midx->num_packs_in_base; i++) {
|
||||||
if (nth_bitmapped_pack(the_repository, midx, &pack, i) < 0) {
|
if (nth_bitmapped_pack(midx, &pack, i) < 0) {
|
||||||
close_midx(midx);
|
close_midx(midx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user