aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-06-02 15:52:22 -0700
committerJunio C Hamano <gitster@pobox.com>2013-06-02 15:52:22 -0700
commit41aaccdcf9170e744e423f2b1f889ada6604ae38 (patch)
treeb785562c2face9c4b2523779525d186d0cbe368c
parentdbbc93b221c6ee9cb2d417a43078b0d2a986fd33 (diff)
parent60003340cda05f5ecd79ee8522b21eda038b994b (diff)
downloadgit-41aaccdcf9170e744e423f2b1f889ada6604ae38.tar.gz
git-41aaccdcf9170e744e423f2b1f889ada6604ae38.tar.xz
Merge branch 'nd/clone-local-with-colon'
"git clone foo/bar:baz" cannot be a request to clone from a remote over git-over-ssh specified in the scp style. Detect this case and clone from a local repository at "foo/bar:baz". * nd/clone-local-with-colon: clone: allow cloning local paths with colons in them
-rw-r--r--Documentation/urls.txt6
-rw-r--r--builtin/clone.c2
-rw-r--r--connect.c7
-rwxr-xr-xt/t5601-clone.sh5
4 files changed, 18 insertions, 2 deletions
diff --git a/Documentation/urls.txt b/Documentation/urls.txt
index 3ca122fae..476e3381c 100644
--- a/Documentation/urls.txt
+++ b/Documentation/urls.txt
@@ -23,6 +23,12 @@ An alternative scp-like syntax may also be used with the ssh protocol:
- {startsb}user@{endsb}host.xz:path/to/repo.git/
+This syntax is only recognized if there are no slashes before the
+first colon. This helps differentiate a local path that contains a
+colon. For example the local path `foo:bar` could be specified as an
+absolute path or `./foo:bar` to avoid being misinterpreted as an ssh
+url.
+
The ssh and git protocols additionally support ~username expansion:
- ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/~{startsb}user{endsb}/path/to/repo.git/
diff --git a/builtin/clone.c b/builtin/clone.c
index 5e70696d8..b6ffc6b4f 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -782,6 +782,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
is_local = option_local != 0 && path && !is_bundle;
if (is_local && option_depth)
warning(_("--depth is ignored in local clones; use file:// instead."));
+ if (option_local > 0 && !is_local)
+ warning(_("--local is ignored"));
if (argc == 2)
dir = xstrdup(argv[1]);
diff --git a/connect.c b/connect.c
index f57efd06c..a0783d486 100644
--- a/connect.c
+++ b/connect.c
@@ -551,8 +551,11 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
path = strchr(end, c);
if (path && !has_dos_drive_prefix(end)) {
if (c == ':') {
- protocol = PROTO_SSH;
- *path++ = '\0';
+ if (path < strchrnul(host, '/')) {
+ protocol = PROTO_SSH;
+ *path++ = '\0';
+ } else /* '/' in the host part, assume local path */
+ path = end;
}
} else
path = end;
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 67869b481..0629149ed 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -280,4 +280,9 @@ test_expect_success 'clone checking out a tag' '
test_cmp fetch.expected fetch.actual
'
+test_expect_success NOT_MINGW,NOT_CYGWIN 'clone local path foo:bar' '
+ cp -R src "foo:bar" &&
+ git clone "./foo:bar" foobar
+'
+
test_done