Thread (4 messages) flat view 4 messages, 4 authors, 2016-06-15

Re: [PATCH] clone: tighten "local paths with colons" check a bit

From: Torsten Bögershausen <hidden>
Date: 2016-06-15 22:58:55
Subsystem: the rest · Maintainer: Linus Torvalds

On 2013-09-27 23.56, Jonathan Nieder wrote:
Nguyễn Thái Ngọc Duy wrote:
quoted
commit 6000334 (clone: allow cloning local paths with colons in them -
2013-05-04) is added to make it possible to specify a path that has
colons in it without file://, e.g. ../foo:bar/somewhere. But the check
is a bit loose.
[...]
quoted
Make sure we only check so when no protocol is specified and the url
is not started with '['.
More precisely, this disables the "'/' before ':'" check when the
url has been mangled by '[]' unwrapping (which only happens if the
URL starts with '[' and contains an ']' at some point later).

If I try to clone "[foo]bar/baz:qux", after this change it will act as
though I specified the remote repository "foo:qux" instead of the local
repository "./foo:qux" as before this change.  Both are wrong ---
that's a bug for another day.
(Loud thinking)
Could it make sense to disable the SSH autodection logic
whenever the url starts with '.' (like in "../XX.git") 
or with "/" like in /home/USER/projects/XX.git ?
diff --git a/connect.c b/connect.c
index a80ebd3..b382032 100644
--- a/connect.c
+++ b/connect.c
@@ -550,7 +550,8 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
                end = host;
 
        path = strchr(end, c);
-       if (path && !has_dos_drive_prefix(end)) {
+       if (path && !has_dos_drive_prefix(end) &&
+           url[0] != '/' && url[0] != '.' ) {
                if (c == ':') {
                        if (path < strchrnul(host, '/')) {
                                protocol = PROTO_SSH;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help