]> git.ipfire.org Git - thirdparty/git.git/commit - t/t5603-clone-dirname.sh
clone: do not use port number as dir name
authorPatrick Steinhardt <ps@pks.im>
Mon, 10 Aug 2015 15:48:24 +0000 (17:48 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Aug 2015 18:02:07 +0000 (11:02 -0700)
commit92722efec01f67a54b68c83fcbc3cd65f9fbb7b8
treeeefdfc349caa9a30a962a1ef67f9586abc3fc688
parente895986727dfc4105c497132540dafa8ed51ec0a
clone: do not use port number as dir name

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>
builtin/clone.c
t/t5603-clone-dirname.sh