git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Oosthoek <s.oosthoek@xs4all.nl>
To: git@vger.kernel.org
Subject: generating format-patch options from an e-mail
Date: Wed, 26 Dec 2012 21:28:30 +0100	[thread overview]
Message-ID: <20121226202830.GA29813@simaj.xs4all.nl> (raw)

[-- 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\"";
}

             reply	other threads:[~2012-12-26 20:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-26 20:28 Simon Oosthoek [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-12-26 20:06 generating format-patch options from an e-mail 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121226202830.GA29813@simaj.xs4all.nl \
    --to=s.oosthoek@xs4all.nl \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).