{"thread":{"id":"20190","subject":"format-patch: numbered patches from a patch list?","startedAt":"2009-07-22T02:25:52Z","lastAt":"2009-07-22T02:47:30Z","messageCount":4,"participants":["tom fogal","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"118442","messageId":"auto-000020035874@sci.utah.edu","threadId":"20190","inReplyTo":null,"subject":"format-patch: numbered patches from a patch list?","fromName":"tom fogal","fromEmail":"tfogal@alumni.unh.edu","sentAt":"2009-07-22T02:25:52Z","receivedAt":"2009-07-22T02:25:52Z","isPatch":false,"sender":{"key":"tfogal@alumni.unh.edu","avatar":"https://gravatar.com/avatar/a2f71bfbe12b2b73cad0be2386d554aa403fff7a89df2f79e812c97c7eab0498?d=mp&s=160"},"body":"I have a need to generate a numbered sequence of patches from a sparse\nsprinkling of patches on a branch.  Is there a way to accomplish this?\n\nBasically I want to say, `for the patches at the heads of these sha1s,\ngive me a numbered sequence.'  Currently I take the list of shas that I\nwant, throw them in a file, and loop over each entry:\n\n  for sha in $(cat patches) ; do git format-patch -o a/ ${sha}^..${sha} ; done\n\nThis is undesirable because each patch is the first patch in a series,\ne.g. \"0001-...\".  A desirable interface would be specifying multiple\ndisconnected ranges via some separator, say \",\".\n\nTo hammer it home; given:\n\n   ... -- A -- B -- C -- D -- E -- F -- G\n\nI'd like a command / line or two of shell which could get me:\n\n  the patch that created A: 0001\n  the patch that created B: 0002\n  the patch that created E: 0003\n  the patch that created G: 0004\n\netc.  It'd get confusing if I specified multiple branches.  Fortunately\nI don't need that use case, and anyway I think just providing a raw\nordering based on timestamp (ignoring branches) would be sufficient for\nany (of my) future needs.\n\n\nThe use case for all of this is disconnected repositories that really\nshouldn't be.  We do `special' merging in subversion, so I do a lot of\ntrunk work via git-svn, and then I have backporting sessions where I\nidentify commits which should go on our release branches and put them\nthere.\n\nThanks for any ideas,\n\n-tom\n"},{"id":"118444","messageId":"7vtz15wi6q.fsf@alter.siamese.dyndns.org","threadId":"20190","inReplyTo":"auto-000020035874@sci.utah.edu","subject":"Re: format-patch: numbered patches from a patch list?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-07-22T02:43:57Z","receivedAt":"2009-07-22T02:43:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"tom fogal <tfogal@alumni.unh.edu> writes:\n\n> I have a need to generate a numbered sequence of patches from a sparse\n> sprinkling of patches on a branch.  Is there a way to accomplish this?\n>\n> Basically I want to say, `for the patches at the heads of these sha1s,\n> give me a numbered sequence.'  Currently I take the list of shas that I\n> want, throw them in a file, and loop over each entry:\n>\n>   for sha in $(cat patches) ; do git format-patch -o a/ ${sha}^..${sha} ; done\n\nYou can pass --start-number to these invocations of format-patch; maintain\nthe parameter to give as an argument to the option inside your loop.\n"},{"id":"118445","messageId":"20090722024445.GA31254@coredump.intra.peff.net","threadId":"20190","inReplyTo":"auto-000020035874@sci.utah.edu","subject":"Re: format-patch: numbered patches from a patch list?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-07-22T02:44:45Z","receivedAt":"2009-07-22T02:44:45Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 21, 2009 at 08:25:52PM -0600, tom fogal wrote:\n\n> I have a need to generate a numbered sequence of patches from a sparse\n> sprinkling of patches on a branch.  Is there a way to accomplish this?\n> \n> Basically I want to say, `for the patches at the heads of these sha1s,\n> give me a numbered sequence.'  Currently I take the list of shas that I\n> want, throw them in a file, and loop over each entry:\n> \n>   for sha in $(cat patches) ; do git format-patch -o a/ ${sha}^..${sha} ; done\n> \n> This is undesirable because each patch is the first patch in a series,\n> e.g. \"0001-...\".  A desirable interface would be specifying multiple\n> disconnected ranges via some separator, say \",\".\n\nTry\n\n  git format-patch --no-walk $(cat patches)\n\n-Peff\n"},{"id":"118446","messageId":"auto-000020035969@sci.utah.edu","threadId":"20190","inReplyTo":"auto-000020035874@sci.utah.edu","subject":"Re: format-patch: numbered patches from a patch list?","fromName":"tom fogal","fromEmail":"tfogal@alumni.unh.edu","sentAt":"2009-07-22T02:47:30Z","receivedAt":"2009-07-22T02:47:30Z","isPatch":false,"sender":{"key":"tfogal@alumni.unh.edu","avatar":"https://gravatar.com/avatar/a2f71bfbe12b2b73cad0be2386d554aa403fff7a89df2f79e812c97c7eab0498?d=mp&s=160"},"body":"Answering my own question.\n\ntom fogal <tfogal@alumni.unh.edu> writes:\n> I have a need to generate a numbered sequence of patches from\n> a sparse sprinkling of patches on a branch.  Is there a way to\n> accomplish this?\n\nYep.  Duh.\n\nJust generate the patches as I did in my my first mail.  Then use\nmtime.sh:\n\n    #!/bin/sh\n\n    for patch in $@ ; do\n      commitdate=$(head -n 5 ${patch} | \\\n                   grep \"^Date\" | \\\n                   cut -d: -f 2-)\n      touch -d \"${commitdate}\" ${patch}\n      shortfn=$(echo \"${patch}\" | cut -b 1-30)\n      echo \"Changed ${shortfn} to ${commitdate}\"\n    done\n\nto change the modification time of every patch I care about.  Now I can\nlist the files by modification time, achieving exactly what I want.\n\nI really love a full posix environment sometimes.\n\n\nSorry for the noise,\n\n-tom\n"}]}