* generating format-patch options from an e-mail
@ 2012-12-26 20:06 Simon Oosthoek
2012-12-26 20:35 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Simon Oosthoek @ 2012-12-26 20:06 UTC (permalink / raw)
To: git
Hi all
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.
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 ;-)
Anyway, I could imagine this as optional flag of git format-patch, so you could say:
$ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8
But I'll save that as an exercise for the reader (or the future)
Cheers
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* generating format-patch options from an e-mail
@ 2012-12-26 20:28 Simon Oosthoek
0 siblings, 0 replies; 6+ messages in thread
From: Simon Oosthoek @ 2012-12-26 20:28 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 655 bytes --]
Hi all
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.
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 ;-)
Anyway, I could imagine this as optional flag of git format-patch, so you could say:
$ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8
But I'll save that as an exercise for the reader (or the future)
Cheers
Simon
PS, now with the script
[-- Attachment #2: formatpatchreply.pl --]
[-- Type: text/x-perl, Size: 1136 bytes --]
#!/usr/bin/perl
use warnings;
use strict;
our @to;
our @cc;
our @id;
our $emptyline=0;
if (defined $ARGV[0] and -f $ARGV[0]) {
open (MAIL, "<$ARGV[0]") or die "cannot open $ARGV[0]\n";
#while (my $line=<MAIL> && ($emptyline == 0) ) {
while (my $line=<MAIL> ) {
chomp $line;
my $header="";
my $content="";
if ($line =~ /^(.*?):.*[ ,<](.*?@.*?)[>, ]/ ||
$line =~ /^(.*ID?):.*[ ,<](.*?)[>, ]/) {
$header=$1;
$content=$2;
if ($header eq "From") {
push(@to, $content);
} if ($header eq "To") {
push(@cc, $content);
} elsif ($header eq "Cc") {
$line =~ /:(.*)$/;
my @ccs=split(/,/, $1);
foreach my $addr (@ccs) {
if ($addr =~ /<(.*)>/) {
push(@cc, $1);
} else {
push(@cc, $addr);
}
}
} elsif ($header eq "Message-ID") {
push(@id, $content);
}
}
$emptyline++ if (length($line) == 0);
}
close (MAIL);
}
foreach my $item (@to) {
print " --to \"$item\"";
}
foreach my $item (@cc) {
print " --cc \"$item\"";
}
foreach my $item (@id) {
print " --in-reply-to \"$item\"";
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: generating format-patch options from an e-mail
2012-12-26 20:06 Simon Oosthoek
@ 2012-12-26 20:35 ` Junio C Hamano
2012-12-26 21:07 ` Simon Oosthoek
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2012-12-26 20:35 UTC (permalink / raw)
To: Simon Oosthoek; +Cc: git
Simon Oosthoek <s.oosthoek@xs4all.nl> writes:
> Hi all
>
> 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.
>
> 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 ;-)
>
> Anyway, I could imagine this as optional flag of git format-patch, so you could say:
> $ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8
>
> But I'll save that as an exercise for the reader (or the future)
I think a much more general approach would be to turn your script
into "get-msg-id" script and use it like so:
$ git format-patch --in-reply-to $(get-msg-id <mboxfile>) a7fe7de8
Then you can reuse that script in a context outside format-patch,
whereever you need the message-id in a single message in the
mailbox.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: generating format-patch options from an e-mail
2012-12-26 20:35 ` Junio C Hamano
@ 2012-12-26 21:07 ` Simon Oosthoek
2012-12-26 21:31 ` Pyeron, Jason J CTR (US)
0 siblings, 1 reply; 6+ messages in thread
From: Simon Oosthoek @ 2012-12-26 21:07 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
* Junio C Hamano <gitster@pobox.com> [2012-12-26 12:35:28 -0800]:
> >
> > Anyway, I could imagine this as optional flag of git format-patch, so you could say:
> > $ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8
> >
> > But I'll save that as an exercise for the reader (or the future)
>
> I think a much more general approach would be to turn your script
> into "get-msg-id" script and use it like so:
>
> $ git format-patch --in-reply-to $(get-msg-id <mboxfile>) a7fe7de8
>
> Then you can reuse that script in a context outside format-patch,
> whereever you need the message-id in a single message in the
> mailbox.
>
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 various options to git format-patch (--to --cc --in-reply-to) based on the headers To:/Cc:/From:/Message-ID:
Cheers
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: generating format-patch options from an e-mail
2012-12-26 21:07 ` Simon Oosthoek
@ 2012-12-26 21:31 ` Pyeron, Jason J CTR (US)
2012-12-26 21:57 ` Jeff King
0 siblings, 1 reply; 6+ messages in thread
From: Pyeron, Jason J CTR (US) @ 2012-12-26 21:31 UTC (permalink / raw)
To: git@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1555 bytes --]
> -----Original Message-----
> From: Simon Oosthoek
> Sent: Wednesday, December 26, 2012 4:08 PM
>
> * Junio C Hamano <gitster@pobox.com> [2012-12-26 12:35:28 -0800]:
> > >
> > > Anyway, I could imagine this as optional flag of git format-patch,
> so you could say:
> > > $ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8
Anyway 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.
It would be a nice addition.
> > >
> > > But I'll save that as an exercise for the reader (or the future)
> >
> > I think a much more general approach would be to turn your script
> > into "get-msg-id" script and use it like so:
> >
> > $ git format-patch --in-reply-to $(get-msg-id <mboxfile>) a7fe7de8
> >
> > Then you can reuse that script in a context outside format-patch,
> > whereever you need the message-id in a single message in the
> > mailbox.
> >
>
> 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.
> various options to git format-patch (--to --cc --in-reply-to) based on
> the headers To:/Cc:/From:/Message-ID:
>
> Cheers
>
> Simon
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5615 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: generating format-patch options from an e-mail
2012-12-26 21:31 ` Pyeron, Jason J CTR (US)
@ 2012-12-26 21:57 ` Jeff King
0 siblings, 0 replies; 6+ messages in thread
From: Jeff King @ 2012-12-26 21:57 UTC (permalink / raw)
To: Pyeron, Jason J CTR (US); +Cc: git@vger.kernel.org
On Wed, Dec 26, 2012 at 09:31:46PM +0000, Pyeron, Jason J CTR (US) wrote:
> > 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-12-26 21:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-26 20:28 generating format-patch options from an e-mail Simon Oosthoek
-- strict thread matches above, loose matches on Subject: below --
2012-12-26 20:06 Simon Oosthoek
2012-12-26 20:35 ` Junio C Hamano
2012-12-26 21:07 ` Simon Oosthoek
2012-12-26 21:31 ` Pyeron, Jason J CTR (US)
2012-12-26 21:57 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).