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

[PATCH 1/1] git-submodule.sh: fix relative paths with ssh urls

From
RYRussell Yanofsky <russ@yanofsky.org>
Date
Dec 3, 2010, 02:53 UTC
Message-ID
<1291344821-20964-1-git-send-email-russ@yanofsky.org>
Fix handling of submodule urls starting with ../ when the remote url is
an scp-style URL with the format user@host.xz:repo.git. For example, if
the remote url is user@host.xz:repo.git and the submodule URL is
../submodule.git, the combined default URL will now be
user@host.xz:submodule.git instead of
user@host.xz:repo.git/submodule.git.
---
 git-submodule.sh |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index c291eed..533cf5d 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -36,13 +36,25 @@ resolve_relative_url ()
 	remoteurl=$(git config "remote.$remote.url") ||
 		die "remote ($remote) does not have a url defined in .git/config"
 	url="$1"
+	sep="/"
 	remoteurl=${remoteurl%/}
 	while test -n "$url"
 	do
 		case "$url" in
 		../*)
 			url="${url#../}"
-			remoteurl="${remoteurl%/*}"
+			remoteparent="${remoteurl%/*}"
+			if test "$remoteparent" != "$remoteurl"
+			then
+				remoteurl="$remoteparent"
+			else
+				remoteparent="${remoteurl%:*}"
+				if test "$remoteparent" != "$remoteurl"
+				then
+					remoteurl="$remoteparent"
+					sep=":"
+				fi
+			fi
 			;;
 		./*)
 			url="${url#./}"
@@ -51,7 +63,7 @@ resolve_relative_url ()
 			break;;
 		esac
 	done
-	echo "$remoteurl/${url%/}"
+	echo "$remoteurl$sep${url%/}"
 }
 
 #
-- 
1.7.3.2
Message 1 of 1 in “git-submodule.sh: fix relative paths with ssh urls”
  1. 1/1 git-submodule.sh: fix relative paths with ssh urlsRussell Yanofsky, Dec 3, 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.