git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/6] remote: remove the_repository from some functions

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 17, 2025, 22:46 UTC
Message-ID
<xmqq7c1auguv.fsf@gitster.g>
In-Reply-To
<20250617-jk-submodule-helper-use-url-v2-3-04cbb003177d@gmail.com>
Jacob Keller <jacob.e.keller@intel.com> writes:
Show 24 quoted lines
> From: Jacob Keller <jacob.keller@gmail.com>
>
> The remotes_remote_get_1 (and its caller, remotes_remote_get, have an
> implicit dependency on the_repository due to calling
> read_branches_file() and read_remotes_file(), both of which use
> the_repository. The branch_get() function calls set_merge() which has an
> implicit dependency on the_repository as well.
>
> Because of this use of the_repository, the helper functions cannot be
> used in code paths which operate on other repositories. A future
> refactor of the submodule--helper will want to make use of some of these
> functions.
>
> Refactor to break the dependency by passing struct repository *repo
> instead of struct remote_state *remote_state in a few places.
>
> The public callers and many other helper functions still depend on
> the_repository. A repo-aware function will be exposed in a following
> change for git submodule--helper.
>
> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
> ---
>  remote.c | 58 ++++++++++++++++++++++++++++------------------------------
>  1 file changed, 28 insertions(+), 30 deletions(-)

As exactly one remote_state instance belongs to each repository ever since fd3cb050 (remote: move static variables into per-repository struct, 2021-11-17) defined the former, and remote_state is not shared across repository, passing the repository instance that owns a remote_state instance and pick up the .remote_state member out of it as needed would give us the right remote_state, and gives us access to the repository instance it owns it.

Makes perfect sense, 
Previous: Jacob KellerNext: Jacob Keller
Message 12 of 18 in “submodule: improve remote lookup logic”
  1. 0/6 submodule: improve remote lookup logicJacob Keller, Jun 17, 2025
  2. 1/6 remote: fix tear down of struct branch and struct remoteJacob Keller, Jun 17, 2025
  3. Junio C HamanoJun 17, 2025
  4. Jacob KellerJun 17, 2025
  5. Junio C HamanoJun 18, 2025
  6. Junio C HamanoJun 18, 2025
  7. Jacob KellerJun 18, 2025
  8. Lidong YanJun 18, 2025
  9. Jacob KellerJun 17, 2025
  10. 2/6 dir: move starts_with_dot(_dot)_slash to dir.hJacob Keller, Jun 17, 2025
  11. 3/6 remote: remove the_repository from some functionsJacob Keller, Jun 17, 2025
  12. Junio C HamanoJun 17, 2025
  13. Jacob KellerJun 17, 2025
  14. 4/6 submodule--helper: improve logic for fallback remote nameJacob Keller, Jun 17, 2025
  15. Junio C HamanoJun 17, 2025
  16. Jacob KellerJun 17, 2025
  17. 5/6 submodule: move get_default_remote_submodule()Jacob Keller, Jun 17, 2025
  18. 6/6 submodule: look up remotes by URL firstJacob Keller, Jun 17, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.