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

[PATCH] submodule: Improve handling of relative submodule URLs.

From
Jacob Helwig <jacob.helwig@gmail.com>
Date
Feb 25, 2010, 19:28 UTC
Message-ID
<1267126109-14638-1-git-send-email-jacob.helwig@gmail.com>

Relative URLs only worked with <proto>://<host>/<location> style URLs, and would break when cloning a repository using <user>@<host>:<location> (scp) style "URL"s.

When a submodule's URL was set to "../submodule.git", and the repository using it was cloned from "git@example.com:repo.git", git would try to clone the submodule from "git@example.com:repo.git/submodule.git", which would not likely work.

This updates resolve_relative_url to handle the scp style URLs.
Signed-off-by: Jacob Helwig <jacob.helwig@gmail.com>
---
 git-submodule.sh |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 664f217..97787a3 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -37,18 +37,19 @@ resolve_relative_url ()
 	while test -n "$url"
 	do
 		case "$url" in
-		../*)
+		..[/:]*)
 			url="${url#../}"
-			remoteurl="${remoteurl%/*}"
+			remoteurl="$(echo "$remoteurl" | sed -e 's|\(.*[/:]\).*|\1|')"
 			;;
-		./*)
+		.[/:]*)
 			url="${url#./}"
+			remoteurl="$remoteurl/"
 			;;
 		*)
 			break;;
 		esac
 	done
-	echo "$remoteurl/${url%/}"
+	echo "$remoteurl${url#[/:]}"
 }
 
 #
-- 
1.7.0.91.g310a
Next: Mark Levedahl
Message 1 of 2 in “submodule: Improve handling of relative submodule URLs.”
  1. submodule: Improve handling of relative submodule URLs.Jacob Helwig, Feb 25, 2010
  2. Mark LevedahlFeb 26, 2010

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.