From fd3cb0501e175bcac042587cb7bb75e16034a5b7 Mon Sep 17 00:00:00 2001 From: Glen Choo Date: Wed, 17 Nov 2021 16:53:22 -0800 Subject: remote: move static variables into per-repository struct remote.c does not works with non-the_repository because it stores its state as static variables. To support non-the_repository, we can use a per-repository struct for the remotes subsystem. Prepare for this change by defining a struct remote_state that holds the remotes subsystem state and move the static variables of remote.c into the_repository->remote_state. This introduces no behavioral or API changes. Signed-off-by: Glen Choo Reviewed-by: Jonathan Tan Signed-off-by: Junio C Hamano --- repository.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'repository.c') diff --git a/repository.c b/repository.c index c5b90ba93e..c7ea706c20 100644 --- a/repository.c +++ b/repository.c @@ -9,6 +9,7 @@ #include "config.h" #include "object.h" #include "lockfile.h" +#include "remote.h" #include "submodule-config.h" #include "sparse-index.h" #include "promisor-remote.h" @@ -24,6 +25,7 @@ void initialize_the_repository(void) the_repo.index = &the_index; the_repo.objects = raw_object_store_new(); + the_repo.remote_state = remote_state_new(); the_repo.parsed_objects = parsed_object_pool_new(); repo_set_hash_algo(&the_repo, GIT_HASH_SHA1); @@ -164,6 +166,7 @@ int repo_init(struct repository *repo, repo->objects = raw_object_store_new(); repo->parsed_objects = parsed_object_pool_new(); + repo->remote_state = remote_state_new(); if (repo_init_gitdir(repo, gitdir)) goto error; @@ -270,6 +273,11 @@ void repo_clear(struct repository *repo) promisor_remote_clear(repo->promisor_remote_config); FREE_AND_NULL(repo->promisor_remote_config); } + + if (repo->remote_state) { + remote_state_clear(repo->remote_state); + FREE_AND_NULL(repo->remote_state); + } } int repo_read_index(struct repository *repo) -- cgit v1.2.3