packfile: pass down repository to for_each_packed_object
The function `for_each_packed_object` currently relies on the global variable `the_repository`. To eliminate global variable usage in `packfile.c`, we should progressively shift the dependency on the_repository to higher layers. Let's remove its usage from this function and closely related function `is_promisor_object`. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
cc656f4eb2
commit
c87910b96b
14
packfile.c
14
packfile.c
@ -2200,15 +2200,15 @@ int for_each_object_in_pack(struct packed_git *p,
|
||||
return r;
|
||||
}
|
||||
|
||||
int for_each_packed_object(each_packed_object_fn cb, void *data,
|
||||
enum for_each_object_flags flags)
|
||||
int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
|
||||
void *data, enum for_each_object_flags flags)
|
||||
{
|
||||
struct packed_git *p;
|
||||
int r = 0;
|
||||
int pack_errors = 0;
|
||||
|
||||
prepare_packed_git(the_repository);
|
||||
for (p = get_all_packs(the_repository); p; p = p->next) {
|
||||
prepare_packed_git(repo);
|
||||
for (p = get_all_packs(repo); p; p = p->next) {
|
||||
if ((flags & FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
|
||||
continue;
|
||||
if ((flags & FOR_EACH_OBJECT_PROMISOR_ONLY) &&
|
||||
@ -2286,14 +2286,14 @@ static int add_promisor_object(const struct object_id *oid,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_promisor_object(const struct object_id *oid)
|
||||
int is_promisor_object(struct repository *r, const struct object_id *oid)
|
||||
{
|
||||
static struct oidset promisor_objects;
|
||||
static int promisor_objects_prepared;
|
||||
|
||||
if (!promisor_objects_prepared) {
|
||||
if (repo_has_promisor_remote(the_repository)) {
|
||||
for_each_packed_object(add_promisor_object,
|
||||
if (repo_has_promisor_remote(r)) {
|
||||
for_each_packed_object(r, add_promisor_object,
|
||||
&promisor_objects,
|
||||
FOR_EACH_OBJECT_PROMISOR_ONLY |
|
||||
FOR_EACH_OBJECT_PACK_ORDER);
|
||||
|
Reference in New Issue
Block a user