git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add option -b/--branch to clone for select a new HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2009, 22:42 UTC
Message-ID
<7vvdkbms6b.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20090825215726.GA30981@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 25 quoted lines
> On Tue, Aug 25, 2009 at 11:27:47PM +0400, Kirill A. Korinskiy wrote:
>
>> +test_expect_success 'clone' '
>> +
>> +	git clone parent clone &&
>> +	(cd clone && git rev-parse --verify refs/remotes/origin/master)
>> +
>> +'
>> +
>> +test_expect_success 'clone -b' '
>> +
>> +	git clone -b two parent clone-b &&
>> +	(cd clone-b && test $(git rev-parse --verify HEAD) = $(git rev-parse --verify refs/remotes/origin/two))
>> +
>> +'
>
> OK, I think that second test makes sense (though please wrap the very
> long line), but now what is the first one doing? Shouldn't it be:
>
>   (cd clone &&
>    test $(git rev-parse --verify HEAD) = \
>         $(git rev-parse --verify refs/remotes/origin/master)
>   )
>
> also?

Are you checking that the HEAD (whichever branch it points at) points at the same commit, or are you also interested in the _current branch_ to be a particular name as well? The suggested check only compares commits and HEAD can be pointing at a local branch whose name is xyzzy.

What is the semantics of this new -b option? When the remote repository has 'next' as its default branch (i.e. HEAD points at it), and if you run clone with "-b maint" against it, I expect that the checked out commit will be the 'maint' of remote repository, but what is the name of the current branch in the resulting clone on our end?

 - Would we use 'master' as the name of our current branch, because that
   is the default?
 - Would we use 'next' as the name of our current branch, because that is
   what the remote side uses?
 - Would we use 'maint', because that is what -b gave us?

I am _hoping_ it is the last one, as otherwise you would also need to make sure that the branch that is different from 'maint' we set as the current branch must track 'maint' from the remote.

Oh, with -b, would we set up our 'maint' to track their 'maint'? Is it something you may want to verify as well?

Previous: Jeff KingNext: Björn Steinbrink
Message 4 of 15 in “Add option -b/--branch to clone for select a new HEAD”
  1. Add option -b/--branch to clone for select a new HEADKirill A. Korinskiy, Aug 25, 2009
  2. Add option -b/--branch to clone for select a new HEADKirill A. Korinskiy, Aug 25, 2009
  3. Jeff KingAug 25, 2009
  4. Junio C HamanoAug 25, 2009
  5. Björn SteinbrinkAug 25, 2009
  6. Tor Arne VestbøAug 28, 2009
  7. Martin LanghoffAug 28, 2009
  8. Julian PhillipsAug 28, 2009
  9. Björn SteinbrinkAug 26, 2009
  10. Add option -b/--branch to clone for select a new HEADKirill A. Korinskiy, Aug 26, 2009
  11. Björn SteinbrinkAug 26, 2009
  12. Jeff KingAug 26, 2009
  13. Björn SteinbrinkAug 26, 2009
  14. Jeff KingAug 26, 2009
  15. Jeff KingAug 26, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.