summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Jonathan Nieder <jrnieder@gmail.com>2013-10-14 11:06:57 -0700
committerLibravatar Jonathan Nieder <jrnieder@gmail.com>2013-10-14 11:06:57 -0700
commitcabb411fcf6a0a0f5058f2fee0f628e9a16a6fcb (patch)
tree765637b99a2226314e7680126e97daf766c7f1ba
parentMerge branch 'jx/clean-interactive' (diff)
parentclone: tighten "local paths with colons" check a bit (diff)
downloadtgif-cabb411fcf6a0a0f5058f2fee0f628e9a16a6fcb.tar.xz
Merge branch 'nd/clone-local-with-colon'
* nd/clone-local-with-colon: clone: tighten "local paths with colons" check a bit
-rw-r--r--connect.c2
-rwxr-xr-xt/t5601-clone.sh46
2 files changed, 46 insertions, 2 deletions
diff --git a/connect.c b/connect.c
index a80ebd316c..40868610ab 100644
--- a/connect.c
+++ b/connect.c
@@ -552,7 +552,7 @@ 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 == ':') {
- if (path < strchrnul(host, '/')) {
+ if (host != url || path < strchrnul(host, '/')) {
protocol = PROTO_SSH;
*path++ = '\0';
} else /* '/' in the host part, assume local path */
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 0629149edd..a3e3d489ec 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -280,9 +280,53 @@ test_expect_success 'clone checking out a tag' '
test_cmp fetch.expected fetch.actual
'
+test_expect_success 'setup ssh wrapper' '
+ write_script "$TRASH_DIRECTORY/ssh-wrapper" <<-\EOF &&
+ echo >>"$TRASH_DIRECTORY/ssh-output" "ssh: $*" &&
+ # throw away all but the last argument, which should be the
+ # command
+ while test $# -gt 1; do shift; done
+ eval "$1"
+ EOF
+
+ GIT_SSH="$TRASH_DIRECTORY/ssh-wrapper" &&
+ export GIT_SSH &&
+ export TRASH_DIRECTORY
+'
+
+clear_ssh () {
+ >"$TRASH_DIRECTORY/ssh-output"
+}
+
+expect_ssh () {
+ {
+ case "$1" in
+ none)
+ ;;
+ *)
+ echo "ssh: $1 git-upload-pack '$2'"
+ esac
+ } >"$TRASH_DIRECTORY/ssh-expect" &&
+ (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
+}
+
+test_expect_success 'cloning myhost:src uses ssh' '
+ clear_ssh &&
+ git clone myhost:src ssh-clone &&
+ expect_ssh myhost src
+'
+
test_expect_success NOT_MINGW,NOT_CYGWIN 'clone local path foo:bar' '
+ clear_ssh &&
cp -R src "foo:bar" &&
- git clone "./foo:bar" foobar
+ git clone "./foo:bar" foobar &&
+ expect_ssh none
+'
+
+test_expect_success 'bracketed hostnames are still ssh' '
+ clear_ssh &&
+ git clone "[myhost:123]:src" ssh-bracket-clone &&
+ expect_ssh myhost:123 src
'
test_done