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

[PATCH] git-submodule.sh - Remove trailing / from URL if found

From
Mark Levedahl <mlevedahl@gmail.com>
Date
Aug 21, 2008, 01:07 UTC
Message-ID
<1219280847-872-1-git-send-email-mlevedahl@gmail.com>
In-Reply-To
<7vpro4tjkw.fsf@gitster.siamese.dyndns.org>

git clone does not complain if a trailing '/' is included in the origin URL, but doing so causes resolution of a submodule's URL relative to the superproject to fail. Trailing /'s are likely when cloning locally using tab-completion, so the slash may appear in either superproject or submodule URL. So, ignore the trailing slash if it already exists in the superproject's URL, and don't record one for the submodule (which could itself have submodules...).

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
---
 git-submodule.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index b40f876..e576cd2 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -36,6 +36,7 @@ resolve_relative_url ()
 	remoteurl=$(git config "remote.$remote.url") ||
 		die "remote ($remote) does not have a url defined in .git/config"
 	url="$1"
+	remoteurl=${remoteurl%/}
 	while test -n "$url"
 	do
 		case "$url" in
@@ -50,7 +51,7 @@ resolve_relative_url ()
 			break;;
 		esac
 	done
-	echo "$remoteurl/$url"
+	echo "$remoteurl"/"${url%/}"
 }
 
 #
-- 
1.6.0.22.g2957
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 7 in “git-submodule.sh - Remove trailing / from URL if found”
  1. git-submodule.sh - Remove trailing / from URL if foundMark Levedahl, Aug 20, 2008
  2. Junio C HamanoAug 20, 2008
  3. git-submodule.sh - Remove trailing / from URL if foundMark Levedahl, Aug 21, 2008
  4. Junio C HamanoAug 21, 2008
  5. Mark LevedahlAug 21, 2008
  6. Junio C HamanoAug 21, 2008
  7. git-submodule.sh - Remove trailing / from URL if foundMark Levedahl, Aug 21, 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.