Thread (1 message) 1 message, 1 author, 2016-06-15

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:19

Jeff King [off-list ref] writes:
On Tue, Aug 25, 2009 at 11:27:47PM +0400, Kirill A. Korinskiy wrote:
quoted
+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?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help