Subject: [PATCH 0/2] remote: replace static variables with struct remote_state

From: "Glen Choo via GitGitGadget" <[email-masked]>
Date: Thu, 07 Oct 2021 19:07:13 +0000

This series aims to make the remotes subsystem work with non-the_repository,
which will allow submodule remotes to be accessed in-process, rather than
through child processes. This is accomplished by creating a struct
remote_state and adding it to struct repository.

One motivation for this is that it allows future submodule commands to run
in-process. An example is an RFC series of mine [1], where I tried to
implement "git branch --recurse-submodules" in-process but couldn't figure
out how to read the remotes of a submodule.

For the most part, this was a mechanical process of taking static variables
and putting them in a struct. As such, I think this series might benefit
from thoughtful review, especially from people with more insight into this
area. Some areas I am extra concerned about are:

 * Naming, especially the renaming of variables in patch 1 and the field
   names in patch 2. I don't really like the name "remote_state", but I
   can't think of a better one.
 * Memory leaks - I am not confident that remote_state_clear() frees all of
   the memory that it should. I tried to eliminate as many leaks as I could
   with "make SANITIZE=address,leak", but I'm not confident that I've caught
   them all.

[1] https://lore.kernel.org/git/[email-masked]/

Glen Choo (2):
  remote: move static variables into struct
  remote: add remote_state to struct repository

 remote.c     | 245 ++++++++++++++++++++++++++++++---------------------
 remote.h     |  69 +++++++++++++--
 repository.c |   8 ++
 repository.h |   4 +
 4 files changed, 222 insertions(+), 104 deletions(-)

base-commit: 0785eb769886ae81e346df10e88bc49ffc0ac64e
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1103%2Fchooglen%2Fremote%2Fstruct-no-global-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1103/chooglen/remote/struct-no-global-v1
Pull-Request: https://github.com/git/git/pull/1103
-- 
gitgitgadget