{"thread":{"id":"26689","subject":"git fast-import : How to change parent during import?","startedAt":"2011-03-08T01:21:45Z","lastAt":"2011-08-29T01:13:46Z","messageCount":9,"participants":["Vitor Antunes","Jonathan Nieder","Sverre Rabbelier"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"162956","messageId":"AANLkTikiEfUSdNqqTjuYy_JLJnEyCizmusSucYsEHC2r@mail.gmail.com","threadId":"26689","inReplyTo":null,"subject":"git fast-import : How to change parent during import?","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-03-08T01:21:45Z","receivedAt":"2011-03-08T01:21:45Z","isPatch":false,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Hi everyone,\n\nIs it possible to change the parent of a commit during fast import?\nI've tried using \"reset\" command and making a new commit pointing to a\nnew parent, but in both cases I get a \"new tip ... does not contain\n...\" error message.\n\nProviding a bit of context. I'm trying to improve git-p4 to detect the\nparent commit of a new branch. Unfortunately, in Perforce a branch is\nnothing more than a copy of a bunch of files into a new location.\nBecause the origin of the copy can be any past commit and there is no\ninformation about which commit was used it is very difficult to\nidentify a parent of a new branch. But if we assume that in this copy\nprocess no file is modified then it should be possible to identify the\nparent commit simply by comparing their SHA-1.\nTo achieve this I used the checkpoint command to flush the list of\nimported commits to disk and then used standard rev-list and diff-tree\ncommands to make find the parent commit. I am now at a point where I\nam able to correctly identify the parent commit, but when trying to\nupdate the from information I get the above message.\n\nThanks in advance for your help,\n-- \nVitor Antunes\n"},{"id":"162959","messageId":"20110308024427.GA21471@elie","threadId":"26689","inReplyTo":"AANLkTikiEfUSdNqqTjuYy_JLJnEyCizmusSucYsEHC2r@mail.gmail.com","subject":"Re: git fast-import : How to change parent during import?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-03-08T02:44:27Z","receivedAt":"2011-03-08T02:44:27Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nVitor Antunes wrote:\n\n> Is it possible to change the parent of a commit during fast import?\n> I've tried using \"reset\" command and making a new commit pointing to a\n> new parent, but in both cases I get a \"new tip ... does not contain\n> ...\" error message.\n\nHave you tried \"git fast-import --force\"?\n\n> Providing a bit of context. I'm trying to improve git-p4 to detect the\n> parent commit of a new branch.\n[...]\n> To achieve this I used the checkpoint command to flush the list of\n> imported commits to disk and then used standard rev-list and diff-tree\n> commands to make find the parent commit. I am now at a point where I\n> am able to correctly identify the parent commit, but when trying to\n> update the from information I get the above message.\n\nThe advice in the section \"Use Tag Fixup Branches\" of git-fast-import(1)\nmight be useful.\n\nThanks for an interesting example, and hope that helps.\nJonathan\n"},{"id":"163023","messageId":"AANLkTini6NgeYxRdFtSDKe8GEEszDvXwRtLnuymiRNt4@mail.gmail.com","threadId":"26689","inReplyTo":"20110308024427.GA21471@elie","subject":"Re: git fast-import : How to change parent during import?","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-03-08T21:19:50Z","receivedAt":"2011-03-08T21:19:50Z","isPatch":false,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Hi Jonathan,\n\nOn Tue, Mar 8, 2011 at 2:44 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> Is it possible to change the parent of a commit during fast import?\n>> I've tried using \"reset\" command and making a new commit pointing to a\n>> new parent, but in both cases I get a \"new tip ... does not contain\n>> ...\" error message.\n>\n> Have you tried \"git fast-import --force\"?\n\nOh... I completely overlooked the command line argument list in the man page...\nThanks for the tip, worked like a charm!\n\n>> Providing a bit of context. I'm trying to improve git-p4 to detect the\n>> parent commit of a new branch.\n> [...]\n>> To achieve this I used the checkpoint command to flush the list of\n>> imported commits to disk and then used standard rev-list and diff-tree\n>> commands to make find the parent commit. I am now at a point where I\n>> am able to correctly identify the parent commit, but when trying to\n>> update the from information I get the above message.\n>\n> The advice in the section \"Use Tag Fixup Branches\" of git-fast-import(1)\n> might be useful.\n\nI'm still trying to understand it. Do you know of any practical\nexample that I can look into?\n\nThanks for your help,\n-- \nVitor Antunes\n"},{"id":"163035","messageId":"20110308222328.GE26471@elie","threadId":"26689","inReplyTo":"AANLkTini6NgeYxRdFtSDKe8GEEszDvXwRtLnuymiRNt4@mail.gmail.com","subject":"Re: git fast-import : How to change parent during import?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-03-08T22:23:28Z","receivedAt":"2011-03-08T22:23:28Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nVitor Antunes wrote:\n> On Tue, Mar 8, 2011 at 2:44 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n\n>> The advice in the section \"Use Tag Fixup Branches\" of git-fast-import(1)\n>> might be useful.\n>\n> I'm still trying to understand it. Do you know of any practical\n> example that I can look into?\n\nIt's likely I misunderstood what you're trying to do.  If you have\nsome work in progress, I'd be glad to look at it.\n\nAnyway, concerning tag fixup branches: git://repo.or.cz/cvs2svn.git\nhas an example in cvs2svn_lib/git_output_option.py::process_tag_commit.\nThe idea is to make commits that don't belong to any branch on a\nseparate TAG_FIXUP ref, using the \"reset\" command where appropriate;\nthen the resulting commits can be inspected, merged, reset to, or used\nin some other way later.\n\nThe \"tag fixup\" idea is that in VCSes like CVS, tags do not\nnecessarily match the content on any branch.  So the history looks\nsomewhat like so (time flowing left to right):\n\n                     TAG\n                    /\n o --- o --- o --- o --- o --- o ...\n\ninstead of the perhaps more sensible\n\n o --- o --- o --- TAG --- o --- o ...\n\nThe side branch leading up to a tag does not correspond to any branch\nname; after it is in the correct state one can use the \"tag\" command\nto get it remembered in permanent history.  The same technique might\nbe useful whenever you are creating history that is not meant to stay\npermanently on any branch.\n\nJonathan\n"},{"id":"163058","messageId":"AANLkTin-Zpk1mZ4hWy1HVL68a0qFjv=8Gne3FBNH8nio@mail.gmail.com","threadId":"26689","inReplyTo":"20110308222328.GE26471@elie","subject":"Re: git fast-import : How to change parent during import?","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-03-09T14:21:05Z","receivedAt":"2011-03-09T14:21:05Z","isPatch":false,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Hi Jonathan,\n\nOn Tue, Mar 8, 2011 at 10:23 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> It's likely I misunderstood what you're trying to do.  If you have\n> some work in progress, I'd be glad to look at it.\n>\n> Anyway, concerning tag fixup branches: git://repo.or.cz/cvs2svn.git\n> has an example in cvs2svn_lib/git_output_option.py::process_tag_commit.\n> The idea is to make commits that don't belong to any branch on a\n> separate TAG_FIXUP ref, using the \"reset\" command where appropriate;\n> then the resulting commits can be inspected, merged, reset to, or used\n> in some other way later.\n>\n> The \"tag fixup\" idea is that in VCSes like CVS, tags do not\n> necessarily match the content on any branch.  So the history looks\n> somewhat like so (time flowing left to right):\n>\n>                     TAG\n>                    /\n>  o --- o --- o --- o --- o --- o ...\n>\n> instead of the perhaps more sensible\n>\n>  o --- o --- o --- TAG --- o --- o ...\n>\n> The side branch leading up to a tag does not correspond to any branch\n> name; after it is in the correct state one can use the \"tag\" command\n> to get it remembered in permanent history.  The same technique might\n> be useful whenever you are creating history that is not meant to stay\n> permanently on any branch.\n\nI think I understood the idea behind TAG_FIXUP and I think it can be a\nbetter solution for my problem. I could make the commit into\nTAG_FIXUP, search for a better parent in the source branch and then\nreset it to that parent or rebase it over any other commit. I'll try\nto do this in the following days, so I will most likely come back with\nmore doubts :)\n\nThanks,\n-- \nVitor Antunes\n"},{"id":"164699","messageId":"20110330182554.5375787b@fenix.utopia.dhis.org","threadId":"26689","inReplyTo":"20110308222328.GE26471@elie","subject":"Re: git fast-import : How to change parent during import?","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-03-30T17:25:54Z","receivedAt":"2011-03-30T17:25:54Z","isPatch":false,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Hi Jonathan,\n\nOn Tue, 8 Mar 2011 16:23:28 -0600\nJonathan Nieder <jrnieder@gmail.com> wrote:\n\n> The \"tag fixup\" idea is that in VCSes like CVS, tags do not\n> necessarily match the content on any branch.  So the history looks\n> somewhat like so (time flowing left to right):\n> \n>                      TAG\n>                     /\n>  o --- o --- o --- o --- o --- o ...\n> \n> instead of the perhaps more sensible\n> \n>  o --- o --- o --- TAG --- o --- o ...\n> \n> The side branch leading up to a tag does not correspond to any branch\n> name; after it is in the correct state one can use the \"tag\" command\n> to get it remembered in permanent history.  The same technique might\n> be useful whenever you are creating history that is not meant to stay\n> permanently on any branch.\n\nI don't think the TAG_FIXUP trick is what I need in this case. Assume the\nfollowing:\n\nA --- B --- C --- D ...    (branch1)\n      \\\n       E --- F --- G ...   (branch2)\n\nNow assume that we are at commit D when we detect a commit to branch2. At this\npoint there is no way of knowing the origin commit in branch1. What is currently\nbeing done is to use commit D as the parent of branch2, which is incorrect. But\nif we assume that all branches are created through a \"cp\" like command, then we\nknow that B=E. So my idea is to go over A, B, C, etc and commit E \"from:\" each\none and see which results in a zero differences diff-tree.\n\nUnfortunately, the current implementation I am using doesn't feel simple enough.\nBecause I'm using commands external to fast-import, I need to be constantly\nmaking use of \"checkpoint\". And this seems to not be good enough, because I need\nto sleep during 0.1s (didn't try other values) after each \"checkpoint\" before\nbeing able to use diff-tree and similar commands. I am also forced to use the\n\"--force\" command due to all the orphan commits I leave behind.\n\nI would really prefer to have a simpler solution. Do you, or anyone else, see\nanother option?\n\nThanks in advance,\n-- \nVitor Antunes\n"},{"id":"174424","messageId":"20110828162325.5f479ef7@fenix.utopia.dhis.org","threadId":"26689","inReplyTo":"20110308024427.GA21471@elie","subject":"Re: git fast-import : How to change parent during import?","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-08-28T15:23:25Z","receivedAt":"2011-08-28T15:23:25Z","isPatch":false,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"On Mon, 7 Mar 2011 20:44:27 -0600\nJonathan Nieder <jrnieder@gmail.com> wrote:\n\n> > Is it possible to change the parent of a commit during fast import?\n> > I've tried using \"reset\" command and making a new commit pointing to a\n> > new parent, but in both cases I get a \"new tip ... does not contain\n> > ...\" error message.\n> \n> Have you tried \"git fast-import --force\"?\n\nI know this is an old topic, but I'm looking into this again now. What I'm\nnow trying to do is to stop using \"--force\".\n\nIs there a way to manually force fast-import to drop an old commit that the\nfrontend script decided it was no longer necessary?\n\nThanks,\n-- \nVitor Antunes\n"},{"id":"174434","messageId":"20110828233931.GD29351@elie.gateway.2wire.net","threadId":"26689","inReplyTo":"20110828162325.5f479ef7@fenix.utopia.dhis.org","subject":"Re: git fast-import : How to change parent during import?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-08-28T23:39:32Z","receivedAt":"2011-08-28T23:39:32Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Vitor Antunes wrote:\n\n> Is there a way to manually force fast-import to drop an old commit that the\n> frontend script decided it was no longer necessary?\n\nSure --- patch fast-import (I'd be happy to review such a patch). :)\n"},{"id":"174435","messageId":"CAGdFq_hC10YgV2Cf_ZSu5LvyFxV6wq1atx9q4kFsP8zQpii9YA@mail.gmail.com","threadId":"26689","inReplyTo":"20110828233931.GD29351@elie.gateway.2wire.net","subject":"Re: git fast-import : How to change parent during import?","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2011-08-29T01:13:46Z","receivedAt":"2011-08-29T01:13:46Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Mon, Aug 29, 2011 at 01:39, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Vitor Antunes wrote:\n>> Is there a way to manually force fast-import to drop an old commit that the\n>> frontend script decided it was no longer necessary?\n>\n> Sure --- patch fast-import (I'd be happy to review such a patch). :)\n\nThat's actually a feature that we need for remote-helpers as well (to\nbe able to drop refs). Would be nice to have a 'drop ref' command in\nfast export :).\n\n-- \nCheers,\n\nSverre Rabbelier\n"}]}