From: "Torsten Bögershausen" <tboegi@web.de>
To: "Torsten Bögershausen" <tboegi@web.de>,
"Jeff King" <peff@peff.net>, "Duy Nguyen" <pclouds@gmail.com>,
"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] clone: local URLs are not for ssh
Date: Sun, 13 Oct 2013 22:00:12 +0200 [thread overview]
Message-ID: <525AFBCC.4080303@web.de> (raw)
In-Reply-To: <52506D15.9040206@web.de>
On 05.10.13 21:48, Torsten Bögershausen wrote:
> On 2013-10-03 03.31, Jeff King wrote:
>>
>> http://article.gmane.org/gmane.comp.version-control.git/235473
What do we think about extending the test a little bit:
git diff 771cf1dab9303bab3c8198b8b6 -- t5602-clone-remote-exec.sh
diff --git a/t/t5602-clone-remote-exec.sh b/t/t5602-clone-remote-exec.sh
index 3f353d9..790896f 100755
--- a/t/t5602-clone-remote-exec.sh
+++ b/t/t5602-clone-remote-exec.sh
@@ -30,5 +30,124 @@ test_expect_success 'clone calls specified git upload-pack with -u option' '
echo "localhost ./something/bin/git-upload-pack '\''/path/to/repo'\''" >expected &&
test_cmp expected not_ssh_output
'
+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 'create src.git' '
+ mkdir src.git &&
+ (
+ cd src.git &&
+ git init &&
+ >file &&
+ git add file &&
+ git commit -m "add file"
+ )
+'
+
+# git clone could fail, so break the && chain and ignore the exit code
+# clone local
+test_expect_success './foo:bar is not ssh' '
+ clear_ssh &&
+ git clone "./foo:bar" foobar
+ expect_ssh none
+'
+
+test_expect_success './[nohost:123]:src is not ssh' '
+ clear_ssh &&
+ git clone "./[nohost:123]:src" 1_2_3
+ expect_ssh none
+'
+
+test_expect_success '[nohost:234] is not ssh' '
+ clear_ssh &&
+ git clone "[nohost:234]" 2_3_4
+ expect_ssh none
+'
+
+test_expect_success ':345 is not ssh' '
+ clear_ssh &&
+ git clone ":345" 3_4_5
+ expect_ssh none
+'
+
+test_expect_success '456: is not ssh' '
+ clear_ssh &&
+ git clone "456:" 4_5_6
+ expect_ssh none
+'
+
+# clone via ssh
+# the expect_ssh checks that git clone tried to use ssh
+test_expect_success 'myhost:567 is ssh' '
+ clear_ssh &&
+ git clone myhost:567 myhost_567
+ expect_ssh myhost 567
+'
+
+test_expect_success '[myhost:678]:src is ssh' '
+ clear_ssh &&
+ git clone "[myhost:678]:src" myhost_678
+ expect_ssh myhost:678 src
+'
+
+#clone url looks like ssh, but is on disk
+test_expect_success SYMLINKS 'dir:123 on disk' '
+ clear_ssh &&
+ ln -s src.git dir:123 &&
+ git clone dir:123 dir_123 &&
+ expect_ssh none
+'
+
+test_expect_success SYMLINKS '[dir:234]:src on disk' '
+ clear_ssh &&
+ ln -s src.git [dir:234]:src &&
+ git clone [dir:234]:src dir_234_src &&
+ expect_ssh none
+'
+
+test_expect_success 'ssh://host.xz/~user/repo' '
+ clear_ssh &&
+ git clone "ssh://host.xz/~user/repo" user-repo
+ expect_ssh host.xz "~user/repo"
+'
+
+test_expect_success 'ssh://host.xz:22/~user/repo' '
+ clear_ssh &&
+ git clone "ssh://host.xz:22/~user/repo" user-repo
+ expect_ssh "-p 22 host.xz" "~user/repo"
+'
+
+test_expect_success 'ssh://[::1]:22/~user/repo' '
+ clear_ssh &&
+ git clone "ssh://[::1]:22/~user/repo" user-repo6
+ expect_ssh "-p 22 ::1" "~user/repo"
+'
test_done
==============
And we need this on top of Duys patch:
diff --git a/connect.c b/connect.c
index e8473f3..09be2b3 100644
--- a/connect.c
+++ b/connect.c
@@ -611,7 +611,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
end = host;
path = strchr(end, c);
- if (path && !has_dos_drive_prefix(end)) {
+ if (path && host != path && !has_dos_drive_prefix(end)) {
if (c == ':') {
if (host != url || path < strchrnul(host, '/')) {
protocol = PROTO_SSH;
next prev parent reply other threads:[~2013-10-13 20:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-28 19:37 [PATCH] clone: local URLs are not for ssh Torsten Bögershausen
2013-09-29 0:33 ` Duy Nguyen
2013-10-02 18:40 ` Torsten Bögershausen
2013-10-03 1:01 ` Duy Nguyen
2013-10-03 1:31 ` Jeff King
2013-10-05 19:48 ` Torsten Bögershausen
2013-10-05 20:35 ` Matthieu Moy
2013-10-13 20:00 ` Torsten Bögershausen [this message]
2013-10-15 0:12 ` Jeff King
2013-10-15 7:22 ` Torsten Bögershausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=525AFBCC.4080303@web.de \
--to=tboegi@web.de \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.