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

[PATCH v2 5/6] submodule: move get_default_remote_submodule()

From
Jacob Keller <jacob.e.keller@intel.com>
Date
Jun 17, 2025, 21:30 UTC
Message-ID
<20250617-jk-submodule-helper-use-url-v2-5-04cbb003177d@gmail.com>
In-Reply-To
<20250617-jk-submodule-helper-use-url-v2-0-04cbb003177d@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
Previous: Jacob KellerNext: Jacob Keller
Message 17 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.