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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 20, 2008, 04:07 UTC
Message-ID
<7vpro4tjkw.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1219198703-2388-1-git-send-email-mlevedahl@gmail.com>
Mark Levedahl <mlevedahl@gmail.com> writes:
Show 24 quoted lines
> 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. Regardless of whether git is changed to remove the
> trailing / before recording the URL, we should avoid this issue in
> submodule as existing repositories can have this problem.
>
> Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
> ---
>  git-submodule.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/git-submodule.sh b/git-submodule.sh
> index ea6357b..fa9dd3a 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -34,7 +34,7 @@ resolve_relative_url ()
>  	remote=$(get_default_remote)
>  	remoteurl=$(git config "remote.$remote.url") ||
>  		die "remote ($remote) does not have a url in .git/config"
> -	url="$1"
> +	url="${1%/}"
>  	while test -n "$url"
>  	do
>  		case "$url" in
Hmm, the case arms outside the context looks like this:
	while test -n "$url"
	do
		case "$url" in
		../*)
			url="${url#../}"
			remoteurl="${remoteurl%/*}"
			;;
		./*)
			url="${url#./}"
			;;
		*)
			break;;
		esac
	done
	echo "$remoteurl/$url"

If you call "resolve_relative_url ../", the first arm used to fire once and stripped one level away, but with your patch it does not do so anymore, and returns "$remoteurl/.." instead?

I know you are primarily interested in making sure that "../foo" and "../foo/" are handled the same way, but somehow this change does not feel right. How about stripping the trailing slash from the end result?

Previous: Mark LevedahlNext: Mark Levedahl
Message 2 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.