X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-send-email.perl;h=9547cc37a1c4fd326876e26b081bc6d6a5141ce6;hb=7b55eee77e11da162fb197a79b72af375ed0f1d0;hp=69559b289a28acf7fd095260797535f62db8172e;hpb=fa548703d1e60231828266856467d3d73ac51f0f;p=git.git diff --git a/git-send-email.perl b/git-send-email.perl index 69559b289..9547cc37a 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -21,8 +21,11 @@ use warnings; use Term::ReadLine; use Getopt::Long; use Data::Dumper; +use Term::ANSIColor; use Git; +$SIG{INT} = sub { print color("reset"), "\n"; exit }; + package FakeTerm; sub new { my ($class, $reason) = @_; @@ -46,6 +49,9 @@ Options: --cc Specify an initial "Cc:" list for the entire series of emails. + --cc-cmd Specify a command to execute per file which adds + per file specific cc address entries + --bcc Specify a list of email addresses that should be Bcc: on all the emails. @@ -157,13 +163,14 @@ if ($@) { my ($quiet, $dry_run) = (0, 0); # Variables with corresponding config settings -my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc); +my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd); my %config_settings = ( "thread" => [\$thread, 1], "chainreplyto" => [\$chain_reply_to, 1], "suppressfrom" => [\$suppress_from, 0], "signedoffcc" => [\$signed_off_cc, 1], + "cccmd" => [\$cc_cmd, ""], ); foreach my $setting (keys %config_settings) { @@ -189,6 +196,7 @@ my $rc = GetOptions("sender|from=s" => \$sender, "smtp-server=s" => \$smtp_server, "compose" => \$compose, "quiet" => \$quiet, + "cc-cmd=s" => \$cc_cmd, "suppress-from!" => \$suppress_from, "signed-off-cc|signed-off-by-cc!" => \$signed_off_cc, "dry-run" => \$dry_run, @@ -309,7 +317,8 @@ if ($thread && !defined $initial_reply_to && $prompting) { } while (!defined $_); $initial_reply_to = $_; - $initial_reply_to =~ s/(^\s+|\s+$)//g; + $initial_reply_to =~ s/^\s+?\s+$/>/; } if (!$smtp_server) { @@ -428,10 +437,17 @@ sub extract_valid_address { # We'll setup a template for the message id, using the "from" address: +my ($message_id_stamp, $message_id_serial); sub make_message_id { - my $date = time; - my $pseudo_rand = int (rand(4200)); + my $uniq; + if (!defined $message_id_stamp) { + $message_id_stamp = sprintf("%s-%s", time, $$); + $message_id_serial = 0; + } + $message_id_serial++; + $uniq = "$message_id_stamp-$message_id_serial"; + my $du_part; for ($sender, $repocommitter, $repoauthor) { $du_part = extract_valid_address(sanitize_address($_)); @@ -441,8 +457,8 @@ sub make_message_id use Sys::Hostname qw(); $du_part = 'user@' . Sys::Hostname::hostname(); } - my $message_id_template = "<%s-git-send-email-$du_part>"; - $message_id = sprintf $message_id_template, "$date$pseudo_rand"; + my $message_id_template = "<%s-git-send-email-%s>"; + $message_id = sprintf($message_id_template, $uniq, $du_part); #print "new message id = $message_id\n"; # Was useful for debugging } @@ -652,11 +668,26 @@ foreach my $t (@files) { } } close F; + + if ($cc_cmd ne "") { + open(F, "$cc_cmd $t |") + or die "(cc-cmd) Could not execute '$cc_cmd'"; + while() { + my $c = $_; + $c =~ s/^\s*//g; + $c =~ s/\n$//g; + push @cc, $c; + printf("(cc-cmd) Adding cc: %s from: '%s'\n", + $c, $cc_cmd) unless $quiet; + } + close F + or die "(cc-cmd) failed to close pipe to '$cc_cmd'"; + } + if (defined $author) { $message = "From: $author\n\n$message"; } - send_message(); # set up for the next message