{"thread":{"id":"20174","subject":"synchronizing 2 heterogenous branches by cherry-pick","startedAt":"2009-07-21T12:42:10Z","lastAt":"2009-07-23T09:24:33Z","messageCount":4,"participants":["Martin Pirker","Pierre Habouzit"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"118367","messageId":"8d53e6220907210542p4c989f3av2b57202fdd2db1f5@mail.gmail.com","threadId":"20174","inReplyTo":null,"subject":"synchronizing 2 heterogenous branches by cherry-pick","fromName":"Martin Pirker","fromEmail":"git.collector@gmail.com","sentAt":"2009-07-21T12:42:10Z","receivedAt":"2009-07-21T12:42:10Z","isPatch":false,"sender":{"key":"git.collector@gmail.com","avatar":null},"body":"One of those weird real-world situations, advice appreciated:\n\nGiven...\none Git repository with\none branch \"left\" and one branch \"right\"\nboth branches have a different history (common ancestor is 0000000)\nboth branches have different content\n_however_, at one specific commit in the \"left\" and \"right\"\nbranch it can be said that the content of specific\nsubdirectories is identical\nthese commits are marked with a tag \"equal\"\n\nThus, patches which only modify the identical\ncontent can always be applied without conflicts on both branches.\nI commit a new patch on \"left\", I can cherry-pick it to\n\"right\" and both trees are identical again.\n\nIssues:\nCheery-pick takes only one commit.\nI have to find commits by hand.\nIdeally, I want to specify equal..HEAD, if 10 commits are \"left\"\nand \"right\" are 7, well, then cherry pick the last 3 from \"left\"\nto \"right\".\nNote that the patch content is always identical, the\ncommit text message (author/committer/timestamp/...) not\nalways\nNote that ideally only one way synchronizing occurs. Bonus\npoints if I can add on both sides and then start magic sync...\n\n\nAny good idea on how to automagically script these cherry-picking?\n\nMartin\n"},{"id":"118568","messageId":"8d53e6220907230141l62dd1830g15ca811d5b009f2f@mail.gmail.com","threadId":"20174","inReplyTo":"8d53e6220907210542p4c989f3av2b57202fdd2db1f5@mail.gmail.com","subject":"Re: synchronizing 2 heterogenous branches by cherry-pick","fromName":"Martin Pirker","fromEmail":"git.collector@gmail.com","sentAt":"2009-07-23T08:41:37Z","receivedAt":"2009-07-23T08:41:37Z","isPatch":false,"sender":{"key":"git.collector@gmail.com","avatar":null},"body":"I'm replying to myself.... for the archives :-)\n\nOn Tue, Jul 21, 2009 at 2:42 PM, Martin Pirker<git.collector@gmail.com> wrote:\n[....]\n>Any good idea on how to automagically script these cherry-picking?\n\ntag identical content point in different branches:\n git tag tag1 commitx\n git tag tag2 commity\n\nget list of newer commits:\n git rev-list tag1^..head1\n git rev-list tag2^..head2\n\ncompare content of commits via:\ngit diff --exit-code commit1 commit2\n\n...and cherry-pick resulting list from one side to the other\n\n\nGit is an amazing toolbox :-)\nMartin\n"},{"id":"118571","messageId":"20090723085125.GL4750@laphroaig.corp","threadId":"20174","inReplyTo":"8d53e6220907230141l62dd1830g15ca811d5b009f2f@mail.gmail.com","subject":"Re: synchronizing 2 heterogenous branches by cherry-pick","fromName":"Pierre Habouzit","fromEmail":"madcoder@madism.org","sentAt":"2009-07-23T08:51:25Z","receivedAt":"2009-07-23T08:51:25Z","isPatch":false,"sender":{"key":"madcoder@madism.org","avatar":null},"body":"On Thu, Jul 23, 2009 at 10:41:37AM +0200, Martin Pirker wrote:\n> I'm replying to myself.... for the archives :-)\n> \n> On Tue, Jul 21, 2009 at 2:42 PM, Martin Pirker<git.collector@gmail.com> wrote:\n> [....]\n> >Any good idea on how to automagically script these cherry-picking?\n> \n> tag identical content point in different branches:\n>  git tag tag1 commitx\n>  git tag tag2 commity\n> \n> get list of newer commits:\n>  git rev-list tag1^..head1\n>  git rev-list tag2^..head2\n> \n> compare content of commits via:\n> git diff --exit-code commit1 commit2\n> \n> ....and cherry-pick resulting list from one side to the other\n\nOr use git cherry\n-- \nIntersec <http://www.intersec.com>\nPierre Habouzit <pierre.habouzit@intersec.com>\nTél : +33 (0)1 5570 3346\nMob : +33 (0)6 1636 8131\nFax : +33 (0)1 5570 3332\n37 Rue Pierre Lhomme\n92400 Courbevoie\n"},{"id":"118572","messageId":"8d53e6220907230224t1ceddf31ic69bfbed84c851f@mail.gmail.com","threadId":"20174","inReplyTo":"20090723085125.GL4750@laphroaig.corp","subject":"Re: synchronizing 2 heterogenous branches by cherry-pick","fromName":"Martin Pirker","fromEmail":"git.collector@gmail.com","sentAt":"2009-07-23T09:24:33Z","receivedAt":"2009-07-23T09:24:33Z","isPatch":false,"sender":{"key":"git.collector@gmail.com","avatar":null},"body":"On Thu, Jul 23, 2009 at 10:51 AM, Pierre Habouzit<madcoder@madism.org> wrote:\n> Or use git cherry\n\nI tried, but I was under the impression git patch-id also hashes the commit\nmessage - or I got something else typed wrong 'cause it didn't seem to work\n:-/\n\nYou are right, the solution is:\n git cherry head1 head2 tag2\n git cherry head2 head1 tag1\nand cherry-pick all lines prefixed with + to the other branch.\n\nThanks,\nMartin\n"}]}