From b4bee06a2de5d74f9b1de64ffbb464e235a3194a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dato=20Sim=C3=B3?= <dato@net.com.org.es>
Date: Mon, 23 Sep 2013 22:13:54 +0100
Subject: [PATCH] vcsh: strip host part from GIT_REMOTE when inferring
 VCSH_REPO_NAME
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

`vcsh clone` does:

    VCSH_REPO_NAME=$(basename "${GIT_REMOTE}" .git)

Typically, most remote paths will have a non-empty directory component,
so using basename works well in all common cases. However, when doing
something like:

    % vcsh clone example.org:repo.git

VCSH_REPO_NAME will be set to "example.org:repo" instead of "repo". This
also happens when using url.<x>.insteadOf, à-la:

    % vcsh clone v:repo

Stripping everything up to the first colon in the remote URL fixes the
issue.

N.B.: remote URLs with protocol (e.g. http://, git://, or ssh://) do
not exhibit this problem, and are unaffected by this change.

Conflicts:
	vcsh
---
 vcsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vcsh b/vcsh
index 5d502e7..5d5628e 100755
--- a/vcsh
+++ b/vcsh
@@ -416,7 +416,7 @@ esac
 if [ "$VCSH_COMMAND" = 'clone' ]; then
 	[ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a remote" 1
 	GIT_REMOTE="$2"
-	[ -n "$3" ] && VCSH_REPO_NAME="$3" || VCSH_REPO_NAME=$(basename "$GIT_REMOTE" .git)
+	[ -n "$3" ] && VCSH_REPO_NAME="$3" || VCSH_REPO_NAME=$(basename "${GIT_REMOTE#*:}" .git)
 	[ -z "$VCSH_REPO_NAME" ] && fatal "$VCSH_COMMAND: could not determine repository name" 1
 	export VCSH_REPO_NAME
 	export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git"
-- 
GitLab