Re: generating format-patch options from an e-mail
On Wed, Dec 26, 2012 at 09:31:46PM +0000, Pyeron, Jason J CTR (US) wrote:
Show 6 quoted lines
> > That would work for the message-ID, but not for the various To: and Cc:
> > addresses.
> >
> > The hacky script that I sent afterwards produces a string with the
>
> Nit, it does not make use of the reply-to header if present.
I do something very similar to Simon, except that rather than generating a reply with my script, I generate the cover letter in my MUA, and then use that response as a template. So the MUA does the heavy lifting, understanding reply-to, culling my own address from cc, etc. The format-patch replies then have the exact same to/cc headers as the template, and use the template's message-id as the in-reply-to (for proper threading).
My perl looks like this (feed the template via stdin):
perl -ne '
if (defined $opt && /^\s+(.*)/) {
$val .= " $1";
next;
}
if (defined $opt) {
print "--$opt=", quotemeta($val), " ";
$opt = $val = undef;
}
if (/^(cc|to):\s*(.*)/i) {
$opt = lc($1);
$val = $2;
}
elsif (/^message-id:\s*(.*)/i) {
$opt = "in-reply-to";
$val = $1;
}
'That, of course, presupposes a cover letter. If I am sending a single patch, then I just do "format-patch --stdout" right into my MUA's editor), and let it handle the headers.
-Peff