{"thread":{"id":"31540","subject":"Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?","startedAt":"2012-09-15T12:02:44Z","lastAt":"2012-09-16T06:04:18Z","messageCount":5,"participants":["David Chanters","Junio C Hamano","Christian Couder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"199097","messageId":"CACffvTp4qnHc3RHKDotEfvshVDqGtTX6eh6Fr-bmJSMUvTFN6g@mail.gmail.com","threadId":"31540","inReplyTo":null,"subject":"Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?","fromName":"David Chanters","fromEmail":"david.chanters@googlemail.com","sentAt":"2012-09-15T12:02:44Z","receivedAt":"2012-09-15T12:02:44Z","isPatch":false,"sender":{"key":"david.chanters@googlemail.com","avatar":null},"body":"Hi,\n\nEarlier this month I asked how best to handle two branches without a\ncommon ancestor to sync changes from one branch to another.  Initially\nI did this via the grafts mechanism, but this wasn't a \"shared\"\nsolution, in that the graft was local to my checkout of the repository\nand no one else's.\n\nI read on StackOverflow that git-replace can be used instead.  Having read this:\n\nhttp://stackoverflow.com/questions/3810348/setting-git-parent-pointer-to-a-different-parent\n\nI followed the instructions to use git-replace.  Have successfully\ndone that, I was then able to merge the two branches which didn't have\na common ancestor and have the correct commits on the branch I was\nhoping for.  AFAIAC, this worked fine.\n\nBut now I have some questions:\n\n1.  I thought the replace data in .git/refs/replace was published when\nI did \"git push\" so that others could use this information as a\nbase-point, yet it seems not to be the case.  How do I publish this?\n2.  If I do publish it, are there any caveats with that?  i.e.,\nbecause the replace data will likely point to a repo which in my\nworking checkout I added with \"git-remote\", is that going to be a\nproblem?  I assume I can instruct people who care, to \"git remote add\nfoo ....\" and then treat master and foo/master as intended?  i.e.,\nfoo/master will see commits on it over time which \"master\" won't have,\nso \"git checkout master && git merge foo/master\" can always happen?\n3.  If it is possible to publish this replace data, is there anything\nwhich needs to happen in .git/config either on the bare repo or local\ncheckouts?\n\nWhat I'm aiming for now, in publishing this merge, is that if I can\npublish the replace data, that people besides me, can clone the repo,\nand the remote repo in place, and merge the branches as outlined in\nquestion 2.   What I also am unsure of is whether or not I have to\nkeep updating the replace refs each time I merge the branch?\n\nTIA!\n\nDavid\n"},{"id":"199108","messageId":"7vvcffyzfh.fsf@alter.siamese.dyndns.org","threadId":"31540","inReplyTo":"CACffvTp4qnHc3RHKDotEfvshVDqGtTX6eh6Fr-bmJSMUvTFN6g@mail.gmail.com","subject":"Re: Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-15T17:21:38Z","receivedAt":"2012-09-15T17:21:38Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Chanters <david.chanters@googlemail.com> writes:\n\n> 1.  I thought the replace data in .git/refs/replace was published when\n> I did \"git push\" so that others could use this information as a\n> base-point, yet it seems not to be the case.  How do I publish this?\n\nIf you don't tell it what to push, the command will just update the\nbranches.  You can tell \"git push\" what you want to push explicitly,\ne.g. \n\n    $ git replace -l ;# to learn what replacement I want to send\n    77d5ba8477eb90509e79dbcf63814a3dfdefb906\n    $ git push origin refs/replace/77d5ba8477eb90509e79dbcf63814a3dfdefb906\n\n> 2.  If I do publish it, are there any caveats with that?  i.e.,\n> because the replace data will likely point to a repo which in my\n> working checkout I added with \"git-remote\", is that going to be a\n> problem?\n\nThat is between you and other project participants.  They may not\nwant to see replacement in their project in the first place.\n\nAssuming that they do, pushing the replacement ref makes the\nreplacing object available in the pushed-into repository, so\nthey will *not* rely on your repository.\n"},{"id":"199124","messageId":"CACffvTroMt-s7X_DV9AHerzKdgz+xABXTd91aTUc2BtYO7QxCA@mail.gmail.com","threadId":"31540","inReplyTo":"7vvcffyzfh.fsf@alter.siamese.dyndns.org","subject":"Re: Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?","fromName":"David Chanters","fromEmail":"david.chanters@googlemail.com","sentAt":"2012-09-15T21:49:30Z","receivedAt":"2012-09-15T21:49:30Z","isPatch":false,"sender":{"key":"david.chanters@googlemail.com","avatar":null},"body":"Hi,\n\nOn 15 September 2012 18:21, Junio C Hamano <gitster@pobox.com> wrote:\n> David Chanters <david.chanters@googlemail.com> writes:\n>> 2.  If I do publish it, are there any caveats with that?  i.e.,\n>> because the replace data will likely point to a repo which in my\n>> working checkout I added with \"git-remote\", is that going to be a\n>> problem?\n>\n> That is between you and other project participants.  They may not\n> want to see replacement in their project in the first place.\n>\n> Assuming that they do, pushing the replacement ref makes the\n> replacing object available in the pushed-into repository, so\n> they will *not* rely on your repository.\n\nThis makes sense.  But it is more the mechanics of what happens with\nneeding to update the \"fetch\" line for the remote in .git/config I am\nmore puzzled by.\n\nFor example, if I have two repos -- repoA and repoB, where repoA\ncontains the replace refs for repoB -- if I clone both repos with the\nintent of wanting to look at the two histories, what must I do in\nrepoA to fetch the replace refs in the first place?\n\nI've tried:\n\n[remote \"origin\"]\n        fetch =\n+refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*\n\nBut this results in:\n\n% git pull\nfatal: Invalid refspec\n'+refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*'\n\nSo I'm clearly not understanding something here, and even then, I'm\nassuming that I can manipulate the correct \"fetch\" line via \"git\nconfig\", it's just that I'm not sure which one to use.\n\nI keep meaning to read up on refspec stuff because it looks so useful.\n\nKindly,\n\nDavid\n"},{"id":"199130","messageId":"CAP8UFD0sfBGT9OaGuS9OF68rdhoe1PTM4gYxE78z+NjTApF9Sw@mail.gmail.com","threadId":"31540","inReplyTo":"CACffvTroMt-s7X_DV9AHerzKdgz+xABXTd91aTUc2BtYO7QxCA@mail.gmail.com","subject":"Re: Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2012-09-16T02:42:29Z","receivedAt":"2012-09-16T02:42:29Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi,\n\nOn Sat, Sep 15, 2012 at 11:49 PM, David Chanters\n<david.chanters@googlemail.com> wrote:\n> Hi,\n>\n> On 15 September 2012 18:21, Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> Assuming that they do, pushing the replacement ref makes the\n>> replacing object available in the pushed-into repository, so\n>> they will *not* rely on your repository.\n>\n> This makes sense.  But it is more the mechanics of what happens with\n> needing to update the \"fetch\" line for the remote in .git/config I am\n> more puzzled by.\n>\n> For example, if I have two repos -- repoA and repoB, where repoA\n> contains the replace refs for repoB -- if I clone both repos with the\n> intent of wanting to look at the two histories, what must I do in\n> repoA to fetch the replace refs in the first place?\n>\n> I've tried:\n>\n> [remote \"origin\"]\n>         fetch =\n> +refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*\n\nCould you try the following:\n\n[remote \"origin\"]\n        fetch = +refs/replace/*:refs/replace/*\n        fetch = +refs/heads/*:refs/remotes/origin/*\n\n\n> But this results in:\n>\n> % git pull\n> fatal: Invalid refspec\n> '+refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*'\n\nBest,\nChristian.\n"},{"id":"199133","messageId":"7vk3vuzeot.fsf@alter.siamese.dyndns.org","threadId":"31540","inReplyTo":"CACffvTroMt-s7X_DV9AHerzKdgz+xABXTd91aTUc2BtYO7QxCA@mail.gmail.com","subject":"Re: Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-16T06:04:18Z","receivedAt":"2012-09-16T06:04:18Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Chanters <david.chanters@googlemail.com> writes:\n\n> I've tried:\n>\n> [remote \"origin\"]\n>         fetch =\n> +refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*\n\nRead the documentation and learn about <refspec> instead of blindly\nguessing.\n\n\t[remote \"origin\"]\n\t\tfetch = +refs/heads/*:refs/remotes/origin/*\n\t        fetch = +refs/replace/*:refs/replace/*\n\nwould be syntactically more correct.  That would blindly fetch each\nand every replace refs from the other side and apply the replacement.\n\nIt is questionable if it is a sensible thing to do, though.\n\n\"Git cabal\" has been discussing a plan to make this easier but it is\nnot quite ready to outline here yet.  Perhaps after I return from my\nvacation post 1.8.0 release ;-)\n"}]}