Patrick Steinhardt <ps@xxxxxx> writes: > Object database sources are classified either as: > > - Local, which means that the source is the repository's primary > source. This is typically ".git/objects". > > - Non-local, which is everything else. Most importantly this includes > alternates and quarantine directories. > > This locality is often computed ad-hoc by checking whether a given > object source is the first one. This works, but it is quite roundabout. > > Refactor the code so that we store locality when creating the sources in > the first place. This makes it both more accessible and robust. > > Signed-off-by: Patrick Steinhardt <ps@xxxxxx> > --- > midx.c | 5 +++-- > midx.h | 2 +- > odb.c | 1 + > odb.h | 8 ++++++++ > packfile.c | 9 ++++----- > repository.c | 1 + > 6 files changed, 18 insertions(+), 8 deletions(-) > > diff --git a/midx.c b/midx.c > index 7d407682e6..b9ca0915a6 100644 > --- a/midx.c > +++ b/midx.c > @@ -723,7 +723,7 @@ int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id) > return 0; > } > > -int prepare_multi_pack_index_one(struct odb_source *source, int local) > +int prepare_multi_pack_index_one(struct odb_source *source) > { > struct repository *r = source->odb->repo; > > @@ -734,7 +734,8 @@ int prepare_multi_pack_index_one(struct odb_source *source, int local) > if (source->midx) > return 1; > > - source->midx = load_multi_pack_index(r, source->path, local); > + source->midx = load_multi_pack_index(r, source->path, > + source->local); > > return !!source->midx; > } > diff --git a/midx.h b/midx.h > index 076382de8a..28c426a823 100644 > --- a/midx.h > +++ b/midx.h > @@ -122,7 +122,7 @@ int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pa > int midx_contains_pack(struct multi_pack_index *m, > const char *idx_or_pack_name); > int midx_preferred_pack(struct multi_pack_index *m, uint32_t *pack_int_id); > -int prepare_multi_pack_index_one(struct odb_source *source, int local); > +int prepare_multi_pack_index_one(struct odb_source *source); > > /* > * Variant of write_midx_file which writes a MIDX containing only the packs > diff --git a/odb.c b/odb.c > index 1f48a0448e..1761a50840 100644 > --- a/odb.c > +++ b/odb.c > @@ -176,6 +176,7 @@ static int link_alt_odb_entry(struct object_database *odb, > > CALLOC_ARRAY(alternate, 1); > alternate->odb = odb; > + alternate->local = false; > /* pathbuf.buf is already in r->objects->source_by_path */ > alternate->path = strbuf_detach(&pathbuf, NULL); > > diff --git a/odb.h b/odb.h > index 09177bf430..d9f4dcf79f 100644 > --- a/odb.h > +++ b/odb.h > @@ -63,6 +63,14 @@ struct odb_source { > */ > struct multi_pack_index *midx; > > + /* > + * Figure out whether this is the local alternate of the owning Do we still use "alternate" in this context? Shouldn't it be "source"? -- Cheers, Toon