{"thread":{"id":"452","subject":"cogito \"origin\" vs. HEAD","startedAt":"2005-05-03T03:24:19Z","lastAt":"2005-05-03T23:49:20Z","messageCount":6,"participants":["Benjamin Herrenschmidt","Petr Baudis","Alexey Nezhdanov"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"2438","messageId":"1115090660.6156.56.camel@gaston","threadId":"452","inReplyTo":null,"subject":"cogito \"origin\" vs. HEAD","fromName":"Benjamin Herrenschmidt","fromEmail":"benh@kernel.crashing.org","sentAt":"2005-05-03T03:24:19Z","receivedAt":"2005-05-03T03:24:19Z","isPatch":false,"sender":{"key":"benh@kernel.crashing.org","avatar":null},"body":"Hi !\n\nSo it's my understanding that linus only uses this HEAD that symlinks\nto .git/refs/heads/master as his head of tree.\n\nHowever, when using cogito, it creates another one here called \"origin\"\nthat matches the \"origin\" branch (I don't like \"branch\" here, it's more\nlike a source of objects than a branch...) locally. Is this actually the\ncontent of the remote's HEAD or is git also looking for a remote\n\"refs/heads/origin\" ?\n\nSo when I later do cg-pull or cg-update origin to update, my \"origin\"\npointer is updated I suppose to the new head of the remote repository,\ndoes it also update my local \"refs/heads/master\" ? Or not ? What happens\nto it ? does anything will use my local HEAD -> refs/heads/master/\never ? If I want to publish my tree, what will remote cogito's try to\nrsync down ? HEAD ? origin ?\n\nBen.\n\n\n"},{"id":"2454","messageId":"20050503064943.GB10244@pasky.ji.cz","threadId":"452","inReplyTo":"1115090660.6156.56.camel@gaston","subject":"Re: cogito \"origin\" vs. HEAD","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-03T06:49:43Z","receivedAt":"2005-05-03T06:49:43Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, May 03, 2005 at 05:24:19AM CEST, I got a letter\nwhere Benjamin Herrenschmidt <benh@kernel.crashing.org> told me that...\n> Hi !\n\nHi,\n\n> So when I later do cg-pull or cg-update origin to update, my \"origin\"\n> pointer is updated I suppose to the new head of the remote repository,\n> does it also update my local \"refs/heads/master\" ? Or not ? What happens\n> to it ? does anything will use my local HEAD -> refs/heads/master/\n> ever ? If I want to publish my tree, what will remote cogito's try to\n> rsync down ? HEAD ? origin ?\n\nwhen accessing the remote repository, Cogito always looks for remote\nrefs/heads/master first - if that one isn't there, it takes HEAD, but\nthere is no correlation between the local and remote branch name. If you\nwant to fetch a different branch from the remote repository, use the\nfragment identifier (see cg-help cg-branch-add).\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"2455","messageId":"1115104408.6156.100.camel@gaston","threadId":"452","inReplyTo":"20050503064943.GB10244@pasky.ji.cz","subject":"Re: cogito \"origin\" vs. HEAD","fromName":"Benjamin Herrenschmidt","fromEmail":"benh@kernel.crashing.org","sentAt":"2005-05-03T07:13:28Z","receivedAt":"2005-05-03T07:13:28Z","isPatch":false,"sender":{"key":"benh@kernel.crashing.org","avatar":null},"body":"\n> when accessing the remote repository, Cogito always looks for remote\n> refs/heads/master first - if that one isn't there, it takes HEAD, but\n> there is no correlation between the local and remote branch name. If you\n> want to fetch a different branch from the remote repository, use the\n> fragment identifier (see cg-help cg-branch-add).\n\nOk, that I'm getting. So then, what happen of my local\nrefs/heads/<branchname> and refs/heads/master/ ? I'm still a bit\nconfused by the whole branch mecanism... It's my understanding than when\nI cg-init, it creates both \"master\" (a head without matching branch)\nand \"origin\" (a branch  + a head) both having the same sha1. It also\nchecks out the tree.\n\nNow, when I cg-update origin, what happens exactly ? I mean, I know it's\npulls all objects, then get the master from the remote pointed by the\norigin branch, but then, I suppose it updates both my local \"origin\" and\nmy local \"master\" pointer, right ? I mean, they are always in sync ? Or\nis this related to what branch my current checkout is tracking ?\n\nBen.\n\n\n"},{"id":"2460","messageId":"200505031306.51520.snake@penza-gsm.ru","threadId":"452","inReplyTo":"1115104408.6156.100.camel@gaston","subject":"Re: cogito \"origin\" vs. HEAD","fromName":"Alexey Nezhdanov","fromEmail":"snake@penza-gsm.ru","sentAt":"2005-05-03T09:06:51Z","receivedAt":"2005-05-03T09:06:51Z","isPatch":false,"sender":{"key":"snake@penza-gsm.ru","avatar":null},"body":"At Tuesday, 03 May 2005 11:13 Benjamin Herrenschmidt wrote:\n> > when accessing the remote repository, Cogito always looks for remote\n> > refs/heads/master first - if that one isn't there, it takes HEAD, but\n> > there is no correlation between the local and remote branch name. If you\n> > want to fetch a different branch from the remote repository, use the\n> > fragment identifier (see cg-help cg-branch-add).\n>\n> Ok, that I'm getting. So then, what happen of my local\n> refs/heads/<branchname> and refs/heads/master/ ? I'm still a bit\n> confused by the whole branch mecanism... It's my understanding than when\n> I cg-init, it creates both \"master\" (a head without matching branch)\n> and \"origin\" (a branch  + a head) both having the same sha1. It also\n> checks out the tree.\n>\n> Now, when I cg-update origin, what happens exactly ? I mean, I know it's\n> pulls all objects, then get the master from the remote pointed by the\n> origin branch, but then, I suppose it updates both my local \"origin\" and\n> my local \"master\" pointer, right ? I mean, they are always in sync ? Or\n> is this related to what branch my current checkout is tracking ?\nIf I understand this mechanics correctly then \"master head\" always track your \nlocal tree (i.e. with all remote and local patches applied) and \"origin head\" \nalways tracking head of the remote branch from where you are getting objects.\n\nI.e. it is really a tree, not source of objects. The tree can be strored on \nmany different hosts but it is the same across them. But the master tree have \nno source to sync from - you are creating it yourself locally so there is no \n\"master branch\" - only head.\n\nSo if you are just tracking some other tree and do not do any merges/patches \nyourself then your master head will always match your remote source head \n(\"origin\" in most cases).\n\n-- \nRespectfully\nAlexey Nezhdanov\n\n"},{"id":"2461","messageId":"20050503094723.GA22436@pasky.ji.cz","threadId":"452","inReplyTo":"1115104408.6156.100.camel@gaston","subject":"Re: cogito \"origin\" vs. HEAD","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-03T09:47:23Z","receivedAt":"2005-05-03T09:47:23Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, May 03, 2005 at 09:13:28AM CEST, I got a letter\nwhere Benjamin Herrenschmidt <benh@kernel.crashing.org> told me that...\n> > when accessing the remote repository, Cogito always looks for remote\n> > refs/heads/master first - if that one isn't there, it takes HEAD, but\n> > there is no correlation between the local and remote branch name. If you\n> > want to fetch a different branch from the remote repository, use the\n> > fragment identifier (see cg-help cg-branch-add).\n> \n> Ok, that I'm getting. So then, what happen of my local\n> refs/heads/<branchname> and refs/heads/master/ ? I'm still a bit\n> confused by the whole branch mecanism... It's my understanding than when\n> I cg-init, it creates both \"master\" (a head without matching branch)\n> and \"origin\" (a branch  + a head) both having the same sha1. It also\n> checks out the tree.\n> \n> Now, when I cg-update origin, what happens exactly ? I mean, I know it's\n> pulls all objects, then get the master from the remote pointed by the\n> origin branch, but then, I suppose it updates both my local \"origin\" and\n> my local \"master\" pointer, right ? I mean, they are always in sync ? Or\n> is this related to what branch my current checkout is tracking ?\n\nThey are in sync as long as you update only from that given branch.\nAt the moment you do a local commit, they get out of sync, at least\nuntil your master branch is merged to the origin branch on the other\nside. Every cg-update will then generate a merging commit, so it will\nlook like this:\n\n     [origin]    [master]\n            commit1\n              |\n            commit2               Both heads are in sync so far...\n              |\n            commit3\n             /    \\\n            /     commit4         Now heads/master is commit4, but\n           /        |             heads/origin is still commit3\n          /         |\n      commit5-.     |             heads/master:commit4, heads/origin:commit5\n          |    \\    |\n          |     `-commit6         commit6 merges origin to master\n          |       /\n          |     /\n          |   /\n      commit6                     origin merged your master; since it\n                                  contained all the commits on the origin\n               |                  branch, it just took over the commit6\n             commit6              commit pointer as its new head; so both\n                                  heads are again in sync now\n\n\nThis is the reason why there are always at least two branches, origin\nand master. The checked out tree is always of the master branch (unless\nyou do cg-seek, which is somewhat special anyway). [*] \"Normally\", when\nyou do no local changes and just always cg-update the origin branch, the\ntwo branches are always in sync. At the point you start to \"mix\" several\nremote branches besides origin in your tree, or at the point you do a\nlocal commit, the master branch gets standalone - until the origin\nmerges your changes as drawn in the diagram.\n\nThere is one other situation when the head pointers may not be in sync -\nwhen you do cg-pull instead of cg-update. You want to see what are the\nchanges in the origin branch, but you are not sure if you want them to\nappear in your master branch, you do cg-pull origin. Your origin head\npointer is updated, but your master pointer stays where it is. If you\ndecide it's ok to bring the changes in, you do either cg-update, or only\ncg-merge to avoid re-pulling.\n\n\n[*] Technically, you can have multiple local branches and your tree can\nbe based on any of them, not only \"master\". Cogito supports that\ninternally, but (deliberately) provides no UI to set that up, at least\nuntil we devise a way to do it without confusing people even more.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"2551","messageId":"1115164160.7627.55.camel@gaston","threadId":"452","inReplyTo":"20050503094723.GA22436@pasky.ji.cz","subject":"Re: cogito \"origin\" vs. HEAD","fromName":"Benjamin Herrenschmidt","fromEmail":"benh@kernel.crashing.org","sentAt":"2005-05-03T23:49:20Z","receivedAt":"2005-05-03T23:49:20Z","isPatch":false,"sender":{"key":"benh@kernel.crashing.org","avatar":null},"body":"On Tue, 2005-05-03 at 11:47 +0200, Petr Baudis wrote:\n> Dear diary, on Tue, May 03, 2005 at 09:13:28AM CEST, I got a letter\n> where Benjamin Herrenschmidt <benh@kernel.crashing.org> told me that...\n> > > when accessing the remote repository, Cogito always looks for remote\n> > > refs/heads/master first - if that one isn't there, it takes HEAD, but\n> > > there is no correlation between the local and remote branch name. If you\n> > > want to fetch a different branch from the remote repository, use the\n> > > fragment identifier (see cg-help cg-branch-add).\n> > \n> > Ok, that I'm getting. So then, what happen of my local\n> > refs/heads/<branchname> and refs/heads/master/ ? I'm still a bit\n> > confused by the whole branch mecanism... It's my understanding than when\n> > I cg-init, it creates both \"master\" (a head without matching branch)\n> > and \"origin\" (a branch  + a head) both having the same sha1. It also\n> > checks out the tree.\n> > \n> > Now, when I cg-update origin, what happens exactly ? I mean, I know it's\n> > pulls all objects, then get the master from the remote pointed by the\n> > origin branch, but then, I suppose it updates both my local \"origin\" and\n> > my local \"master\" pointer, right ? I mean, they are always in sync ? Or\n> > is this related to what branch my current checkout is tracking ?\n> \n> They are in sync as long as you update only from that given branch.\n> At the moment you do a local commit, they get out of sync, at least\n> until your master branch is merged to the origin branch on the other\n> side. Every cg-update will then generate a merging commit, so it will\n> look like this:\n> > .../...\n\nThanks for that detailed explanation !\n\nBen.\n\n\n"}]}