* Git clone behave strange after active branch change in bare repo
@ 2012-03-12 10:10 Zdenek Crha
2012-03-12 11:12 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: Zdenek Crha @ 2012-03-12 10:10 UTC (permalink / raw)
To: git
Hello,
I'm trying to change active branch on bare repository to force
checkout of different branch than master when directory is cloned. The
git version I'm using is 1.7.9.1 from debian repository.
I've used git-symbolic-ref to change active branch without problem:
$ cd repository.git
$ git branch
* master
$ git branch a_branch
$ git symbolic-ref HEAD refs/heads/a_branch
$ cat HEAD
ref: refs/heads/a_branch
When I run git clone while 'master' and 'a_branch' point to same
commit, I will get clone with default branch 'master' where I would
expect default branch 'a_branch'.
$ cd .. && git clone repository.git repo
$ cd repo && git branch
* master
I've tried to remove master branch and I've got result I've expected -
new clone has one branch checked out, the 'a_branch'.
But then I created another branch on the commit pointed by active
branch and tried to clone:
$ cd repository.git && git branch AAA
$ cd .. && git clone repository.git
$ cd repo && git branch
* AAA
I did few more checks and it seems to me that:
* when active branch is 'master' then default branch in clone is
always master as expected
* when active branch is different from 'master', then the default
branch in clone is a first branch in alfabetically sorted list of
branches that point to same commit as active branch
Is this behaviour correct or did I run into a bug?
Regards,
Zdenek Crha
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Git clone behave strange after active branch change in bare repo
2012-03-12 10:10 Git clone behave strange after active branch change in bare repo Zdenek Crha
@ 2012-03-12 11:12 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2012-03-12 11:12 UTC (permalink / raw)
To: Zdenek Crha; +Cc: git
On Mon, Mar 12, 2012 at 11:10:03AM +0100, Zdenek Crha wrote:
> When I run git clone while 'master' and 'a_branch' point to same
> commit, I will get clone with default branch 'master' where I would
> expect default branch 'a_branch'.
Yes, this is a known issue. The git protocol does not transfer the
contents of the symref; the client must guess the branch name from the
set of refs that are advertised. This has been discussed before, and
there were even some patches proposed, but I think nobody cared enough
to push it through, as it requires an extension to the protocol.
You can search the list archives for past discussions.
> I did few more checks and it seems to me that:
>
> * when active branch is 'master' then default branch in clone is
> always master as expected
> * when active branch is different from 'master', then the default
> branch in clone is a first branch in alfabetically sorted list of
> branches that point to same commit as active branch
Exactly. The relevant code is in remote.c:guess_remote_head.
-Peff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-12 11:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-12 10:10 Git clone behave strange after active branch change in bare repo Zdenek Crha
2012-03-12 11:12 ` Jeff King
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 NNTP newsgroup(s).