summaryrefslogtreecommitdiff
path: root/t/t5603-clone-dirname.sh
AgeCommit message (Collapse)Author
2017-11-21ssh: 'simple' variant does not support --portJonathan Nieder
When trying to connect to an ssh:// URL with port explicitly specified and the ssh command configured with GIT_SSH does not support such a setting, it is less confusing to error out than to silently suppress the port setting and continue. This requires updating the GIT_SSH setting in t5603-clone-dirname.sh. That test is about the directory name produced when cloning various URLs. It uses an ssh wrapper that ignores all its arguments but does not declare that it supports a port argument; update it to set GIT_SSH_VARIANT=ssh to do so. (Real-life ssh wrappers that pass a port argument to OpenSSH would also support -G and would not require such an update.) Reported-by: William Yan <wyan@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Acked-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-10clone: do not use port number as dir namePatrick Steinhardt
If the URI contains a port number and the URI's path component is empty we fail to guess a sensible directory name. E.g. cloning a repository 'ssh://example.com:2222/' we guess a directory name '2222' where we would want the hostname only, e.g. 'example.com'. We need to take care to not drop trailing port-like numbers in certain cases. E.g. when cloning a repository 'foo/bar:2222.git' we want to guess the directory name '2222' instead of 'bar'. Thus, we have to first check the stripped URI for path separators and only strip port numbers if there are path separators present. This heuristic breaks when cloning a repository 'bar:2222.git', though. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-10clone: do not include authentication data in guessed dirPatrick Steinhardt
If the URI contains authentication data and the URI's path component is empty, we fail to guess a sensible directory name. E.g. cloning a repository 'ssh://user:password@example.com/' we guess a directory name 'password@example.com' where we would want the hostname only, e.g. 'example.com'. The naive way of just adding '@' as a path separator would break cloning repositories like 'foo/bar@baz.git' (which would currently become 'bar@baz' but would then become 'baz' only). Instead fix this by first dropping the scheme and then greedily scanning for an '@' sign until we find the first path separator. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-10clone: use computed length in guess_dir_nameJeff King
Commit 7e837c6 (clone: simplify string handling in guess_dir_name(), 2015-07-09) changed clone to use strip_suffix instead of hand-rolled pointer manipulation. However, strip_suffix will strip from the end of a NUL-terminated string, and we may have already stripped some characters (like directory separators, or "/.git"). This leads to commands like: git clone host:foo.git/ failing to strip the ".git". We must instead convert our pointer arithmetic into a computed length and feed that to strip_suffix_mem, which will then reduce the length further for us. It would be nicer if we could drop the pointer manipulation entirely, and just continually strip using strip_suffix. But that doesn't quite work for two reasons: 1. The early suffixes we're stripping are not constant; we need to look for is_dir_sep, which could be one of several characters. 2. Mid-way through the stripping we compute the pointer "start", which shows us the beginning of the pathname. Which really give us two lengths to work with: the offset from the start of the string, and from the start of the path. By using pointers for the early part, we can just compute the length from "start" when we need it. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-10clone: add tests for output directoryJeff King
When we run "git clone $url", clone guesses from the $url what to name the local output directory. We don't have any test coverage of this, so let's add some basic tests. This reveals a few problems: - cloning "foo.git/" does not properly remove the ".git"; this is a recent regression from 7e837c6 (clone: simplify string handling in guess_dir_name(), 2015-07-09) - likewise, cloning foo/.git does not seem to handle the bare case (we should end up in foo.git, but we try to use foo/.git on the local end), which also comes from 7e837c6. - cloning the root is not very smart about URL parsing, and usernames and port numbers may end up in the directory name All of these tests are marked as failures. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>