clone: do not include authentication data in guessed dir
commite895986727dfc4105c497132540dafa8ed51ec0a
authorPatrick Steinhardt <ps@pks.im>
Mon, 10 Aug 2015 15:48:23 +0000 (10 17:48 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Aug 2015 18:01:08 +0000 (10 11:01 -0700)
tree15b88bc28cc0b417f95fa7944a081cf939294a9c
parentdb2e220447f7b02278d64417c8f05f73710f5b8b
clone: do not include authentication data in guessed dir

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