{"thread":{"id":"20903","subject":"one half of a rebase","startedAt":"2009-09-11T17:25:59Z","lastAt":"2009-09-12T14:38:11Z","messageCount":5,"participants":["Geoffrey Irving","Matthieu Moy","Alex Riesen","Paolo Bonzini"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"122902","messageId":"7f9d599f0909111025q42e3cdc6vba602b84c1d81215@mail.gmail.com","threadId":"20903","inReplyTo":null,"subject":"one half of a rebase","fromName":"Geoffrey Irving","fromEmail":"irving@naml.us","sentAt":"2009-09-11T17:25:59Z","receivedAt":"2009-09-11T17:25:59Z","isPatch":false,"sender":{"key":"irving@naml.us","avatar":"https://gravatar.com/avatar/52d7452fcd134aac0fa12f57a3bb7ef5f3f7e73ca0ab36736d06c6a6132de718?d=mp&s=160"},"body":"If I'm on branch topic and do \"git rebase master\", git performs two operations:\n\n1. Rewind the current head to master.\n2. For each commit in topic that isn't in master, cherry pick it onto\nthe current head.\n\nI would like to be able to do (2) as a separate operation.  For\nexample, if I start out on branch master and want to get all of\ntopic's commits on top of the current head, I currently do\n\n    git checkout topic\n    git rebase master\n    git branch -d master\n    git branch -m master\n\nIf I could do (2) as a separate operation, it would look something like\n\n    git cherry-pick-all topic\n\nwhich is simpler and faster since it avoids switching files back and\nforth (master to topic and back).  Is there a robust way to achieve\nthe cherry-pick-all semantics with current commands?  If not, how\ndifficult would it be to partition rebase accordingly?\n\nThanks,\nGeoffrey\n"},{"id":"122905","messageId":"vpqvdjpgwbv.fsf@bauges.imag.fr","threadId":"20903","inReplyTo":"7f9d599f0909111025q42e3cdc6vba602b84c1d81215@mail.gmail.com","subject":"Re: one half of a rebase","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2009-09-11T18:39:16Z","receivedAt":"2009-09-11T18:39:16Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Geoffrey Irving <irving@naml.us> writes:\n\n> If I could do (2) as a separate operation, it would look something like\n>\n>     git cherry-pick-all topic\n\nI believe\n\n  git rebase --onto master master topic\n  git update-ref master topic\n\nwould do the trick.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"122914","messageId":"81b0412b0909111410k3f3ebfaco393bb37ff5a6b5c1@mail.gmail.com","threadId":"20903","inReplyTo":"7f9d599f0909111025q42e3cdc6vba602b84c1d81215@mail.gmail.com","subject":"Re: one half of a rebase","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-09-11T21:10:38Z","receivedAt":"2009-09-11T21:10:38Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Fri, Sep 11, 2009 at 19:25, Geoffrey Irving <irving@naml.us> wrote:\n> If I could do (2) as a separate operation, it would look something like\n>\n>    git cherry-pick-all topic\n>\n> which is simpler and faster since it avoids switching files back and\n> forth (master to topic and back).  Is there a robust way to achieve\n> the cherry-pick-all semantics with current commands?  If not, how\n> difficult would it be to partition rebase accordingly?\n\nI have this in my .bashrc:\n\n$ gcp3 ()\n{\n    git format-patch -k --stdout --full-index \"$@\" | git am -k -3 --binary\n}\n\nThen, while on master branch:\n\n$ gcp3 master..topic\n"},{"id":"122929","messageId":"7f9d599f0909111923v76e0f411n16555e7cdc0c3ed1@mail.gmail.com","threadId":"20903","inReplyTo":"81b0412b0909111410k3f3ebfaco393bb37ff5a6b5c1@mail.gmail.com","subject":"Re: one half of a rebase","fromName":"Geoffrey Irving","fromEmail":"irving@naml.us","sentAt":"2009-09-12T02:23:24Z","receivedAt":"2009-09-12T02:23:24Z","isPatch":false,"sender":{"key":"irving@naml.us","avatar":"https://gravatar.com/avatar/52d7452fcd134aac0fa12f57a3bb7ef5f3f7e73ca0ab36736d06c6a6132de718?d=mp&s=160"},"body":"On Fri, Sep 11, 2009 at 5:10 PM, Alex Riesen<raa.lkml@gmail.com> wrote:\n> On Fri, Sep 11, 2009 at 19:25, Geoffrey Irving <irving@naml.us> wrote:\n>> If I could do (2) as a separate operation, it would look something like\n>>\n>>    git cherry-pick-all topic\n>>\n>> which is simpler and faster since it avoids switching files back and\n>> forth (master to topic and back).  Is there a robust way to achieve\n>> the cherry-pick-all semantics with current commands?  If not, how\n>> difficult would it be to partition rebase accordingly?\n>\n> I have this in my .bashrc:\n>\n> $ gcp3 ()\n> {\n>    git format-patch -k --stdout --full-index \"$@\" | git am -k -3 --binary\n> }\n>\n> Then, while on master branch:\n>\n> $ gcp3 master..topic\n\nGreat!  That should work nicely.\n\nGeoffrey\n"},{"id":"122946","messageId":"4AABB253.2080200@gnu.org","threadId":"20903","inReplyTo":"7f9d599f0909111923v76e0f411n16555e7cdc0c3ed1@mail.gmail.com","subject":"Re: one half of a rebase","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2009-09-12T14:38:11Z","receivedAt":"2009-09-12T14:38:11Z","isPatch":false,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"On 09/12/2009 04:23 AM, Geoffrey Irving wrote:\n> On Fri, Sep 11, 2009 at 5:10 PM, Alex Riesen<raa.lkml@gmail.com>  wrote:\n>> On Fri, Sep 11, 2009 at 19:25, Geoffrey Irving<irving@naml.us>  wrote:\n>>> If I could do (2) as a separate operation, it would look something like\n>>>\n>>>     git cherry-pick-all topic\n>>>\n>>> which is simpler and faster since it avoids switching files back and\n>>> forth (master to topic and back).  Is there a robust way to achieve\n>>> the cherry-pick-all semantics with current commands?  If not, how\n>>> difficult would it be to partition rebase accordingly?\n\nAs mentioned by Alex \"git am -3\" is basically parsing + the second part \nof rebase.  So, based on Alex's recipe, here is a possible alias for \ncherry-pick-all:\n\n[alias]\n\tcherry-pick-all = \"!f() { git format-patch -k --stdout --full-index \n`git symbolic-ref HEAD`..$1 | git am -k -3 --binary; }; f\"\n\nMore useful (just because it is more generic) than \"the second part of \ngit rebase\", a \"sequencer\" would be \"the second part of git rebase -i\", \napplying a custom script coming from stdin.  If that was present, git \ncherry-pick-all could be done like this:\n\ngit log --pretty=tformat:'pick %h' master..topic | git sequencer\n\nAnd here is yet another alternative, that however would only work only \nif the patches applies perfectly:\n\ngit log --pretty=format:%h master..topic | xargs -rn1 git cherry-pick\n\nPaolo\n"}]}