From: Stefan Beller Date: Fri, 23 Mar 2018 17:21:09 +0000 (+0100) Subject: sha1_file: allow prepare_alt_odb to handle arbitrary repositories X-Git-Tag: v2.18.0-rc0~144^2~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13068bf0a04c4c3cfc177f1aabc61037e319d595;p=git sha1_file: allow prepare_alt_odb to handle arbitrary repositories Signed-off-by: Stefan Beller Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- diff --git a/object-store.h b/object-store.h index 3fc461a463..f54bc0b951 100644 --- a/object-store.h +++ b/object-store.h @@ -24,8 +24,7 @@ struct alternate_object_database { */ char path[FLEX_ARRAY]; }; -#define prepare_alt_odb(r) prepare_alt_odb_##r() -void prepare_alt_odb_the_repository(void); +void prepare_alt_odb(struct repository *r); char *compute_alternate_path(const char *path, struct strbuf *err); typedef int alt_odb_fn(struct alternate_object_database *, void *); int foreach_alt_odb(alt_odb_fn, void*); diff --git a/sha1_file.c b/sha1_file.c index d38f5cdb0e..04118f331c 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -673,18 +673,15 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb) return r; } -void prepare_alt_odb_the_repository(void) +void prepare_alt_odb(struct repository *r) { - if (the_repository->objects->alt_odb_tail) + if (r->objects->alt_odb_tail) return; - the_repository->objects->alt_odb_tail = - &the_repository->objects->alt_odb_list; - link_alt_odb_entries(the_repository, - the_repository->objects->alternate_db, - PATH_SEP, NULL, 0); + r->objects->alt_odb_tail = &r->objects->alt_odb_list; + link_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0); - read_info_alternates(the_repository, get_object_directory(), 0); + read_info_alternates(r, r->objects->objectdir, 0); } /* Returns 1 if we have successfully freshened the file, 0 otherwise. */