All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: git@vger.kernel.org,  Jacob Keller <jacob.keller@gmail.com>,
	 Lidong Yan <yldhome2d2@gmail.com>,
	 Patrick Steinhardt <ps@pks.im>
Subject: Re: [PATCH v2 3/6] remote: remove the_repository from some functions
Date: Tue, 17 Jun 2025 15:46:00 -0700	[thread overview]
Message-ID: <xmqq7c1auguv.fsf@gitster.g> (raw)
In-Reply-To: <20250617-jk-submodule-helper-use-url-v2-3-04cbb003177d@gmail.com> (Jacob Keller's message of "Tue, 17 Jun 2025 14:30:43 -0700")

Jacob Keller <jacob.e.keller@intel.com> writes:

> 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, 

  reply	other threads:[~2025-06-17 22:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-17 21:30 [PATCH v2 0/6] submodule: improve remote lookup logic Jacob Keller
2025-06-17 21:30 ` [PATCH v2 1/6] remote: fix tear down of struct branch and struct remote Jacob Keller
2025-06-17 22:25   ` Junio C Hamano
2025-06-17 23:25     ` Jacob Keller
2025-06-18  1:30       ` Junio C Hamano
2025-06-18 11:20         ` Junio C Hamano
2025-06-18 17:41           ` Jacob Keller
2025-06-18  2:44       ` Lidong Yan
2025-06-17 23:45     ` Jacob Keller
2025-06-17 21:30 ` [PATCH v2 2/6] dir: move starts_with_dot(_dot)_slash to dir.h Jacob Keller
2025-06-17 21:30 ` [PATCH v2 3/6] remote: remove the_repository from some functions Jacob Keller
2025-06-17 22:46   ` Junio C Hamano [this message]
2025-06-17 23:19     ` Jacob Keller
2025-06-17 21:30 ` [PATCH v2 4/6] submodule--helper: improve logic for fallback remote name Jacob Keller
2025-06-17 23:12   ` Junio C Hamano
2025-06-17 23:21     ` Jacob Keller
2025-06-17 21:30 ` [PATCH v2 5/6] submodule: move get_default_remote_submodule() Jacob Keller
2025-06-17 21:30 ` [PATCH v2 6/6] submodule: look up remotes by URL first Jacob Keller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq7c1auguv.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jacob.keller@gmail.com \
    --cc=ps@pks.im \
    --cc=yldhome2d2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.