From: Duy Nguyen <pclouds@gmail.com>
To: Stefan Beller <stefanbeller@googlemail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Ralf Thielow <ralf.thielow@gmail.com>,
robert.mitwicki@opensoftware.pl,
Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] clone: do not segfault when specifying a nonexistent branch
Date: Mon, 7 Oct 2013 17:46:23 +0700 [thread overview]
Message-ID: <CACsJy8D+a=agXppSRT0C_w_9a5nGwomDp=8tiN5GPWtrpCKHRQ@mail.gmail.com> (raw)
In-Reply-To: <52512CF8.2070205@googlemail.com>
On Sun, Oct 6, 2013 at 4:27 PM, Stefan Beller
<stefanbeller@googlemail.com> wrote:
>>> @@ -688,7 +688,7 @@ static void write_refspec_config(const char* src_ref_prefix,
>>>
>>> if (option_mirror || !option_bare) {
>>> if (option_single_branch && !option_mirror) {
>>> - if (option_branch) {
>>> + if (option_branch && our_head_points_at) {
>>> if (strstr(our_head_points_at->name, "refs/tags/"))
>>> strbuf_addf(&value, "+%s:%s", our_head_points_at->name,
>>> our_head_points_at->name);
>>
>> This prevents the segfault, but what about remote.*.fetch? Should we
>> setup standard refspec for fetch or..?
>>
>
> Looking at the code a few lines below, this comment comes up:
>
> /*
> * otherwise, the next "git fetch" will
> * simply fetch from HEAD without updating
> * any remote-tracking branch, which is what
> * we want.
> */
>
> This behavior was good for the case (!option_branch && !remote_head_points_at)
> Now we extend that behavior doing nothing to
> ((!option_branch || !our_head_points_at) && !remote_head_points_at)
>
> I am not sure how to handle that case best. The user has given a non existing branch,
> so it doesn't make sense to track that branch, but only have that
> registered as a remote*.fetch?
>
> Reading the documentation enhancements of 31b808a
> (2012-09-20, clone --single: limit the fetch refspec to fetched branch), doesn't
> talk about this corner case. So maybe the remote.*.fetch shall be set, but no branch
> should be checked out, when running
> git clone --depth 1 -b test https://github.com/mitfik/coredump.git /tmp/coredump.git
>
> Does that make sense?
Looking further back to 86ac751 (Allow cloning an empty repository -
2009-01-23), the reason to allow cloning an empty repository is so
that the user does not have do manual configuration, so I agree with
your "maybe". git-clone.txt should have a short description about this
too in case somebody runs into this and cares enough to check the
document before heading to Stack Overflow.
--
Duy
next prev parent reply other threads:[~2013-10-07 10:46 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 [this message]
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
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='CACsJy8D+a=agXppSRT0C_w_9a5nGwomDp=8tiN5GPWtrpCKHRQ@mail.gmail.com' \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).