From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Michael J Gruber <git@drmicha.warpmail.net>,
Sverre Rabbelier <srabbelier@gmail.com>,
Stefan Naewe <stefan.naewe@atlas-elektronik.com>,
"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git clone NonExistentLocation
Date: Fri, 18 Feb 2011 01:11:33 -0500 [thread overview]
Message-ID: <20110218061133.GA25847@sigill.intra.peff.net> (raw)
In-Reply-To: <7vd3mp6ftp.fsf@alter.siamese.dyndns.org>
On Thu, Feb 17, 2011 at 10:02:10PM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > I think the patch below is the right fix.
> > ...
> > Signed-off-by: Jeff King <peff@peff.net>
> > ---
> > builtin/clone.c | 5 ++++-
> > t/t5701-clone-local.sh | 13 +++++++++++++
> > 2 files changed, 17 insertions(+), 1 deletions(-)
> >
> > diff --git a/builtin/clone.c b/builtin/clone.c
> > index 60d9a64..55785d0 100644
> > --- a/builtin/clone.c
> > +++ b/builtin/clone.c
> > @@ -412,8 +412,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
> > path = get_repo_path(repo_name, &is_bundle);
> > if (path)
> > repo = xstrdup(make_nonrelative_path(repo_name));
> > - else if (!strchr(repo_name, ':'))
> > + else if (!strchr(repo_name, ':')) {
> > + if (!file_exists(repo_name))
> > + die("repository '%s' does not exist", repo_name);
> > repo = xstrdup(make_absolute_path(repo_name));
> > + }
> > else
> > repo = repo_name;
> > is_local = path && !is_bundle;
>
> Thanks, but I am confused.
>
> The stuff goes through make_absolute_path() so we must be certain that
> this has to be a local filesystem entity _if_ it is a repository.
>
> But when will we see a file at repo_name in this new codepath? In what
> situation would get_repo_path(repo_name, &is_bundle) return NULL but the
> added file_exists(repo_name) would yield true to bypess your die()?
Hmm, good point. I didn't look carefully enough into get_repo_path. It
is not really about finding a repo, but rather about finding a directory
or filename. Plus, my file_exists() isn't quite right, anyway. We really
want to make sure $repo_name.git, $repo_name.bundle, etc don't exist.
But get_repo_path has already done that for us, so we should just trust
its output.
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 60d9a64..2ee1fa9 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -413,7 +413,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
> if (path)
> repo = xstrdup(make_nonrelative_path(repo_name));
> else if (!strchr(repo_name, ':'))
> - repo = xstrdup(make_absolute_path(repo_name));
> + die("repository '%s' does not exist", repo_name);
> else
> repo = repo_name;
> is_local = path && !is_bundle;
Yeah, I think that is a better fix.
-Peff
next prev parent reply other threads:[~2011-02-18 6:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-17 9:01 git clone NonExistentLocation Stefan Naewe
2011-02-17 12:39 ` Michael J Gruber
2011-02-17 12:52 ` Stefan Naewe
2011-02-17 12:59 ` Michael J Gruber
2011-02-17 14:03 ` Sverre Rabbelier
2011-02-17 16:53 ` Michael J Gruber
2011-02-18 4:01 ` Jeff King
2011-02-18 6:02 ` Junio C Hamano
2011-02-18 6:11 ` Jeff King [this message]
2011-02-18 10:16 ` Sverre Rabbelier
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=20110218061133.GA25847@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=srabbelier@gmail.com \
--cc=stefan.naewe@atlas-elektronik.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).