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

[PATCH] git-submodule - Use "get_default_remote" from git-parse-remote

From
Mark Levedahl <mlevedahl@gmail.com>
Date
Aug 24, 2008, 18:46 UTC
Message-ID
<1219603570-516-1-git-send-email-mlevedahl@gmail.com>
In-Reply-To
<e21617f50ffaae98ab73fa364e40440397bcbe33.1219598198.git.davvid@gmail.com>

Resolve_relative_url was using its own code for this function, but this is duplication with the best result that this continues to work. Replace with the common function provided by git-parse-remote.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
---

I think it makes more sense to use the facility provided elsewhere rather than duplicate. (I've had this patch in my tree for quite a while, never really had a reason to submit it.)

 git-submodule.sh |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 2a3a197..59fe7b3 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -9,6 +9,7 @@ USAGE="[--quiet] [--cached] \
 [--] [<path>...]|[foreach <command>]"
 OPTIONS_SPEC=
 . git-sh-setup
+. git-parse-remote
 require_work_tree

 command=
@@ -30,9 +31,7 @@ say()
 # Resolve relative url by appending to parent's url
 resolve_relative_url ()
 {
-	branch="$(git symbolic-ref HEAD 2>/dev/null)"
-	remote="$(git config branch.${branch#refs/heads/}.remote)"
-	remote="${remote:-origin}"
+	remote=$(get_default_remote)
 	remoteurl=$(git config "remote.$remote.url") ||
 		die "remote ($remote) does not have a url defined in .git/config"
 	url="$1"
--
1.6.0.127.gf1d7c
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 14 in “git-submodule: add "sync" command (v2)”
  1. David AguilarAug 24, 2008
  2. 1/3 git-submodule: add a get_remote functionDavid Aguilar, Aug 24, 2008
  3. 2/3 git-submodule: use get_remote in resolve_relative_urlDavid Aguilar, Aug 24, 2008
  4. 3/3 git-submodule: add "sync" commandDavid Aguilar, Aug 24, 2008
  5. Junio C HamanoAug 24, 2008
  6. David AguilarAug 24, 2008
  7. git-submodule: add "sync" commandDavid Aguilar, Aug 24, 2008
  8. David AguilarAug 27, 2008
  9. Junio C HamanoAug 27, 2008
  10. Mark LevedahlAug 24, 2008
  11. Junio C HamanoAug 24, 2008
  12. Junio C HamanoAug 24, 2008
  13. git-submodule - Use "get_default_remote" from git-parse-remoteMark Levedahl, Aug 24, 2008
  14. Junio C HamanoAug 24, 2008

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.