mirror of
https://github.com/git-for-windows/git.git
synced 2025-12-15 12:58:18 -06:00
Git for Windows uses MSYS2's Bash to run the test suite, which comes with benefits but also at a heavy price: on the plus side, MSYS2's POSIX emulation layer allows us to continue pretending that we are on a Unix system, e.g. use Unix paths instead of Windows ones, yet this is bought at a rather noticeable performance penalty. There *are* some more native ports of Unix shells out there, though, most notably BusyBox-w32's ash. These native ports do not use any POSIX emulation layer (or at most a *very* thin one, choosing to avoid features such as fork() that are expensive to emulate on Windows), and they use native Windows paths (usually with forward slashes instead of backslashes, which is perfectly legal in almost all use cases). And here comes the problem: with a $PWD looking like, say, C:/git-sdk-64/usr/src/git/t/trash directory.t5813-proto-disable-ssh Git's test scripts get quite a bit confused, as their assumptions have been shattered. Not only does this path contain a colon (oh no!), it also does not start with a slash. This is a problem e.g. when constructing a URL as t5813 does it: ssh://remote$PWD. Not only is it impossible to separate the "host" from the path with a $PWD as above, even prefixing $PWD by a slash won't work, as /C:/git-sdk-64/... is not a valid path. As a workaround, detect when $PWD does not start with a slash on Windows, and simply strip the drive prefix, using an obscure feature of Windows paths: if an absolute Windows path starts with a slash, it is implicitly prefixed by the drive prefix of the current directory. As we are talking about the current directory here, anyway, that strategy works. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
60 lines
1.5 KiB
Bash
Executable File
60 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='test disabling of git-over-ssh in clone/fetch'
|
|
|
|
. ./test-lib.sh
|
|
. "$TEST_DIRECTORY/lib-proto-disable.sh"
|
|
|
|
setup_ssh_wrapper
|
|
|
|
test_expect_success 'setup repository to clone' '
|
|
test_commit one &&
|
|
mkdir remote &&
|
|
git init --bare remote/repo.git &&
|
|
git push remote/repo.git HEAD
|
|
'
|
|
|
|
test_proto "host:path" ssh "remote:repo.git"
|
|
|
|
hostdir="$PWD"
|
|
if test_have_prereq MINGW && test "/${PWD#/}" != "$PWD"
|
|
then
|
|
case "$PWD" in
|
|
[A-Za-z]:/*)
|
|
hostdir="${PWD#?:}"
|
|
;;
|
|
*)
|
|
skip_all="Unhandled PWD '$PWD'; skipping rest"
|
|
test_done
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
test_proto "ssh://" ssh "ssh://remote$hostdir/remote/repo.git"
|
|
test_proto "git+ssh://" ssh "git+ssh://remote$hostdir/remote/repo.git"
|
|
|
|
# Don't even bother setting up a "-remote" directory, as ssh would generally
|
|
# complain about the bogus option rather than completing our request. Our
|
|
# fake wrapper actually _can_ handle this case, but it's more robust to
|
|
# simply confirm from its output that it did not run at all.
|
|
test_expect_success 'hostnames starting with dash are rejected' '
|
|
test_must_fail git clone ssh://-remote/repo.git dash-host 2>stderr &&
|
|
! grep ^ssh: stderr
|
|
'
|
|
|
|
test_expect_success 'setup repo with dash' '
|
|
git init --bare remote/-repo.git &&
|
|
git push remote/-repo.git HEAD
|
|
'
|
|
|
|
test_expect_success 'repo names starting with dash are rejected' '
|
|
test_must_fail git clone remote:-repo.git dash-path 2>stderr &&
|
|
! grep ^ssh: stderr
|
|
'
|
|
|
|
test_expect_success 'full paths still work' '
|
|
git clone "remote:$PWD/remote/-repo.git" dash-path
|
|
'
|
|
|
|
test_done
|