git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Torsten Bögershausen <tboegi@web.de>
Date
Sep 28, 2013, 13:14 UTC
Message-ID
<5246D642.7060203@web.de>
In-Reply-To
<20130927215631.GN9464@google.com>
On 2013-09-27 23.56, Jonathan Nieder wrote:
Show 18 quoted lines
> Nguyễn Thái Ngọc Duy wrote:
> 
>> 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.
> [...]
>> 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;
Previous: Jonathan Nieder
Message 4 of 4 in “clone: tighten "local paths with colons" check a bit”
  1. clone: tighten "local paths with colons" check a bitNguyễn Thái Ngọc Duy, Sep 27, 2013
  2. Jeff KingSep 27, 2013
  3. Jonathan NiederSep 27, 2013
  4. Torsten BögershausenSep 28, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.