{"thread":{"id":"32459","subject":"generating format-patch options from an e-mail","startedAt":"2012-12-26T20:06:23Z","lastAt":"2012-12-26T21:57:12Z","messageCount":5,"participants":["Simon Oosthoek","Junio C Hamano","Pyeron, Jason J CTR (US)","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"205504","messageId":"20121226200623.GA29446@simaj.xs4all.nl","threadId":"32459","inReplyTo":null,"subject":"generating format-patch options from an e-mail","fromName":"Simon Oosthoek","fromEmail":"s.oosthoek@xs4all.nl","sentAt":"2012-12-26T20:06:23Z","receivedAt":"2012-12-26T20:06:23Z","isPatch":false,"sender":{"key":"s.oosthoek@xs4all.nl","avatar":"https://avatars.githubusercontent.com/u/11677720?v=4"},"body":"Hi all\n\nI've been very frustrated by the process to setup a commandline for git format-patch, to include everyone in the cc list and reply to the right message-id.\n\nIn my frustration I created a perl script to generate the options from a saved e-mail, I realise that it may be non-general and perhaps it could be written better using a module which understands e-mails, but well, it worked for me ;-)\n\nAnyway, I could imagine this as optional flag of git format-patch, so you could say:\n$ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8\n\nBut I'll save that as an exercise for the reader (or the future)\n\nCheers\n\nSimon\n"},{"id":"205508","messageId":"7vbodgo8kv.fsf@alter.siamese.dyndns.org","threadId":"32459","inReplyTo":"20121226200623.GA29446@simaj.xs4all.nl","subject":"Re: generating format-patch options from an e-mail","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-26T20:35:28Z","receivedAt":"2012-12-26T20:35:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Simon Oosthoek <s.oosthoek@xs4all.nl> writes:\n\n> Hi all\n>\n> I've been very frustrated by the process to setup a commandline for git format-patch, to include everyone in the cc list and reply to the right message-id.\n>\n> In my frustration I created a perl script to generate the options from a saved e-mail, I realise that it may be non-general and perhaps it could be written better using a module which understands e-mails, but well, it worked for me ;-)\n>\n> Anyway, I could imagine this as optional flag of git format-patch, so you could say:\n> $ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8\n>\n> But I'll save that as an exercise for the reader (or the future)\n\nI think a much more general approach would be to turn your script\ninto \"get-msg-id\" script and use it like so:\n\n  $ git format-patch --in-reply-to $(get-msg-id <mboxfile>) a7fe7de8\n\nThen you can reuse that script in a context outside format-patch,\nwhereever you need the message-id in a single message in the\nmailbox.\n"},{"id":"205511","messageId":"20121226210737.GB20704@xs4all.nl","threadId":"32459","inReplyTo":"7vbodgo8kv.fsf@alter.siamese.dyndns.org","subject":"Re: generating format-patch options from an e-mail","fromName":"Simon Oosthoek","fromEmail":"s.oosthoek@xs4all.nl","sentAt":"2012-12-26T21:07:37Z","receivedAt":"2012-12-26T21:07:37Z","isPatch":false,"sender":{"key":"s.oosthoek@xs4all.nl","avatar":"https://avatars.githubusercontent.com/u/11677720?v=4"},"body":"* Junio C Hamano <gitster@pobox.com> [2012-12-26 12:35:28 -0800]:\n> >\n> > Anyway, I could imagine this as optional flag of git format-patch, so you could say:\n> > $ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8\n> >\n> > But I'll save that as an exercise for the reader (or the future)\n> \n> I think a much more general approach would be to turn your script\n> into \"get-msg-id\" script and use it like so:\n> \n>   $ git format-patch --in-reply-to $(get-msg-id <mboxfile>) a7fe7de8\n> \n> Then you can reuse that script in a context outside format-patch,\n> whereever you need the message-id in a single message in the\n> mailbox.\n> \n\nThat would work for the message-ID, but not for the various To: and Cc: addresses.\n\nThe hacky script that I sent afterwards produces a string with the various options to git format-patch (--to --cc --in-reply-to) based on the headers To:/Cc:/From:/Message-ID:\n\nCheers\n\nSimon\n"},{"id":"205514","messageId":"871B6C10EBEFE342A772D1159D1320853A00DD2E@umechphj.easf.csd.disa.mil","threadId":"32459","inReplyTo":"20121226210737.GB20704@xs4all.nl","subject":"RE: generating format-patch options from an e-mail","fromName":"Pyeron, Jason J CTR (US)","fromEmail":"jason.j.pyeron.ctr@mail.mil","sentAt":"2012-12-26T21:31:46Z","receivedAt":"2012-12-26T21:31:46Z","isPatch":false,"sender":{"key":"jason.j.pyeron.ctr@mail.mil","avatar":null},"body":"> -----Original Message-----\n> From: Simon Oosthoek\n> Sent: Wednesday, December 26, 2012 4:08 PM\n> \n> * Junio C Hamano <gitster@pobox.com> [2012-12-26 12:35:28 -0800]:\n> > >\n> > > Anyway, I could imagine this as optional flag of git format-patch,\n> so you could say:\n> > > $ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8\n\nAnyway you would need a --in-reply-to-email and a --in-reply-to-all-email, both should support stdin. Then you can feel free to --[no-]to and --[no-]cc (where is the --bcc?) to your heart's content.\n\nIt would be a nice addition.\n\n> > >\n> > > But I'll save that as an exercise for the reader (or the future)\n> >\n> > I think a much more general approach would be to turn your script\n> > into \"get-msg-id\" script and use it like so:\n> >\n> >   $ git format-patch --in-reply-to $(get-msg-id <mboxfile>) a7fe7de8\n> >\n> > Then you can reuse that script in a context outside format-patch,\n> > whereever you need the message-id in a single message in the\n> > mailbox.\n> >\n> \n> That would work for the message-ID, but not for the various To: and Cc:\n> addresses.\n> \n> The hacky script that I sent afterwards produces a string with the\n\nNit, it does not make use of the reply-to header if present.\n\n> various options to git format-patch (--to --cc --in-reply-to) based on\n> the headers To:/Cc:/From:/Message-ID:\n> \n> Cheers\n> \n> Simon\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"205516","messageId":"20121226215712.GA11491@sigill.intra.peff.net","threadId":"32459","inReplyTo":"871B6C10EBEFE342A772D1159D1320853A00DD2E@umechphj.easf.csd.disa.mil","subject":"Re: generating format-patch options from an e-mail","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-12-26T21:57:12Z","receivedAt":"2012-12-26T21:57:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 26, 2012 at 09:31:46PM +0000, Pyeron, Jason J CTR (US) wrote:\n\n> > That would work for the message-ID, but not for the various To: and Cc:\n> > addresses.\n> > \n> > The hacky script that I sent afterwards produces a string with the\n> \n> Nit, it does not make use of the reply-to header if present.\n\nI do something very similar to Simon, except that rather than generating\na reply with my script, I generate the cover letter in my MUA, and then\nuse that response as a template. So the MUA does the heavy lifting,\nunderstanding reply-to, culling my own address from cc, etc. The\nformat-patch replies then have the exact same to/cc headers as the\ntemplate, and use the template's message-id as the in-reply-to (for\nproper threading).\n\nMy perl looks like this (feed the template via stdin):\n\n  perl -ne '\n    if (defined $opt && /^\\s+(.*)/) {\n      $val .= \" $1\";\n      next;\n    }\n    if (defined $opt) {\n      print \"--$opt=\", quotemeta($val), \" \";\n      $opt = $val = undef;\n    }\n    if (/^(cc|to):\\s*(.*)/i) {\n      $opt = lc($1);\n      $val = $2;\n    }\n    elsif (/^message-id:\\s*(.*)/i) {\n      $opt = \"in-reply-to\";\n      $val = $1;\n    }\n  '\n\nThat, of course, presupposes a cover letter. If I am sending a single\npatch, then I just do \"format-patch --stdout\" right into my MUA's\neditor), and let it handle the headers.\n\n-Peff\n"}]}