{"thread":{"id":"20777","subject":"Generating patches/Cherry Picking for a large number of commits","startedAt":"2009-08-28T19:26:43Z","lastAt":"2009-08-28T22:35:43Z","messageCount":7,"participants":["Alydis","Jeff King","Jakub Narebski","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"122045","messageId":"ae09c2a40908281226r744141bm3a5bf4161ddab3e7@mail.gmail.com","threadId":"20777","inReplyTo":null,"subject":"Generating patches/Cherry Picking for a large number of commits","fromName":"Alydis","fromEmail":"alydis@august8.net","sentAt":"2009-08-28T19:26:43Z","receivedAt":"2009-08-28T19:26:43Z","isPatch":false,"sender":{"key":"alydis@august8.net","avatar":null},"body":"Hi,\n\nNewly converted git user here.  I've stopped working with Subversion\never since working with the Linux kernel has introduced me to git, and\nnever looked back!\n\nI am currently working on a project in which I'm trying to backport\nthe powerpc boot-wrapper and device tree handling from Linux 2.6.30\ninto Linux 2.6.21.  We have some third party vendor code that is not\nready for the (new) completely fair scheduler just yet.  Yet, our BSP\nrelies on cuImage and the DTS files.\n\nThe approach I'm taking is to try to cherry-pick any commits between\nv2.6.21 and v2.6.30 on the Linux kernel git repository that touch any\nfile in the arch/powerpc/boot directory into a v2.6.21 branch (and\npray that the conflicts are manageable).\n\nI've tried something along these lines:\n\ngit clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6\ncd linux-2.6\ngit checkout -b mybranch v2.6.21\ngit format-patch -o patches v2.6.21..v2.6.30 arch/powerpc/boot\ngit am -3 patches/*\n\nBut, to my dismay, format-patch here tears apart the commits and\napplies ONLY the hunks that apply to the arch/powerpc/boot directory.\nWhat I'd much rather do is obtain a list of commits that apply to\narch/powerpc/boot; but, then apply the entire patch.\n\nI'm a bit lost at how to proceed at this point?  Do I need to write my\nown script that uses git-log to grab the commit hashes that I want,\nthen call format-patch (or diff/apply/etc) individually on each of\nthem?  I realize I'll have to handle patch numbering myself, if I were\nto do that (luckily, I believe format-patch allows you to specify the\nstarting number).  I also know at some point, I'll have to drill down\ninto individual commits and do some more detailed cherry picking to\nform the desired patch series.  This script seems like a good deal of\nwork for me... so before I go off and start it, I was wondering if the\ngit gurus have any clever solutions for me?\n\nThanks,\nTommy Wang\n"},{"id":"122048","messageId":"20090828194556.GA13302@coredump.intra.peff.net","threadId":"20777","inReplyTo":"ae09c2a40908281226r744141bm3a5bf4161ddab3e7@mail.gmail.com","subject":"Re: Generating patches/Cherry Picking for a large number of commits","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-28T19:45:56Z","receivedAt":"2009-08-28T19:45:56Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Aug 28, 2009 at 02:26:43PM -0500, Alydis wrote:\n\n> I've tried something along these lines:\n> \n> git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6\n> cd linux-2.6\n> git checkout -b mybranch v2.6.21\n> git format-patch -o patches v2.6.21..v2.6.30 arch/powerpc/boot\n> git am -3 patches/*\n> \n> But, to my dismay, format-patch here tears apart the commits and\n> applies ONLY the hunks that apply to the arch/powerpc/boot directory.\n> What I'd much rather do is obtain a list of commits that apply to\n> arch/powerpc/boot; but, then apply the entire patch.\n\nBy default, format-patch (and log, gitk, etc) when given a path limiter\nwill also limit the diff shown. You can override it with --full-diff.\n\n-Peff\n"},{"id":"122050","messageId":"ae09c2a40908281250r42275a3o96825b89e725bace@mail.gmail.com","threadId":"20777","inReplyTo":"20090828194556.GA13302@coredump.intra.peff.net","subject":"Re: Generating patches/Cherry Picking for a large number of commits","fromName":"Alydis","fromEmail":"alydis@august8.net","sentAt":"2009-08-28T19:50:53Z","receivedAt":"2009-08-28T19:50:53Z","isPatch":false,"sender":{"key":"alydis@august8.net","avatar":null},"body":"Ack!  Embarrassing RTFM.\n\nWhile I have your attention, however, I noticed that git am <path>\nwill apply the list patches generated by format-patch.  The\ndocumentation said something about mbox/maildir directories, which I\nactually am not that familiar with.  Is it safe to say that git am\n<path> will read the path and apply patches in numerical order?  Does\nit allow skipping?\n\nThanks again,\nTommy Wang\n\n\nOn Fri, Aug 28, 2009 at 2:45 PM, Jeff King<peff@peff.net> wrote:\n> On Fri, Aug 28, 2009 at 02:26:43PM -0500, Alydis wrote:\n>\n>> I've tried something along these lines:\n>>\n>> git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6\n>> cd linux-2.6\n>> git checkout -b mybranch v2.6.21\n>> git format-patch -o patches v2.6.21..v2.6.30 arch/powerpc/boot\n>> git am -3 patches/*\n>>\n>> But, to my dismay, format-patch here tears apart the commits and\n>> applies ONLY the hunks that apply to the arch/powerpc/boot directory.\n>> What I'd much rather do is obtain a list of commits that apply to\n>> arch/powerpc/boot; but, then apply the entire patch.\n>\n> By default, format-patch (and log, gitk, etc) when given a path limiter\n> will also limit the diff shown. You can override it with --full-diff.\n>\n> -Peff\n>\n"},{"id":"122052","messageId":"m3k50nllt6.fsf@localhost.localdomain","threadId":"20777","inReplyTo":"ae09c2a40908281250r42275a3o96825b89e725bace@mail.gmail.com","subject":"Re: Generating patches/Cherry Picking for a large number of commits","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-08-28T20:34:36Z","receivedAt":"2009-08-28T20:34:36Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"[Alydis, please do not toppost]\n\nAlydis <alydis@august8.net> writes:\n> On Fri, Aug 28, 2009 at 2:45 PM, Jeff King<peff@peff.net> wrote:\n>> On Fri, Aug 28, 2009 at 02:26:43PM -0500, Alydis wrote:\n>>\n>>> I've tried something along these lines:\n>>>\n[...]\n>>> git format-patch -o patches v2.6.21..v2.6.30 arch/powerpc/boot\n>>> git am -3 patches/*\n>>>\n>>> But, to my dismay, format-patch here tears apart the commits and\n>>> applies ONLY the hunks that apply to the arch/powerpc/boot directory.\n>>> What I'd much rather do is obtain a list of commits that apply to\n>>> arch/powerpc/boot; but, then apply the entire patch.\n>>\n>> By default, format-patch (and log, gitk, etc) when given a path limiter\n>> will also limit the diff shown. You can override it with --full-diff.\n>\n> Ack!  Embarrassing RTFM.\n> \n> While I have your attention, however, I noticed that git am <path>\n> will apply the list patches generated by format-patch.  The\n> documentation said something about mbox/maildir directories, which I\n> actually am not that familiar with.  Is it safe to say that git am\n> <path> will read the path and apply patches in numerical order? \n\ngit-format-patch | git-am pipeline has to work correctly, as it\noriginally was the way (modulo extra options) git-rebase was\nimplemented.  So yes, \"git am <dir>\" should understand and apply in\ncorrect order result of \"git format-patch -o <dir> <revspec>\".\n\n> Does it allow skipping?\n\nThere is \"git am -i\".\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"122060","messageId":"20090828215420.GA18336@coredump.intra.peff.net","threadId":"20777","inReplyTo":"ae09c2a40908281250r42275a3o96825b89e725bace@mail.gmail.com","subject":"Re: Generating patches/Cherry Picking for a large number of commits","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-28T21:54:20Z","receivedAt":"2009-08-28T21:54:20Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Aug 28, 2009 at 02:50:53PM -0500, Alydis wrote:\n\n> While I have your attention, however, I noticed that git am <path>\n> will apply the list patches generated by format-patch.  The\n> documentation said something about mbox/maildir directories, which I\n> actually am not that familiar with.  Is it safe to say that git am\n> <path> will read the path and apply patches in numerical order?  Does\n> it allow skipping?\n\nIt will apply the patches in the order given on the command line. When\nyour shell expands the \"patches/*\" glob, it will do so in lexically\nsorted order. Meaning \"0001\" comes before \"0002\", etc, which is the\nreason that format-patch zero-pads the filenames.\n\nYou can edit or delete the patches in your patch directory before\napplying, and they should apply the same (unless you create a patch that\ncannot actually be applied).\n\n-Peff\n"},{"id":"122063","messageId":"7vmy5jh8oa.fsf@alter.siamese.dyndns.org","threadId":"20777","inReplyTo":"ae09c2a40908281250r42275a3o96825b89e725bace@mail.gmail.com","subject":"Re: Generating patches/Cherry Picking for a large number of commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-28T22:31:49Z","receivedAt":"2009-08-28T22:31:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alydis <alydis@august8.net> writes:\n\n> Ack!  Embarrassing RTFM.\n>\n> While I have your attention, however, I noticed that git am <path>\n> will apply the list patches generated by format-patch.  The\n> documentation said something about mbox/maildir directories, which I\n> actually am not that familiar with.  Is it safe to say that git am\n> <path> will read the path and apply patches in numerical order?  Does\n> it allow skipping?\n\nIf you say \"git am <directory>/*\", like you have in your original message\nshown *below* (sheesh, why am I responding to somebody who top-posts?),\nyou let your shell perform a numerical sort, so you would be Ok.\n\n>>> git format-patch -o patches v2.6.21..v2.6.30 arch/powerpc/boot\n>>> git am -3 patches/*\n\nI do not think the above format-patch, even with --full-diff, is\nnecessarily a good idea nor would work in general.\n\nOften, when a series is concocted, you would see this pattern:\n\n * Early parts of the patch series to lay groundwork by introducing non\n   platform specific infrastructure; and then\n\n * Later parts of the series utilizes the infrastructure to implement the\n   feature for particular platforms.\n\nObviously you are interested only for powerpc parts in the latter category\nand would want to omit anything irrelevant to powerpc.  But you do want to\ninclude all of the former class, even if they do not touch anything inside\nthe powerpc area.\n"},{"id":"122065","messageId":"7v1vmvh8hs.fsf@alter.siamese.dyndns.org","threadId":"20777","inReplyTo":"m3k50nllt6.fsf@localhost.localdomain","subject":"Re: Generating patches/Cherry Picking for a large number of commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-28T22:35:43Z","receivedAt":"2009-08-28T22:35:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> git-format-patch | git-am pipeline has to work correctly, as it\n> originally was the way (modulo extra options) git-rebase was\n> implemented.  So yes, \"git am <dir>\" should understand and apply in\n> correct order result of \"git format-patch -o <dir> <revspec>\".\n\nYou are not making any sense.  rebase is done using --stdout and does not\nrely on the intermediate files nor ordering of their names.\n"}]}