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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx:repo.git", git would try to
clone the submodule from "git@xxxxxxxxxxx: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@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]