odb: store locality in object database sources

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@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-08-11 15:46:41 +02:00
committed by Junio C Hamano
parent 70b7b03f98
commit 595bef7180
6 changed files with 18 additions and 8 deletions

1
odb.c
View File

@@ -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);