mbox series

[v1,0/3] make create_branch() accept any repository

Message ID 20211111171643.13805-1-chooglen@google.com (mailing list archive)
Headers show
Series make create_branch() accept any repository | expand

Message

Glen Choo Nov. 11, 2021, 5:16 p.m. UTC
create_branch() accepts a struct repository parameter, which seems to
suggest that it works with any repository, but it actually only works
with the_repository. This series aims to fix this discrepancy.

This series depends on gc/remote-with-fewer-static-global-variables [1]
because setup_tracking() needs tracking information from
repositories other than the_repository.

Note that this fix is not as clean as "just replace the problematic
functions with an equivalent that doesn't use the_repository".

* git_config_set() uses the_repository deep in its call chain. Patch 2
  adds an alternative implementation instead of trying to fix the entire
  call chain.
* We cannot check if a non-the_repository is bare (yet). In patch 3,
  just die instead of trying to perform this check.

While this series isn't perfect, I think it is close enough to an
"ideal" removal of the_repository that it is ready for review. My hope
is to use this series to implement "git branch --recurse-submodules"
in-process. If this series doesn't pass review, I'll implement the
feature with child processes instead.

[1] https://lore.kernel.org/git/20211028183101.41013-1-chooglen@google.com/

Glen Choo (3):
  refs/files-backend: remove the_repository
  config: introduce repo_config_set* functions
  branch: remove implicit the_repository from create_branch()

 branch.c             | 69 ++++++++++++++++++++++++++++++--------------
 branch.h             |  9 ++++--
 builtin/branch.c     |  5 ++--
 builtin/checkout.c   |  7 +++--
 config.c             | 24 +++++++++++++++
 config.h             | 11 +++++++
 refs/files-backend.c | 20 +++++++------
 7 files changed, 107 insertions(+), 38 deletions(-)