git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* strange "git clone" behavior wrt an active branch
@ 2008-09-28 12:05 Leo Razoumov
  2008-09-28 12:37 ` Santi Béjar
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Razoumov @ 2008-09-28 12:05 UTC (permalink / raw)
  To: Git Mailing List

Hi All,
I am using the latest stable version git-1.6.0.2.

The man page for git-clone states explicitly that "git clone"

" Clones a repository into a newly created directory, ...[snip]...
  and creates and checks out an initial branch equal to the
  cloned repository's currently active branch. "

I noticed that while my active branch "My" happens to point to the
same commit as the "master" the git clone will check out master
instead of My (currently active branch). Is it a bug?

Here is the example that demontrates the problem

~> mkdir tmp
~/tmp> git init
~/tmp> cat > txt
some text
~/tmp> git add .
~/tmp> git ci -m 'init ci'
~/tmp> git branch -a
* master
~/tmp> git co -b My
~/tmp> git branch -a
* My
  master

Now "My" is my active branch in 'tmp' repo. It points to the same
commit as the master. Now let us clone it

~/tmp> cd ..
~> git clone tmp tmp1
~> cd tmp1
~/tmp1> git branch -a
* master
  origin/HEAD
  origin/My
  origin/master

In the cloned repository 'tmp1',  master branch is active. No local
tracking branch for "My" was created. I think this behavior
contradicts the man page. Is it a bug or feature??

Thanks,
--Leo--

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange "git clone" behavior wrt an active branch
  2008-09-28 12:05 strange "git clone" behavior wrt an active branch Leo Razoumov
@ 2008-09-28 12:37 ` Santi Béjar
  2008-09-28 13:23   ` Leo Razoumov
  0 siblings, 1 reply; 4+ messages in thread
From: Santi Béjar @ 2008-09-28 12:37 UTC (permalink / raw)
  To: SLONIK.AZ; +Cc: Git Mailing List

On Sun, Sep 28, 2008 at 2:05 PM, Leo Razoumov <slonik.az@gmail.com> wrote:
> Hi All,
> I am using the latest stable version git-1.6.0.2.
>
> The man page for git-clone states explicitly that "git clone"
>
> " Clones a repository into a newly created directory, ...[snip]...
>  and creates and checks out an initial branch equal to the
>  cloned repository's currently active branch. "
>
> I noticed that while my active branch "My" happens to point to the
> same commit as the "master" the git clone will check out master
> instead of My (currently active branch). Is it a bug?
>

Currently it is only guessed which is the active branch (with a
preference for the master branch as it is the default), as the current
protocol does not allow tranfering the ref links:

$ git ls-remote $url
$sha1 HEAD
$sha1 $branchname
...

instead of:
ref: refs/heads/master HEAD
$sha1 $branchname
...

So, I think it is a current limitation that maybe should be documented.

HTH,
Santi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange "git clone" behavior wrt an active branch
  2008-09-28 12:37 ` Santi Béjar
@ 2008-09-28 13:23   ` Leo Razoumov
  2008-09-28 19:43     ` Santi Béjar
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Razoumov @ 2008-09-28 13:23 UTC (permalink / raw)
  To: Santi Béjar; +Cc: Git Mailing List

On 9/28/08, Santi Béjar <santi@agolina.net> wrote:
> On Sun, Sep 28, 2008 at 2:05 PM, Leo Razoumov <slonik.az@gmail.com> wrote:
>  > Hi All,
>  > I am using the latest stable version git-1.6.0.2.
>  >
>  > The man page for git-clone states explicitly that "git clone"
>  >
>  > " Clones a repository into a newly created directory, ...[snip]...
>  >  and creates and checks out an initial branch equal to the
>  >  cloned repository's currently active branch. "
>  >
>  > I noticed that while my active branch "My" happens to point to the
>  > same commit as the "master" the git clone will check out master
>  > instead of My (currently active branch). Is it a bug?
>  >
>
>
> Currently it is only guessed which is the active branch (with a
>  preference for the master branch as it is the default), as the current
>  protocol does not allow tranfering the ref links:

This is quite unfortunate design decision. There can be any number of
local branches referring to the same commit. Without being able to
pick into .git/HEAD it is impossible to decide which of them is
"active".

--Leo--

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: strange "git clone" behavior wrt an active branch
  2008-09-28 13:23   ` Leo Razoumov
@ 2008-09-28 19:43     ` Santi Béjar
  0 siblings, 0 replies; 4+ messages in thread
From: Santi Béjar @ 2008-09-28 19:43 UTC (permalink / raw)
  To: SLONIK.AZ; +Cc: Git Mailing List

On Sun, Sep 28, 2008 at 3:23 PM, Leo Razoumov <slonik.az@gmail.com> wrote:
> On 9/28/08, Santi Béjar <santi@agolina.net> wrote:
>> On Sun, Sep 28, 2008 at 2:05 PM, Leo Razoumov <slonik.az@gmail.com> wrote:
>>  > Hi All,
>>  > I am using the latest stable version git-1.6.0.2.
>>  >
>>  > The man page for git-clone states explicitly that "git clone"
>>  >
>>  > " Clones a repository into a newly created directory, ...[snip]...
>>  >  and creates and checks out an initial branch equal to the
>>  >  cloned repository's currently active branch. "
>>  >
>>  > I noticed that while my active branch "My" happens to point to the
>>  > same commit as the "master" the git clone will check out master
>>  > instead of My (currently active branch). Is it a bug?
>>  >
>>
>>
>> Currently it is only guessed which is the active branch (with a
>>  preference for the master branch as it is the default), as the current
>>  protocol does not allow transferring the ref links:
>
> This is quite unfortunate design decision.

This is not a design decision, git has evolved, not designed. The ref
links are younger than the transfer protocols.

> There can be any number of
> local branches referring to the same commit. Without being able to
> pick into .git/HEAD it is impossible to decide which of them is
> "active".

I'm sure patches are welcome.

>
> --Leo--
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-09-28 19:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-28 12:05 strange "git clone" behavior wrt an active branch Leo Razoumov
2008-09-28 12:37 ` Santi Béjar
2008-09-28 13:23   ` Leo Razoumov
2008-09-28 19:43     ` Santi Béjar

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).