git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: git@vger.kernel.org
Cc: Jacob Keller <jacob.keller@gmail.com>,
	 Lidong Yan <yldhome2d2@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	 Patrick Steinhardt <ps@pks.im>
Subject: [PATCH v3 6/7] submodule: move get_default_remote_submodule()
Date: Wed, 18 Jun 2025 16:08:20 -0700	[thread overview]
Message-ID: <20250618-jk-submodule-helper-use-url-v3-6-7c60f2679271@gmail.com> (raw)
In-Reply-To: <20250618-jk-submodule-helper-use-url-v3-0-7c60f2679271@gmail.com>

From: Jacob Keller <jacob.keller@gmail.com>

A future refactor got get_default_remote_submodule() is going to depend on
resolve_relative_url(). That function depends on get_default_remote().

Move get_default_remote_submodule() after resolve_relative_url() first
to make the additional functionality easier to review.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---
 builtin/submodule--helper.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 4aa237033a526fca29cce2926419462179d40ee3..1aa87435c2000e94f43da94c5ef88a307f6f3f4a 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -41,22 +41,6 @@
 typedef void (*each_submodule_fn)(const struct cache_entry *list_item,
 				  void *cb_data);
 
-static int get_default_remote_submodule(const char *module_path, char **default_remote)
-{
-	struct repository subrepo;
-
-	if (repo_submodule_init(&subrepo, the_repository, module_path,
-				null_oid(the_hash_algo)) < 0)
-		return die_message(_("could not get a repository handle for submodule '%s'"),
-				   module_path);
-
-	*default_remote = xstrdup(repo_default_remote(&subrepo));
-
-	repo_clear(&subrepo);
-
-	return 0;
-}
-
 static char *get_default_remote(void)
 {
 	return xstrdup(repo_default_remote(the_repository));
@@ -86,6 +70,22 @@ static char *resolve_relative_url(const char *rel_url, const char *up_path, int
 	return resolved_url;
 }
 
+static int get_default_remote_submodule(const char *module_path, char **default_remote)
+{
+	struct repository subrepo;
+
+	if (repo_submodule_init(&subrepo, the_repository, module_path,
+				null_oid(the_hash_algo)) < 0)
+		return die_message(_("could not get a repository handle for submodule '%s'"),
+				   module_path);
+
+	*default_remote = xstrdup(repo_default_remote(&subrepo));
+
+	repo_clear(&subrepo);
+
+	return 0;
+}
+
 /* the result should be freed by the caller. */
 static char *get_submodule_displaypath(const char *path, const char *prefix,
 				       const char *super_prefix)

-- 
2.48.1.397.gec9d649cc640


  parent reply	other threads:[~2025-06-18 23:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18 23:08 [PATCH v3 0/7] submodule: improve remote lookup logic Jacob Keller
2025-06-18 23:08 ` [PATCH v3 1/7] remote: remove branch->merge_name and fix branch_release() Jacob Keller
2025-06-20 23:36   ` Junio C Hamano
2025-06-21  2:12     ` Lidong Yan
2025-06-23 23:06       ` Jacob Keller
2025-06-18 23:08 ` [PATCH v3 2/7] remote: fix tear down of struct remote Jacob Keller
2025-06-18 23:08 ` [PATCH v3 3/7] dir: move starts_with_dot(_dot)_slash to dir.h Jacob Keller
2025-06-18 23:08 ` [PATCH v3 4/7] remote: remove the_repository from some functions Jacob Keller
2025-06-18 23:08 ` [PATCH v3 5/7] submodule--helper: improve logic for fallback remote name Jacob Keller
2025-06-18 23:08 ` Jacob Keller [this message]
2025-06-18 23:08 ` [PATCH v3 7/7] submodule: look up remotes by URL first Jacob Keller
2025-06-18 23:33 ` [PATCH v3 0/7] submodule: improve remote lookup logic Junio C Hamano

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=20250618-jk-submodule-helper-use-url-v3-6-7c60f2679271@gmail.com \
    --to=jacob.e.keller@intel.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).