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 

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 
$ git format-patch -s --in-reply-to-email <mboxfile> a7fe7de8

But I'll save that as an exercise for the reader (or the future)



PS, now with the script

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?):.*[ ,<](.*?)[>, ]/) {
					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 via email to