{"thread":{"id":"14120","subject":"git-fetch remote tag to local branch fails","startedAt":"2008-06-24T12:17:39Z","lastAt":"2008-06-25T09:10:38Z","messageCount":10,"participants":["Klas Lindberg","Santi Béjar","Michael J Gruber","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"80881","messageId":"33f4f4d70806240517h5e3ae420h263dd0c2d6bae459@mail.gmail.com","threadId":"14120","inReplyTo":null,"subject":"git-fetch remote tag to local branch fails","fromName":"Klas Lindberg","fromEmail":"klas.lindberg@gmail.com","sentAt":"2008-06-24T12:17:39Z","receivedAt":"2008-06-24T12:17:39Z","isPatch":false,"sender":{"key":"klas.lindberg@gmail.com","avatar":null},"body":"Hi\n\nI have a repository \"bogustree\" that contains tags \"test_tag\" and\n\"foo_tag\" (both on the same branch, with \"test_tag\" pointing to an\nolder commit).\nI also have repository \"R\", which contains \"test_tag\" from \"bogustree\"\nand a branch \"b\" created from \"test_tag\". The active branch in R is\n\"master\".\n\nNow I want to do the following from R:\n\ngit-fetch bogustree refs/tags/foo_tag:refs/heads/b\n\nbut this fails with the message given below. The interesting part is\nthat git-fetch tries to write a \"non-commit object\" and indeed I have\nno idea what this thing is (the commit pointed to by \"foo_tag\" has\ncommit ID cab0a25388f1884a1ab16bd0d66f877c0b36f1d5). Another\ninteresting detail is that the command fails and then continues\nanyway. That seems wrong in itself.\n\n# remote: Counting objects: 6, done.\n# remote: Compressing objects: 100% (2/2), done.\n# remote: Total 4 (delta 0), reused 0 (delta 0)\n# Unpacking objects: 100% (4/4), done.\n# error: Trying to write non-commit object\n5f61233bc5dad0f3e25ecea65457f5bb528174d2 to branch refs/heads/B\n# From /home/qliklas/bogustree/b/b\n#    72f0622..5f61233  foo_tag    -> b\n# From /home/qliklas/bogustree/b/b\n#  * [new tag]         foo_tag    -> foo_tag\n#  * [new tag]         test_tag   -> test_tag\n\nWhy can't I fetch like this? The manual page for git-fetch says that\n\n       <refspec>\n              The canonical format of a <refspec> parameter is +?<src>:<dst>;\n              that is, an optional plus +, followed by the source ref,\n              followed by a colon :, followed by the destination ref.\n\n              The remote ref that matches <src> is fetched, and if <dst> is\n              not empty string, the local ref that matches it is fast\n              forwarded using <src>. Again, if the optional plus + is used,\n              the local ref is updated even if it does not result in a fast\n              forward update.\n\nso I think it should be OK?\n\nBR / Klas\n"},{"id":"80892","messageId":"8aa486160806240638o221b01d2i2f46cc8f0f3760a3@mail.gmail.com","threadId":"14120","inReplyTo":"33f4f4d70806240517h5e3ae420h263dd0c2d6bae459@mail.gmail.com","subject":"Re: git-fetch remote tag to local branch fails","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-06-24T13:38:12Z","receivedAt":"2008-06-24T13:38:12Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Tue, Jun 24, 2008 at 14:17, Klas Lindberg <klas.lindberg@gmail.com> wrote:\n> Hi\n>\n> I have a repository \"bogustree\" that contains tags \"test_tag\" and\n> \"foo_tag\" (both on the same branch, with \"test_tag\" pointing to an\n> older commit).\n> I also have repository \"R\", which contains \"test_tag\" from \"bogustree\"\n> and a branch \"b\" created from \"test_tag\". The active branch in R is\n> \"master\".\n>\n> Now I want to do the following from R:\n>\n> git-fetch bogustree refs/tags/foo_tag:refs/heads/b\n>\n> but this fails with the message given below. The interesting part is\n> that git-fetch tries to write a \"non-commit object\" and indeed I have\n> no idea what this thing is (the commit pointed to by \"foo_tag\" has\n> commit ID cab0a25388f1884a1ab16bd0d66f877c0b36f1d5).\n\nnon-commit object is an object that is not a commit, like a tag, a\nblob or a tree, and you are trying to write a tag in refs/heads/. Only\ncommits objects (no tags) are allowed in refs/heads/.\n\n\n> Another\n> interesting detail is that the command fails and then continues\n> anyway. That seems wrong in itself.\n>\n> # remote: Counting objects: 6, done.\n> # remote: Compressing objects: 100% (2/2), done.\n> # remote: Total 4 (delta 0), reused 0 (delta 0)\n> # Unpacking objects: 100% (4/4), done.\n> # error: Trying to write non-commit object\n> 5f61233bc5dad0f3e25ecea65457f5bb528174d2 to branch refs/heads/B\n> # From /home/qliklas/bogustree/b/b\n> #    72f0622..5f61233  foo_tag    -> b\n> # From /home/qliklas/bogustree/b/b\n> #  * [new tag]         foo_tag    -> foo_tag\n> #  * [new tag]         test_tag   -> test_tag\n\nAre you sure it is written as a branch? What is the output of \"git tag\n-l\" and \"git branch -a\"?\n\n\n>\n> Why can't I fetch like this? The manual page for git-fetch says that\n>\n>       <refspec>\n>              The canonical format of a <refspec> parameter is +?<src>:<dst>;\n>              that is, an optional plus +, followed by the source ref,\n>              followed by a colon :, followed by the destination ref.\n>\n>              The remote ref that matches <src> is fetched, and if <dst> is\n>              not empty string, the local ref that matches it is fast\n>              forwarded using <src>. Again, if the optional plus + is used,\n>              the local ref is updated even if it does not result in a fast\n>              forward update.\n>\n> so I think it should be OK?\n\nas long as <src> are commit objects.\n\nSanti\n"},{"id":"80897","messageId":"33f4f4d70806240701o1c00cef2g688a188970964b0f@mail.gmail.com","threadId":"14120","inReplyTo":"8aa486160806240638o221b01d2i2f46cc8f0f3760a3@mail.gmail.com","subject":"Re: git-fetch remote tag to local branch fails","fromName":"Klas Lindberg","fromEmail":"klas.lindberg@gmail.com","sentAt":"2008-06-24T14:01:13Z","receivedAt":"2008-06-24T14:01:13Z","isPatch":false,"sender":{"key":"klas.lindberg@gmail.com","avatar":null},"body":"Hello\n\n> git tag -l\nfoo_tag\ntest_tag\n>\n\n> git branch -a\n>\n\nAt this point, I can create the branch \"b\" from \"foo_tag\", so the\nfetch did get me a remote tag. It just didn't update a local branch\nwith the contents (or create a new one).\n\nSomething that also confuses me is that if branch \"b\" already exists, then\n\n> git-pull bogustree refs/tags/foo_tag:refs/heads/b\n\nactually does update branch \"b\". I find the behaviour quite inconsistent.\n\nUnfortunately it isn't a solution for me to fetch tags and then create\nbranches from the tags. I need to be able to update existing branches,\nand I have to do that without first making such a branch the current\nbranch.\n\nAny suggestions?\n\n/Klas\n\nOn Tue, Jun 24, 2008 at 3:38 PM, Santi Béjar <sbejar@gmail.com> wrote:\n> On Tue, Jun 24, 2008 at 14:17, Klas Lindberg <klas.lindberg@gmail.com> wrote:\n>> Hi\n>>\n>> I have a repository \"bogustree\" that contains tags \"test_tag\" and\n>> \"foo_tag\" (both on the same branch, with \"test_tag\" pointing to an\n>> older commit).\n>> I also have repository \"R\", which contains \"test_tag\" from \"bogustree\"\n>> and a branch \"b\" created from \"test_tag\". The active branch in R is\n>> \"master\".\n>>\n>> Now I want to do the following from R:\n>>\n>> git-fetch bogustree refs/tags/foo_tag:refs/heads/b\n>>\n>> but this fails with the message given below. The interesting part is\n>> that git-fetch tries to write a \"non-commit object\" and indeed I have\n>> no idea what this thing is (the commit pointed to by \"foo_tag\" has\n>> commit ID cab0a25388f1884a1ab16bd0d66f877c0b36f1d5).\n>\n> non-commit object is an object that is not a commit, like a tag, a\n> blob or a tree, and you are trying to write a tag in refs/heads/. Only\n> commits objects (no tags) are allowed in refs/heads/.\n>\n>\n>> Another\n>> interesting detail is that the command fails and then continues\n>> anyway. That seems wrong in itself.\n>>\n>> # remote: Counting objects: 6, done.\n>> # remote: Compressing objects: 100% (2/2), done.\n>> # remote: Total 4 (delta 0), reused 0 (delta 0)\n>> # Unpacking objects: 100% (4/4), done.\n>> # error: Trying to write non-commit object\n>> 5f61233bc5dad0f3e25ecea65457f5bb528174d2 to branch refs/heads/B\n>> # From /home/qliklas/bogustree/b/b\n>> #    72f0622..5f61233  foo_tag    -> b\n>> # From /home/qliklas/bogustree/b/b\n>> #  * [new tag]         foo_tag    -> foo_tag\n>> #  * [new tag]         test_tag   -> test_tag\n>\n> Are you sure it is written as a branch? What is the output of \"git tag\n> -l\" and \"git branch -a\"?\n>\n>\n>>\n>> Why can't I fetch like this? The manual page for git-fetch says that\n>>\n>>       <refspec>\n>>              The canonical format of a <refspec> parameter is +?<src>:<dst>;\n>>              that is, an optional plus +, followed by the source ref,\n>>              followed by a colon :, followed by the destination ref.\n>>\n>>              The remote ref that matches <src> is fetched, and if <dst> is\n>>              not empty string, the local ref that matches it is fast\n>>              forwarded using <src>. Again, if the optional plus + is used,\n>>              the local ref is updated even if it does not result in a fast\n>>              forward update.\n>>\n>> so I think it should be OK?\n>\n> as long as <src> are commit objects.\n>\n> Santi\n>\n"},{"id":"80903","messageId":"8aa486160806240727r6fc6de6doec8300700293a3a7@mail.gmail.com","threadId":"14120","inReplyTo":"33f4f4d70806240701o1c00cef2g688a188970964b0f@mail.gmail.com","subject":"Re: git-fetch remote tag to local branch fails","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-06-24T14:27:49Z","receivedAt":"2008-06-24T14:27:49Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Tue, Jun 24, 2008 at 16:01, Klas Lindberg <klas.lindberg@gmail.com> wrote:\n> Hello\n>\n>> git tag -l\n> foo_tag\n> test_tag\n>>\n>\n>> git branch -a\n>>\n\nempty?\n\n>\n> At this point, I can create the branch \"b\" from \"foo_tag\", so the\n> fetch did get me a remote tag. It just didn't update a local branch\n> with the contents (or create a new one).\n>\n> Something that also confuses me is that if branch \"b\" already exists, then\n>\n>> git-pull bogustree refs/tags/foo_tag:refs/heads/b\n>\n> actually does update branch \"b\". I find the behaviour quite inconsistent.\n\nYou asked explicitly to update branch b with :refs/heads/b.\n\n>\n> Unfortunately it isn't a solution for me to fetch tags and then create\n> branches from the tags. I need to be able to update existing branches,\n> and I have to do that without first making such a branch the current\n> branch.\n>\n\nIf you have to update existing branches from remote branches you can:\n\ngit fetch <remote> refs/heads/<remotebranch>:refs/heads/<localbranch>\n\nBut normally you have some remote tracking branches, such as how the\n\"origin\" remote repository is configured.\n\nUpdating from remote tags is not normal, since tags are not supposed to change.\n\nCan you explain why you have to do it this way? Or the whole workflow?\n\nSanti\n\nP.D.: Please, do not toppost.\n"},{"id":"80906","messageId":"g3r1vv$7dr$1@ger.gmane.org","threadId":"14120","inReplyTo":"33f4f4d70806240701o1c00cef2g688a188970964b0f@mail.gmail.com","subject":"Re: git-fetch remote tag to local branch fails","fromName":"Michael J Gruber","fromEmail":"michaeljgruber+gmane@fastmail.fm","sentAt":"2008-06-24T14:57:02Z","receivedAt":"2008-06-24T14:57:02Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Klas Lindberg venit, vidit, dixit 24.06.2008 16:01:\n> Hello\n> \n>> git tag -l\n> foo_tag\n> test_tag\n> \n>> git branch -a\n>>\n> \n> At this point, I can create the branch \"b\" from \"foo_tag\", so the\n> fetch did get me a remote tag. It just didn't update a local branch\n> with the contents (or create a new one).\n> \n> Something that also confuses me is that if branch \"b\" already exists, then\n> \n>> git-pull bogustree refs/tags/foo_tag:refs/heads/b\n> \n> actually does update branch \"b\". I find the behaviour quite inconsistent.\n\nYou tell git to fetch everything up to the tag you specify, to store \nthose refs into branch b, and then to merge into the current branch. \nThis is what git did (assuming you see the merge in the current branch; \nif it's b then it has been fast forwarded already).\n\n> Unfortunately it isn't a solution for me to fetch tags and then create\n> branches from the tags. I need to be able to update existing branches,\n> and I have to do that without first making such a branch the current\n> branch.\n\nIf I try what you described (using git 1.5.6) in a fresh repo (with one \nempty commit) I get:\n\ngit fetch ../fromrepo refs/tags/testtag:refs/heads/newbranch\nwarning: no common commits\nremote: Counting objects: 18, done.\nremote: Compressing objects: 100% (18/18), done.\nremote: Total 18 (delta 9), reused 0 (delta 0)\nUnpacking objects: 100% (18/18), done.\n From ../fromrepo\n  * [new branch]      testtag    -> newbranch\n  * [new tag]         testtag    -> testtag\n\nI see a new branch, disconnected from master (no common commits), and a \nnew tag pointing to the head of newbranch. All is well here. Maybe you \ncan set-up a minimal example or share a repo which exposes your problem?\n\nMichael\n"},{"id":"80913","messageId":"33f4f4d70806240831q14caacddp66645e1bcfb6d14b@mail.gmail.com","threadId":"14120","inReplyTo":"8aa486160806240727r6fc6de6doec8300700293a3a7@mail.gmail.com","subject":"Re: git-fetch remote tag to local branch fails","fromName":"Klas Lindberg","fromEmail":"klas.lindberg@gmail.com","sentAt":"2008-06-24T15:31:49Z","receivedAt":"2008-06-24T15:31:49Z","isPatch":false,"sender":{"key":"klas.lindberg@gmail.com","avatar":null},"body":">>> git branch -a\n>>>\n>\n> empty?\n\nSorry, my mistake. It lists \"master\"\n\n>>> git-pull bogustree refs/tags/foo_tag:refs/heads/b\n>>\n>> actually does update branch \"b\". I find the behaviour quite inconsistent.\n>\n> You asked explicitly to update branch b with :refs/heads/b.\n\nI'm not sure what you mean. I asked it to update local branch \"b\"\nagainst remote tag \"foo_tag\" and it did just that. I find it\ninconsistent that pull can do this, but fetch can't.\n\n> Can you explain why you have to do it this way? Or the whole workflow?\n\nI am looking into the possibility of writing a tool that handles\nconfigurations of trees. For instance, I want the tool to be able to\nconsume some version of a configuration and create, update or reset\nbranches in other trees accordingly.\nThe main stumbling block is actually that a lot of git commands have\nside effects on the working tree (usually because they do something\nwith a \"current\" branch). In my mind, the user should be able to\nselect a configuration that effectively fast forwards branches in some\ntrees and resets branches in others -- all of it without touching any\nworking trees (unless there is an explicit checkout).\nThe example in this case is that fetching tags to update a branch\nisn't possible. Pulling *is* possible, but would also update the\ncurrent branch and the working tree.\n\n/Klas\n"},{"id":"80914","messageId":"33f4f4d70806240836q7522192eybdfe7983293c4c6a@mail.gmail.com","threadId":"14120","inReplyTo":"33f4f4d70806240831q14caacddp66645e1bcfb6d14b@mail.gmail.com","subject":"Re: git-fetch remote tag to local branch fails","fromName":"Klas Lindberg","fromEmail":"klas.lindberg@gmail.com","sentAt":"2008-06-24T15:36:56Z","receivedAt":"2008-06-24T15:36:56Z","isPatch":false,"sender":{"key":"klas.lindberg@gmail.com","avatar":null},"body":"> I'm not sure what you mean. I asked it to update local branch \"b\"\n> against remote tag \"foo_tag\" and it did just that. I find it\n> inconsistent that pull can do this, but fetch can't.\n\nI'm sorry. That was plain wrong. It doesn't update the branch from the\nremote tag when I pull.\n\nOh well...\n"},{"id":"80918","messageId":"8aa486160806240911p49d7bcb8q82a8d68c51206543@mail.gmail.com","threadId":"14120","inReplyTo":"33f4f4d70806240831q14caacddp66645e1bcfb6d14b@mail.gmail.com","subject":"Re: git-fetch remote tag to local branch fails","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-06-24T16:11:27Z","receivedAt":"2008-06-24T16:11:27Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Tue, Jun 24, 2008 at 17:31, Klas Lindberg <klas.lindberg@gmail.com> wrote:\n>\n>> Can you explain why you have to do it this way? Or the whole workflow?\n>\n> I am looking into the possibility of writing a tool that handles\n> configurations of trees.\n\nMaybe you should be using the plumbing commands.\n\n> For instance, I want the tool to be able to\n> consume some version of a configuration and create, update or reset\n> branches in other trees accordingly.\n\nWhat are the \"other trees\"?\n\nDo you mean this?\n\n1. You have a repository with different branches as:\n  master\n  tree1\n  tree2\n  ..\n\n2. You want /path/to/tree1 to always checkout tree1\n  and the same for treeN\n\nThen\n\n3. In /path/to/treeN/.. you do:\n$ git clone /path/to/repo treeN\n$ git checkout -b treeN origin/treeN\n\n4. To keep uptodate:\n$ git pull\n\n5. The branches for the other trees are always uptodate in origin/*.\n\n> The main stumbling block is actually that a lot of git commands have\n> side effects on the working tree (usually because they do something\n> with a \"current\" branch).\n\nSure. So you have to choose those that don't have these \"side\neffects\", you have plenty of them, mainly in the low-level, plumbing\ncommands.\n\n> In my mind, the user should be able to\n> select a configuration that effectively fast forwards branches in some\n> trees and resets branches in others -- all of it without touching any\n> working trees (unless there is an explicit checkout).\n\nWell, if you touch the current branch, for sure, you want to update\nthe working tree.\n\nMaybe you want to keep your local branches up to date with respect\ntheir tracking branch?\n\n> The example in this case is that fetching tags to update a branch\n> isn't possible.\n\nI don't see the point updating a branch with a tag, but you can make a\ntool to update a branch with a tag, see for example\ncontrib/examples/git-fetch.sh.\n\nSanti\n"},{"id":"81094","messageId":"33f4f4d70806250150q41f09764m4ae0cc1cd6e15e30@mail.gmail.com","threadId":"14120","inReplyTo":"8aa486160806240911p49d7bcb8q82a8d68c51206543@mail.gmail.com","subject":"Re: git-fetch remote tag to local branch fails","fromName":"Klas Lindberg","fromEmail":"klas.lindberg@gmail.com","sentAt":"2008-06-25T08:50:06Z","receivedAt":"2008-06-25T08:50:06Z","isPatch":false,"sender":{"key":"klas.lindberg@gmail.com","avatar":null},"body":">> I am looking into the possibility of writing a tool that handles\n>> configurations of trees.\n>\n> Maybe you should be using the plumbing commands.\n\nYes. It looks like it.\n\n>> For instance, I want the tool to be able to\n>> consume some version of a configuration and create, update or reset\n>> branches in other trees accordingly.\n>\n> What are the \"other trees\"?\n\nOne tree tracks a configuration file that just contains specs for\nother trees. The idea is something like this: Given a refspec on the\nconfiguration tree, git-view the configuration file and use the\ncontained refspecs to clone/pull/fetch/reset/whatever a bunch of other\ntrees.\n\nNote that I'm not trying to solve the problem addressed by the\nsubmodules system in git; I need configuration management.\n\n> Maybe you want to keep your local branches up to date with respect\n> their tracking branch?\n\nWell yes, but that is only half of it. One of the scenarios I'm\npondering is this: A user wants to take an old configuration based on\ntags and try some use case that breaks a newer configuration. After\nthe checkout, the working trees will not be \"on\" any branches (what's\nthe word for that?). Unfortunately, most people seem to think that\neverything in a VCS happens on a branch. A lot of people will\nincorrectly assume that they are still on their \"working branch\"\nbecause they didn't check out a different branch! They checked out a\ntag and, like myself, have muddy ideas about what that actually means\nin relation to branches. I'd prefer to not have to tell them to try\ngit-lost-found on a 40 different trees to recover commits that they\nmade on non-branches.\n\nI'll have to think more about this. It's not a functionality\nshortcoming, but a UI one.\n\n> I don't see the point updating a branch with a tag, but you can make a\n> tool to update a branch with a tag, see for example\n> contrib/examples/git-fetch.sh.\n\nThank you. I'll have a look at that, but after our conversation I\nthink I was mentally stuck in the land of some other VCS. I know\nperfectly well that a tag is not just a marker along some branch, but\nI realize now that I was thinking of it as if it was.\n\n/Klas\n"},{"id":"81097","messageId":"m3bq1pkhh3.fsf@localhost.localdomain","threadId":"14120","inReplyTo":"33f4f4d70806250150q41f09764m4ae0cc1cd6e15e30@mail.gmail.com","subject":"Re: git-fetch remote tag to local branch fails","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-06-25T09:10:38Z","receivedAt":"2008-06-25T09:10:38Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Klas Lindberg\" <klas.lindberg@gmail.com> writes:\n\n> Note that I'm not trying to solve the problem addressed by the\n> submodules system in git; I need configuration management.\n\nWhy not use one of existing tools (see InterfacesFrontendsAndTools\npage on Git Wiki, http://git.or.cz/gitwiki/), like IsiSetup, or\netckeeper?\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}