Re: [PATCH] clone: fix refspec on "--single-branch" option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 14, 2012, 06:48 UTC
- Message-ID
- <7vipbh6qxa.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <7vr4q56uae.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 20 quoted lines
> Who guarantees at this point in the codepath that option_branch is
> set when option_single_branch is non-zero? Until we talk with the
> remote, "clone --single-branch" without an explicit "--branch" will
> not learn which branch at the remote we are going to fetch (it will
> be their HEAD).
>
> I wonder if this should be more like this:
>
> if (option_single_branch) {
> if (option_branch)
> Your patch "+refs/heads/foo:refs/remotes/origin/foo";
> else
> "HEAD";
> } else {
> Original "+refs/heads/*:refs/remotes/origin/*";
> }
>
> That is, "clone --single-branch" will continue fetching from and
> integrating with their HEAD without storing any remote tracking
> branch.Alternatively, if you can move the logic to set up this configuration further down so that it happens after we talked to the other side and figured out remote_head_points_at, you could instead set it up to keep a single remote tracking branch.
Even if you did so, guess_remote_head() may not find any branch when the other repository's HEAD is detached, so you would need to decide what to do in such a case, and "fetch and integrate their HEAD without using any remote tracking branch" may be a reasonable thing to do in such a case.