{"thread":{"id":"5067","subject":"Strange cogito behaviour","startedAt":"2006-08-01T09:53:24Z","lastAt":"2006-08-01T15:41:16Z","messageCount":3,"participants":["Andy Parkins","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"24503","messageId":"200608011053.25112.andyparkins@gmail.com","threadId":"5067","inReplyTo":null,"subject":"Strange cogito behaviour","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-08-01T09:53:24Z","receivedAt":"2006-08-01T09:53:24Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"Hello,\n\nHope this is the correct list for this report.\n\nAttached is a script that demonstrates (I think) strange cogito behaviour.  \nRun it in a temporary directory.\n\nIt does the following:\n * Create a repository, repo1, add a file to it\n * Create a branch inside repo1 and change the file in it\n * Switches repo1 to master branch\n * Clones repo1 to repo2\n * Switches repo1 to alternate branch\n * Updates repo2\n\nThe odd behaviour is that repo2 changes in the update to show the branch \ncontents in the working copy.  The only actions that has happened in repo1 is \na switch of the working directory to a different branch.  It could easily be \nthat I've misunderstood what switch is doing, but the same operations using \ngit seem to work as I'd expect (script available if required).\n\nThe script then continues with\n * Switch repo1 back to master branch\n * Update repo2\n\nThis time repo2 doesn't change.  So I'm more confused :-)\n\nIn case you don't want to run the script, sample output follows:\n--------------------------------------------------------------\n--- Make a project\n--- Turn it into a repository, repo1\ndefaulting to local storage area\nAdding file file\nCommitting initial tree ef18611ce9f2693e47a1b2df5e76613f53a9173c\nCommitted as f59933a07af5f12618deae8d33335621184ccc7c\n--- Create a branch and change it's content\nCreating new branch branch: f59933a07af5f12618deae8d33335621184ccc7c\nSwitching to branch branch...\nM file\nCommitted as 88bc51f62dfa3d71fbc0140fdd48aa150215a632\n--- Switch repo1 back to master\nSwitching to branch master...\n--- Clone repo1 to repo2: repo2 is now the repo1#master\ndefaulting to local storage area\nUsing hard links\nFetching head...\n`/home/andyp/src/git-test/repo1/.git/HEAD' -> \n`.git/refs/heads/./.origin-fetching'\n`/home/andyp/src/git-test/repo1/.git/refs/heads/master' -> \n`.git/refs/heads/./.origin-fetching'\nFetching objects...\nprogress: 3 objects, 239 bytes\nFetching tags...\nNew branch: f59933a07af5f12618deae8d33335621184ccc7c\nCloned to repo2/ (origin /home/andyp/src/git-test/repo1 available as \nbranch \"origin\")\n--- file now contains master contents\ninitial contents goes in master branch\n--- Switch repo1 to branch again\nSwitching to branch branch...\n--- Update repo2\nUsing hard links\nFetching head...\n`/home/andyp/src/git-test/repo1/.git/HEAD' -> \n`.git/refs/heads/./.origin-fetching'\n`/home/andyp/src/git-test/repo1/.git/refs/heads/branch' -> \n`.git/refs/heads/./.origin-fetching'\nFetching objects...\nprogress: 3 objects, 290 bytes\nFetching tags...\nTree change: \nf59933a07af5f12618deae8d33335621184ccc7c:88bc51f62dfa3d71fbc0140fdd48aa150215a632\n\nApplying changes...\nFast-forwarding f59933a07af5f12618deae8d33335621184ccc7c -> \n88bc51f62dfa3d71fbc0140fdd48aa150215a632\n        on top of f59933a07af5f12618deae8d33335621184ccc7c ...\n--- Show contents of both repositories\nrepo1/file:initial contents goes in master branch\nrepo1/file:added in branch - not in master\nrepo2/file:initial contents goes in master branch\nrepo2/file:added in branch - not in master\n---\nWhy has repo2 changed? repo1 had its working copy switched\nrepo2 shouldn't care about what's in the local copy of repo1.\nWhat exactly is repo2#master tracking?  It's certainly not\nrepo1#master.\n--- Switching repo1 back to master\nSwitching to branch master...\n--- Updating repo2 again\nUsing hard links\nFetching head...\n`/home/andyp/src/git-test/repo1/.git/HEAD' -> \n`.git/refs/heads/./.origin-fetching'\n`/home/andyp/src/git-test/repo1/.git/refs/heads/master' -> \n`.git/refs/heads/./.origin-fetching'\nFetching objects...\n\nFetching tags...\nTree change: \n88bc51f62dfa3d71fbc0140fdd48aa150215a632:f59933a07af5f12618deae8d33335621184ccc7c\n\nApplying changes...\nBranch already fully merged.\n--- Show contents of both repositories\nrepo1/file:initial contents goes in master branch\nrepo2/file:initial contents goes in master branch\nrepo2/file:added in branch - not in master\n---\nEven more strange, switching repo1 back to \"master\" and\nupdating repo2, hasn't changed repo2.  The first test showed that\nrepo2 is not tracking #master; but this test shows that repo2\nis not tracking repo1 HEAD either.  What is repo2 tracking?\n(it seems that it's repo1#branch)\n--------------------------------------------------------------\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIEE\nandyparkins@gmail.com\n"},{"id":"24513","messageId":"20060801151258.GB3923@coredump.intra.peff.net","threadId":"5067","inReplyTo":"200608011053.25112.andyparkins@gmail.com","subject":"Re: Strange cogito behaviour","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-01T15:12:58Z","receivedAt":"2006-08-01T15:12:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 01, 2006 at 10:53:24AM +0100, Andy Parkins wrote:\n\n> It does the following:\n>  * Create a repository, repo1, add a file to it\n>  * Create a branch inside repo1 and change the file in it\n>  * Switches repo1 to master branch\n>  * Clones repo1 to repo2\n>  * Switches repo1 to alternate branch\n>  * Updates repo2\n> \n> The odd behaviour is that repo2 changes in the update to show the branch \n> contents in the working copy.  The only actions that has happened in repo1 is \n\nA cogito fetch without a branch specifier defaults to the remote HEAD,\nnot master.  This is the documented behavior (see cg-branch-add(1)). I\nagree it is confusing (I also thought it was a bug until I looked it up\n:) ). If you want to always fetch from the master, you must say so\nexplicitly:\n  $ cg-clone repo1#master repo2\n\n> The script then continues with\n>  * Switch repo1 back to master branch\n>  * Update repo2\n> This time repo2 doesn't change.  So I'm more confused :-)\n\nThis is because repo2's master is already at the branch, and repo1 is a\nsubset of that history. There is no need to merge since repo2 already\ncontains all of the commits in repo1 (plus another one which is only on\nthe branch in repo1).\n\n-Peff\n"},{"id":"24516","messageId":"200608011641.20077.andyparkins@gmail.com","threadId":"5067","inReplyTo":"20060801151258.GB3923@coredump.intra.peff.net","subject":"Re: Strange cogito behaviour","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-08-01T15:41:16Z","receivedAt":"2006-08-01T15:41:16Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Tuesday 2006 August 01 16:12, Jeff King wrote:\n\n> A cogito fetch without a branch specifier defaults to the remote HEAD,\n> not master.  This is the documented behavior (see cg-branch-add(1)). I\n> agree it is confusing (I also thought it was a bug until I looked it up\n\nFair enough.  If it is working as intended, then I have no complaint.\n\n\n> > The script then continues with\n> >  * Switch repo1 back to master branch\n> >  * Update repo2\n> > This time repo2 doesn't change.  So I'm more confused :-)\n>\n> This is because repo2's master is already at the branch, and repo1 is a\n> subset of that history. There is no need to merge since repo2 already\n> contains all of the commits in repo1 (plus another one which is only on\n> the branch in repo1).\n\nI think I see now.  repo2 is neither repo1#master nor repo1#branch because it \nactually went like this:\n * repo1 cloned to repo2, repo2#master is repo1#master\n * repo2 fetches repo1#branch and /merges/ those changes\n * repo1#HEAD switched to HEAD=master\n * repo2 fetch does nothing because repo2 is actually\n   repo1#master + repo1#branch, hence is newer than both\n   repo1#master and repo1#branch\nThat explanation seems to fit exactly with the observed results, so would seem \nto be plausible.\n\nThank you for your help; I of course withdraw my bug report and apologise for \nbothering you all :-)\n\n\nAndy\n\n\n-- \nDr Andy Parkins, M Eng (hons), MIEE\nandyparkins@gmail.com\n"}]}