| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='test disabling of local paths in clone/fetch' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | . "$TEST_DIRECTORY/lib-proto-disable.sh" |
| 7 | |
| 8 | test_expect_success 'setup repository to clone' ' |
| 9 | test_commit one |
| 10 | ' |
| 11 | |
| 12 | test_proto "file://" file "file://$PWD" |
| 13 | test_proto "path" file . |
| 14 | |
| 15 | test_expect_success 'setup repo with dash' ' |
| 16 | git init --bare repo.git && |
| 17 | git push repo.git HEAD && |
| 18 | mv repo.git "$PWD/-repo.git" |
| 19 | ' |
| 20 | |
| 21 | # This will fail even without our rejection because upload-pack will |
| 22 | # complain about the bogus option. So let's make sure that GIT_TRACE |
| 23 | # doesn't show us even running upload-pack. |
| 24 | # |
| 25 | # We must also be sure to use "fetch" and not "clone" here, as the latter |
| 26 | # actually canonicalizes our input into an absolute path (which is fine |
| 27 | # to allow). |
| 28 | test_expect_success 'repo names starting with dash are rejected' ' |
| 29 | rm -f trace.out && |
| 30 | test_must_fail env GIT_TRACE="$PWD/trace.out" git fetch -- -repo.git && |
| 31 | ! grep upload-pack trace.out |
| 32 | ' |
| 33 | |
| 34 | test_expect_success 'full paths still work' ' |
| 35 | git fetch "$PWD/-repo.git" |
| 36 | ' |
| 37 | |
| 38 | test_done |