From: Jeff King <peff@peff.net>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: William Giokas <1007380@gmail.com>,
git@vger.kernel.org, fsckdaemon@gmail.com,
Daniel Barkalow <barkalow@iabervon.org>
Subject: Re: [BUG] Filenames with single colon being treated as remote repository
Date: Sun, 21 Apr 2013 08:45:11 -0400 [thread overview]
Message-ID: <20130421124511.GA1933@sigill.intra.peff.net> (raw)
In-Reply-To: <20130421060538.GB10429@elie.Belkin>
On Sat, Apr 20, 2013 at 11:05:39PM -0700, Jonathan Nieder wrote:
> > Cloning into 'new-baz'...
> > ssh: Could not resolve hostname /tmp/foo: Success
> > fatal: Could not read from remote repository.
>
> Here's a toy patch. I haven't thought carefully about whether it's a
> good idea, but maybe it can be useful for thinking about that.
>
> Still needs documentation and tests.
>
> My main worry is that the proposed rule for when an argument is
> treated as a local path is hard to explain. There's some precedent in
> handling of bundles, though. What do you think?
I think the rule could be something like:
1. If it looks like a URL ("^scheme://"), it is.
2. Otherwise, if it is a path in the filesystem, it is.
3. Otherwise, if it has a colon, it's host:path
4. Otherwise, barf.
where the interesting bit is the ordering of 2 and 3. It seems like
"git clone" follows the order above with get_repo_path. But we do not
seem to follow it in git_connect, where we prefer 3 over 2.
> @@ -942,6 +943,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
> ret->disconnect = close_bundle;
> ret->smart_options = NULL;
> } else if (!is_url(url)
> + || (is_local(url) && !stat(url, &st))
> || !prefixcmp(url, "file://")
> || !prefixcmp(url, "git://")
> || !prefixcmp(url, "ssh://")
I don't think that is enough. Something like /path/to/foo:bar would
trigger !is_url already, but then git_connect fails.
Try:
$ git init --bare foo:bar
$ git clone foo:bar
ssh: Could not resolve hostname /home/peff/foo: Name or service not known
fatal: Could not read from remote repository.
...
Clone recognizes it as a path and turns it into an absolute path. It
then feeds it to the transport code, which triggers !is_url and knows to
use the git transport. But then git_connect prefers ssh over the
filesystem.
If you do a straight fetch, though, the transport code might see the
relative path (if you use one):
$ git init
$ git init --bare sub:repo
$ git fetch sub:repo
ssh: Could not resolve hostname sub: Name or service not known
but that still triggers the is_url above (which demands the "://").
I am not sure whether your patch covers any cases I am missing, but I
think you would need an analogous change to git_connect for these common
cases.
-Peff
next prev parent reply other threads:[~2013-04-21 12:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-21 4:53 [BUG] Filenames with single colon being treated as remote repository William Giokas
2013-04-21 6:05 ` Jonathan Nieder
2013-04-21 12:45 ` Jeff King [this message]
2013-04-21 16:56 ` Jonathan Nieder
2013-04-21 18:01 ` Junio C Hamano
2013-04-22 15:35 ` Jeff King
2013-04-22 16:00 ` Junio C Hamano
2013-04-27 3:36 ` [PATCH] clone: allow cloning local paths with colons in them Nguyễn Thái Ngọc Duy
2013-04-27 20:08 ` William Giokas
2013-04-27 21:16 ` Junio C Hamano
2013-04-28 0:19 ` Duy Nguyen
2013-04-28 1:48 ` Eric Sunshine
2013-04-28 2:15 ` Duy Nguyen
2013-05-04 2:19 ` [PATCH v2] " Nguyễn Thái Ngọc Duy
2013-05-07 15:34 ` Junio C Hamano
2013-05-07 16:47 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130421124511.GA1933@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=1007380@gmail.com \
--cc=barkalow@iabervon.org \
--cc=fsckdaemon@gmail.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).