From 8037d1a31a60e9645c56a8bebb01d0e13970b93f Mon Sep 17 00:00:00 2001 From: Ryan Anderson Date: Sun, 31 Jul 2005 20:04:24 -0400 Subject: [PATCH] [PATCH] git-send-email-script: Reformat readline interface and generate a better message-id. Signed-off-by: Ryan Anderson Signed-off-by: Junio C Hamano --- git-send-email-script | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/git-send-email-script b/git-send-email-script index 288662be..60aef632 100755 --- a/git-send-email-script +++ b/git-send-email-script @@ -69,30 +69,38 @@ close(GITVAR); if (!defined $from) { $from = $author || $committer; - 1 while (!defined ($_ = $term->readline("Who should the emails appear to be from? ", - $from))); + do { + $_ = $term->readline("Who should the emails appear to be from? ", + $from); + while (!defined $_); + $from = $_; print "Emails will be sent from: ", $from, "\n"; } if (!@to) { - 1 while (!defined ($_ = $term->readline("Who should the emails be sent to? ", - ""))); + do { + $_ = $term->readline("Who should the emails be sent to? ", + ""); + } while (!defined $_); my $to = $_; push @to, split /,/, $to; } if (!defined $initial_subject) { - 1 while (!defined ($_ = - $term->readline("What subject should the emails start with? ", - $initial_subject))); + do { + $_ = $term->readline("What subject should the emails start with? ", + $initial_subject); + } while (!defined $_); $initial_subject = $_; } if (!defined $initial_reply_to) { - 1 while (!defined ($_ = - $term->readline("Message-ID to be used as In-Reply-To? ", - $initial_reply_to))); + do { + $_= $term->readline("Message-ID to be used as In-Reply-To? ", + $initial_reply_to); + } while (!defined $_); + $initial_reply_to = $_; $initial_reply_to =~ s/(^\s+|\s+$)//g; } @@ -104,8 +112,9 @@ for my $f (@ARGV) { opendir(DH,$f) or die "Failed to opendir $f: $!"; - push @files, map { +$f . "/" . $_ } grep !/^\.{1,2}$/, - sort readdir(DH); + push @files, map { +$f . "/" . $_ } grep { -f $_ } + sort readdir(DH); + } elsif (-f $f) { push @files, $f; @@ -142,13 +151,18 @@ our ($message_id, $cc, %mail, $subject, $reply_to, $message); # of seconds since the beginning of Unix time and tacking on # a random number to the end, in case we are called quicker than # 1 second since the last time we were called. + +# We'll setup a template for the message id, using the "from" address: +my $message_id_from = Email::Valid->address($from); +my $message_id_template = "<%s-git-send-email-$from>"; + sub make_message_id { my $date = `date "+\%s"`; chomp($date); my $pseudo_rand = int (rand(4200)); - $message_id = "<$date$pseudo_rand\@foobar.com>"; - print "new message id = $message_id\n"; + $message_id = sprintf $message_id_template, "$date$pseudo_rand"; + #print "new message id = $message_id\n"; # Was useful for debugging } -- 2.11.0