odb: get rid of the_repository when handling alternates
The functions to manage alternates all depend on `the_repository`. Refactor them to accept an object database as a parameter and adjust all callers. The functions are renamed accordingly. Note that right now the situation is still somewhat weird because we end up using the object store path provided by the object store's repository anyway. Consequently, we could have instead passed in a pointer to the repository instead of passing in the pointer to the object store. This will be addressed in subsequent commits though, where we will start to use the path owned by the object store itself. 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
1b1679c688
commit
c44185f6c1
@@ -106,7 +106,7 @@ static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)
|
||||
{
|
||||
struct odb_source *source;
|
||||
|
||||
prepare_alt_odb(the_repository);
|
||||
odb_prepare_alternates(the_repository->objects);
|
||||
for (source = the_repository->objects->sources->next; source; source = source->next) {
|
||||
if (check_and_freshen_odb(source, oid, freshen))
|
||||
return 1;
|
||||
@@ -205,7 +205,7 @@ static int stat_loose_object(struct repository *r, const struct object_id *oid,
|
||||
struct odb_source *source;
|
||||
static struct strbuf buf = STRBUF_INIT;
|
||||
|
||||
prepare_alt_odb(r);
|
||||
odb_prepare_alternates(r->objects);
|
||||
for (source = r->objects->sources; source; source = source->next) {
|
||||
*path = odb_loose_path(source, &buf, oid);
|
||||
if (!lstat(*path, st))
|
||||
@@ -227,7 +227,7 @@ static int open_loose_object(struct repository *r,
|
||||
int most_interesting_errno = ENOENT;
|
||||
static struct strbuf buf = STRBUF_INIT;
|
||||
|
||||
prepare_alt_odb(r);
|
||||
odb_prepare_alternates(r->objects);
|
||||
for (source = r->objects->sources; source; source = source->next) {
|
||||
*path = odb_loose_path(source, &buf, oid);
|
||||
fd = git_open(*path);
|
||||
@@ -246,7 +246,7 @@ static int quick_has_loose(struct repository *r,
|
||||
{
|
||||
struct odb_source *source;
|
||||
|
||||
prepare_alt_odb(r);
|
||||
odb_prepare_alternates(r->objects);
|
||||
for (source = r->objects->sources; source; source = source->next) {
|
||||
if (oidtree_contains(odb_loose_cache(source, oid), oid))
|
||||
return 1;
|
||||
@@ -1439,7 +1439,7 @@ int for_each_loose_object(each_loose_object_fn cb, void *data,
|
||||
{
|
||||
struct odb_source *source;
|
||||
|
||||
prepare_alt_odb(the_repository);
|
||||
odb_prepare_alternates(the_repository->objects);
|
||||
for (source = the_repository->objects->sources; source; source = source->next) {
|
||||
int r = for_each_loose_file_in_objdir(source->path, cb, NULL,
|
||||
NULL, data);
|
||||
|
||||
Reference in New Issue
Block a user