threads / discuss / 452

cogito "origin" vs. HEAD

Subject: cogito "origin" vs. HEAD

## tl;dr

6 messages between May 3, 2005 and May 3, 2005.

replies: 5people: 3as markdown or json

Benjamin Herrenschmidt· May 3, 2005, 03:24 UTC · lore
Hi !

So it's my understanding that linus only uses this HEAD that symlinks to .git/refs/heads/master as his head of tree.

However, when using cogito, it creates another one here called "origin" that matches the "origin" branch (I don't like "branch" here, it's more like a source of objects than a branch...) locally. Is this actually the content of the remote's HEAD or is git also looking for a remote "refs/heads/origin" ?

So when I later do cg-pull or cg-update origin to update, my "origin" pointer is updated I suppose to the new head of the remote repository, does it also update my local "refs/heads/master" ? Or not ? What happens to it ? does anything will use my local HEAD -> refs/heads/master/ ever ? If I want to publish my tree, what will remote cogito's try to rsync down ? HEAD ? origin ?

Ben.
Petr Baudis· May 3, 2005, 06:49 UTC · re: Benjamin Herrenschmidt · lore

Re: cogito "origin" vs. HEAD

Dear diary, on Tue, May 03, 2005 at 05:24:19AM CEST, I got a letter where Benjamin Herrenschmidt <benh@kernel.crashing.org> told me that...

> Hi !
Hi,
Show 6 quoted lines
> So when I later do cg-pull or cg-update origin to update, my "origin"
> pointer is updated I suppose to the new head of the remote repository,
> does it also update my local "refs/heads/master" ? Or not ? What happens
> to it ? does anything will use my local HEAD -> refs/heads/master/
> ever ? If I want to publish my tree, what will remote cogito's try to
> rsync down ? HEAD ? origin ?

when accessing the remote repository, Cogito always looks for remote refs/heads/master first - if that one isn't there, it takes HEAD, but there is no correlation between the local and remote branch name. If you want to fetch a different branch from the remote repository, use the fragment identifier (see cg-help cg-branch-add).

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Benjamin Herrenschmidt· May 3, 2005, 07:13 UTC · re: Petr Baudis · lore

Re: cogito "origin" vs. HEAD

Show 5 quoted lines
> when accessing the remote repository, Cogito always looks for remote
> refs/heads/master first - if that one isn't there, it takes HEAD, but
> there is no correlation between the local and remote branch name. If you
> want to fetch a different branch from the remote repository, use the
> fragment identifier (see cg-help cg-branch-add).

Ok, that I'm getting. So then, what happen of my local refs/heads/<branchname> and refs/heads/master/ ? I'm still a bit confused by the whole branch mecanism... It's my understanding than when I cg-init, it creates both "master" (a head without matching branch) and "origin" (a branch + a head) both having the same sha1. It also checks out the tree.

Now, when I cg-update origin, what happens exactly ? I mean, I know it's pulls all objects, then get the master from the remote pointed by the origin branch, but then, I suppose it updates both my local "origin" and my local "master" pointer, right ? I mean, they are always in sync ? Or is this related to what branch my current checkout is tracking ?

Ben.
Alexey Nezhdanov· May 3, 2005, 09:06 UTC · re: Benjamin Herrenschmidt · lore

Re: cogito "origin" vs. HEAD

At Tuesday, 03 May 2005 11:13 Benjamin Herrenschmidt wrote:
Show 18 quoted lines
> > when accessing the remote repository, Cogito always looks for remote
> > refs/heads/master first - if that one isn't there, it takes HEAD, but
> > there is no correlation between the local and remote branch name. If you
> > want to fetch a different branch from the remote repository, use the
> > fragment identifier (see cg-help cg-branch-add).
>
> Ok, that I'm getting. So then, what happen of my local
> refs/heads/<branchname> and refs/heads/master/ ? I'm still a bit
> confused by the whole branch mecanism... It's my understanding than when
> I cg-init, it creates both "master" (a head without matching branch)
> and "origin" (a branch  + a head) both having the same sha1. It also
> checks out the tree.
>
> Now, when I cg-update origin, what happens exactly ? I mean, I know it's
> pulls all objects, then get the master from the remote pointed by the
> origin branch, but then, I suppose it updates both my local "origin" and
> my local "master" pointer, right ? I mean, they are always in sync ? Or
> is this related to what branch my current checkout is tracking ?

If I understand this mechanics correctly then "master head" always track your local tree (i.e. with all remote and local patches applied) and "origin head" always tracking head of the remote branch from where you are getting objects.

I.e. it is really a tree, not source of objects. The tree can be strored on many different hosts but it is the same across them. But the master tree have no source to sync from - you are creating it yourself locally so there is no "master branch" - only head.

So if you are just tracking some other tree and do not do any merges/patches yourself then your master head will always match your remote source head ("origin" in most cases).

-- 
Respectfully
Alexey Nezhdanov
Petr Baudis· May 3, 2005, 09:47 UTC · re: Benjamin Herrenschmidt · lore

Re: cogito "origin" vs. HEAD

Dear diary, on Tue, May 03, 2005 at 09:13:28AM CEST, I got a letter where Benjamin Herrenschmidt <benh@kernel.crashing.org> told me that...

Show 18 quoted lines
> > when accessing the remote repository, Cogito always looks for remote
> > refs/heads/master first - if that one isn't there, it takes HEAD, but
> > there is no correlation between the local and remote branch name. If you
> > want to fetch a different branch from the remote repository, use the
> > fragment identifier (see cg-help cg-branch-add).
> 
> Ok, that I'm getting. So then, what happen of my local
> refs/heads/<branchname> and refs/heads/master/ ? I'm still a bit
> confused by the whole branch mecanism... It's my understanding than when
> I cg-init, it creates both "master" (a head without matching branch)
> and "origin" (a branch  + a head) both having the same sha1. It also
> checks out the tree.
> 
> Now, when I cg-update origin, what happens exactly ? I mean, I know it's
> pulls all objects, then get the master from the remote pointed by the
> origin branch, but then, I suppose it updates both my local "origin" and
> my local "master" pointer, right ? I mean, they are always in sync ? Or
> is this related to what branch my current checkout is tracking ?

They are in sync as long as you update only from that given branch. At the moment you do a local commit, they get out of sync, at least until your master branch is merged to the origin branch on the other side. Every cg-update will then generate a merging commit, so it will look like this:

     [origin]    [master]
            commit1
              |
            commit2               Both heads are in sync so far...
              |
            commit3
             /    \
            /     commit4         Now heads/master is commit4, but
           /        |             heads/origin is still commit3
          /         |
      commit5-.     |             heads/master:commit4, heads/origin:commit5
          |    \    |
          |     `-commit6         commit6 merges origin to master
          |       /
          |     /
          |   /
      commit6                     origin merged your master; since it
                                  contained all the commits on the origin
               |                  branch, it just took over the commit6
             commit6              commit pointer as its new head; so both
                                  heads are again in sync now

This is the reason why there are always at least two branches, origin and master. The checked out tree is always of the master branch (unless you do cg-seek, which is somewhat special anyway). [*] "Normally", when you do no local changes and just always cg-update the origin branch, the two branches are always in sync. At the point you start to "mix" several remote branches besides origin in your tree, or at the point you do a local commit, the master branch gets standalone - until the origin merges your changes as drawn in the diagram.

There is one other situation when the head pointers may not be in sync - when you do cg-pull instead of cg-update. You want to see what are the changes in the origin branch, but you are not sure if you want them to appear in your master branch, you do cg-pull origin. Your origin head pointer is updated, but your master pointer stays where it is. If you decide it's ok to bring the changes in, you do either cg-update, or only cg-merge to avoid re-pulling.

[*] Technically, you can have multiple local branches and your tree can be based on any of them, not only "master". Cogito supports that internally, but (deliberately) provides no UI to set that up, at least until we devise a way to do it without confusing people even more.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Benjamin Herrenschmidt· May 3, 2005, 23:49 UTC · re: Petr Baudis · lore

Re: cogito "origin" vs. HEAD

On Tue, 2005-05-03 at 11:47 +0200, Petr Baudis wrote:
Show 27 quoted lines
> Dear diary, on Tue, May 03, 2005 at 09:13:28AM CEST, I got a letter
> where Benjamin Herrenschmidt <benh@kernel.crashing.org> told me that...
> > > when accessing the remote repository, Cogito always looks for remote
> > > refs/heads/master first - if that one isn't there, it takes HEAD, but
> > > there is no correlation between the local and remote branch name. If you
> > > want to fetch a different branch from the remote repository, use the
> > > fragment identifier (see cg-help cg-branch-add).
> > 
> > Ok, that I'm getting. So then, what happen of my local
> > refs/heads/<branchname> and refs/heads/master/ ? I'm still a bit
> > confused by the whole branch mecanism... It's my understanding than when
> > I cg-init, it creates both "master" (a head without matching branch)
> > and "origin" (a branch  + a head) both having the same sha1. It also
> > checks out the tree.
> > 
> > Now, when I cg-update origin, what happens exactly ? I mean, I know it's
> > pulls all objects, then get the master from the remote pointed by the
> > origin branch, but then, I suppose it updates both my local "origin" and
> > my local "master" pointer, right ? I mean, they are always in sync ? Or
> > is this related to what branch my current checkout is tracking ?
> 
> They are in sync as long as you update only from that given branch.
> At the moment you do a local commit, they get out of sync, at least
> until your master branch is merged to the origin branch on the other
> side. Every cg-update will then generate a merging commit, so it will
> look like this:
> > .../...
Thanks for that detailed explanation !
Ben.

← back to recent threads