diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2015-04-26 20:30:12 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-04-28 15:23:12 -0700 |
commit | baaf233755f71c057d28b9e8692e24d4fca7d22f (patch) | |
tree | f4dd21df1b7ea6028213cf59cfb9cfb8b27dafc8 /t/t5601-clone.sh | |
parent | d1018c2494c05e6a27ec5945902306cfb9e45b0c (diff) | |
download | git-baaf233755f71c057d28b9e8692e24d4fca7d22f.tar.gz |
connect: improve check for plink to reduce false positivesbc/connect-plink
The git_connect function has code to handle plink and tortoiseplink
specially, as they require different command line arguments from
OpenSSH (-P instead of -p for ports; tortoiseplink additionally requires
-batch). However, the match was done by checking for "plink" anywhere
in the string, which led to a GIT_SSH value containing "uplink" being
treated as an invocation of putty's plink.
Improve the check by looking for "plink" or "tortoiseplink" (or those
names suffixed with ".exe") only in the final component of the path.
This has the downside that a program such as "plink-0.63" would no
longer be recognized, but the increased robustness is likely worth it.
Add tests to cover these cases to avoid regressions.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5601-clone.sh')
-rwxr-xr-x | t/t5601-clone.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index 5efc177917..731c09c418 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -296,6 +296,12 @@ setup_ssh_wrapper () { ' } +copy_ssh_wrapper_as () { + cp "$TRASH_DIRECTORY/ssh-wrapper" "$1" && + GIT_SSH="$1" && + export GIT_SSH +} + expect_ssh () { test_when_finished ' (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output) @@ -335,6 +341,33 @@ test_expect_success 'bracketed hostnames are still ssh' ' expect_ssh "-p 123" myhost src ' +test_expect_success 'uplink is not treated as putty' ' + copy_ssh_wrapper_as "$TRASH_DIRECTORY/uplink" && + git clone "[myhost:123]:src" ssh-bracket-clone-uplink && + expect_ssh "-p 123" myhost src +' + +test_expect_success 'plink is treated specially (as putty)' ' + copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" && + git clone "[myhost:123]:src" ssh-bracket-clone-plink-0 && + expect_ssh "-P 123" myhost src +' + +test_expect_success 'plink.exe is treated specially (as putty)' ' + copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink.exe" && + git clone "[myhost:123]:src" ssh-bracket-clone-plink-1 && + expect_ssh "-P 123" myhost src +' + +test_expect_success 'tortoiseplink is like putty, with extra arguments' ' + copy_ssh_wrapper_as "$TRASH_DIRECTORY/tortoiseplink" && + git clone "[myhost:123]:src" ssh-bracket-clone-plink-2 && + expect_ssh "-batch -P 123" myhost src +' + +# Reset the GIT_SSH environment variable for clone tests. +setup_ssh_wrapper + counter=0 # $1 url # $2 none|host |