From: Duy Nguyen <pclouds@gmail.com>
To: Ralf Thielow <ralf.thielow@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Stefan Beller <stefanbeller@googlemail.com>,
Junio C Hamano <gitster@pobox.com>,
Jonathan Nieder <jrnieder@gmail.com>,
robert.mitwicki@opensoftware.pl
Subject: Re: [PATCH] clone --branch: refuse to clone if upstream repo is empty
Date: Tue, 15 Oct 2013 02:08:38 +0700 [thread overview]
Message-ID: <CACsJy8AgU89=s4P+28Smp5Vysbc06GhaN-o0Rw3N-OEOVbhLRA@mail.gmail.com> (raw)
In-Reply-To: <1381510142-3026-1-git-send-email-ralf.thielow@gmail.com>
On Fri, Oct 11, 2013 at 11:49 PM, Ralf Thielow <ralf.thielow@gmail.com> wrote:
> Since 920b691 (clone: refuse to clone if --branch
> points to bogus ref) we refuse to clone with option
> "-b" if the specified branch does not exist in the
> (non-empty) upstream. If the upstream repository is empty,
> the branch doesn't exist, either. So refuse the clone too.
Yeah, much simpler approach :)
> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
> ---
> builtin/clone.c | 4 ++++
> t/t5706-clone-branch.sh | 8 +++++++-
> 2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index ca3eb68..5af386e 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -945,6 +945,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
> our_head_points_at = remote_head_points_at;
> }
> else {
> + if (option_branch)
> + die(_("Remote branch %s not found in upstream %s"),
> + option_branch, option_origin);
> +
> warning(_("You appear to have cloned an empty repository."));
> mapped_refs = NULL;
> our_head_points_at = NULL;
> diff --git a/t/t5706-clone-branch.sh b/t/t5706-clone-branch.sh
> index 56be67e..6e7a7be 100755
> --- a/t/t5706-clone-branch.sh
> +++ b/t/t5706-clone-branch.sh
> @@ -20,7 +20,9 @@ test_expect_success 'setup' '
> echo one >file && git add file && git commit -m one &&
> git checkout -b two &&
> echo two >file && git add file && git commit -m two &&
> - git checkout master)
> + git checkout master) &&
> + mkdir empty &&
> + (cd empty && git init)
> '
>
> test_expect_success 'vanilla clone chooses HEAD' '
> @@ -61,4 +63,8 @@ test_expect_success 'clone -b with bogus branch' '
> test_must_fail git clone -b bogus parent clone-bogus
> '
>
> +test_expect_success 'clone -b not allowed with empty repos' '
> + test_must_fail git clone -b branch empty clone-branch-empty
> +'
> +
> test_done
> --
> 1.8.4.652.g0d6e0ce
>
--
Duy
prev parent reply other threads:[~2013-10-14 19:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-04 13:54 Bug: Segmentation fault (core dumped) Robert Mitwicki
2013-10-04 14:20 ` [PATCH] clone: do not segfault when specifying a nonexistent branch Stefan Beller
2013-10-04 23:55 ` Duy Nguyen
2013-10-06 9:27 ` Stefan Beller
2013-10-07 10:46 ` Duy Nguyen
2013-10-08 10:06 ` Stefan Beller
2013-10-09 16:38 ` Ralf Thielow
2013-10-11 16:49 ` [PATCH] clone --branch: refuse to clone if upstream repo is empty Ralf Thielow
2013-10-14 19:08 ` Duy Nguyen [this message]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACsJy8AgU89=s4P+28Smp5Vysbc06GhaN-o0Rw3N-OEOVbhLRA@mail.gmail.com' \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=ralf.thielow@gmail.com \
--cc=robert.mitwicki@opensoftware.pl \
--cc=stefanbeller@googlemail.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).