Skip to content

remote: replace static variables with struct remote_state

Glen Choo via GitGitGadget git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2remote: move static variables into structremote.c+63 -461 reply
2/2remote: add remote_state to struct repositoryremote.c remote.h repository.c +1 more+184 -832 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

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

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 protected]/

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

Signature · 1 line
gitgitgadget