{"thread":{"id":"3719","subject":"send-email: dependency removal, cleanup, + small feature","startedAt":"2006-03-25T10:43:30Z","lastAt":"2006-05-15T04:12:28Z","messageCount":24,"participants":["Eric Wong","Randal L. Schwartz","Junio C Hamano","Ryan Anderson","Martin Langhoff"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"17925","messageId":"11432834101430-git-send-email-normalperson@yhbt.net","threadId":"3719","inReplyTo":null,"subject":"send-email: dependency removal, cleanup, + small feature","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-25T10:43:30Z","receivedAt":"2006-03-25T10:43:30Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"\n1 - Change from Mail::Sendmail to Net::SMTP\n2 - use built-in time() instead of /bin/date '+%s'\n3 - lazy-load Email::Valid and make it optional\n4 - add support for mutt aliases files\n\nPatches 1 and 3 make git-send-email easily runnable with any\nreasonable Perl installation.  2 is just a good idea.  4 makes\nmy life a lot easier.\n\n-- \nEric Wong\n"},{"id":"17926","messageId":"11432834102700-git-send-email-normalperson@yhbt.net","threadId":"3719","inReplyTo":"11432834101430-git-send-email-normalperson@yhbt.net","subject":"[PATCH 1/4] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-25T10:43:30Z","receivedAt":"2006-03-25T10:43:30Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Net::SMTP is in the base Perl distribution, so users are more\nlikely to have it.  Net::SMTP also allows reusing the SMTP\nconnection, so sending multiple emails is faster.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n git-send-email.perl |   66 ++++++++++++++++++++++++++++++++-------------------\n 1 files changed, 41 insertions(+), 25 deletions(-)\n\n7155ae6e5f94a8fdf55f50029af27279dd36fd0a\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex b220d11..efaf457 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -19,11 +19,17 @@\n use strict;\n use warnings;\n use Term::ReadLine;\n-use Mail::Sendmail qw(sendmail %mailcfg);\n use Getopt::Long;\n use Data::Dumper;\n+use Net::SMTP;\n use Email::Valid;\n \n+# most mail servers generate the Date: header, but not all...\n+$ENV{LC_ALL} = 'C';\n+use POSIX qw/strftime/;\n+\n+my $smtp;\n+\n sub unique_email_list(@);\n sub cleanup_compose_files();\n \n@@ -271,35 +277,45 @@ $cc = \"\";\n \n sub send_message\n {\n-\tmy $to = join (\", \", unique_email_list(@to));\n-\n-\t%mail = (\tTo\t=>\t$to,\n-\t\t\tFrom\t=>\t$from,\n-\t\t\tCC\t=>\t$cc,\n-\t\t\tSubject\t=>\t$subject,\n-\t\t\tMessage\t=>\t$message,\n-\t\t\t'Reply-to'\t=>\t$from,\n-\t\t\t'In-Reply-To'\t=>\t$reply_to,\n-\t\t\t'Message-ID'\t=>\t$message_id,\n-\t\t\t'X-Mailer'\t=>\t\"git-send-email\",\n-\t\t);\n-\n-\t$mail{smtp} = $smtp_server;\n-\t$mailcfg{mime} = 0;\n-\n-\t#print Data::Dumper->Dump([\\%mail],[qw(*mail)]);\n-\n-\tsendmail(%mail) or die $Mail::Sendmail::error;\n+\tmy @recipients = unique_email_list(@to);\n+\tmy $to = join (\",\\n\\t\", @recipients);\n+\t@recipients = unique_email_list(@recipients,@cc);\n+\tmy $date = strftime('%a, %d %b %Y %H:%M:%S %z', localtime(time));\n+\n+\tmy $header = \"From: $from\n+To: $to\n+Cc: $cc\n+Subject: $subject\n+Reply-To: $from\n+Date: $date\n+Message-Id: $message_id\n+X-Mailer: git-send-email\n+\";\n+\t$header .= \"In-Reply-To: $reply_to\\n\" if $reply_to;\n+\n+\t$smtp ||= Net::SMTP->new( $smtp_server );\n+\t$smtp->mail( $from ) or die $smtp->message;\n+\t$smtp->to( @recipients ) or die $smtp->message;\n+\t$smtp->data or die $smtp->message;\n+\t$smtp->datasend(\"$header\\n$message\") or die $smtp->message;\n+\t$smtp->dataend() or die $smtp->message;\n+\t$smtp->ok or die \"Failed to send $subject\\n\".$smtp->message;\n \n \tif ($quiet) {\n-\t\tprintf \"Sent %s\\n\", $subject;\n+\t\tprint \"Sent $subject\\n\";\n \t} else {\n-\t\tprint \"OK. Log says:\\n\", $Mail::Sendmail::log;\n-\t\tprint \"\\n\\n\"\n+\t\tprint \"OK. Log says:\n+Date: $date\n+Server: $smtp_server Port: 25\n+From: $from\n+Subject: $subject\n+Cc: $cc\n+To: $to\n+\n+Result: \", $smtp->code, ' ', ($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\n \t}\n }\n \n-\n $reply_to = $initial_reply_to;\n make_message_id();\n $subject = $initial_subject;\n@@ -390,7 +406,7 @@ sub cleanup_compose_files() {\n \n }\n \n-\n+$smtp->quit if $smtp;\n \n sub unique_email_list(@) {\n \tmy %seen;\n-- \n1.2.4.gb622a\n"},{"id":"17927","messageId":"11432834111445-git-send-email-normalperson@yhbt.net","threadId":"3719","inReplyTo":"11432834101430-git-send-email-normalperson@yhbt.net","subject":"[PATCH 4/4] send-email: add support for mutt aliases files","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-25T10:43:31Z","receivedAt":"2006-03-25T10:43:31Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"I got rid of the Email::Valid dependency since writing\nRFC-correct email addresses is probably not a problem for most\nusers.\n\nIn my experience, misspelled usernames are a much bigger\nproblem.  I am prone to doing things like leaving out the 'k' in\nJunio's email address and other things that Email::Valid can't\ncatch.\n\nSince I use mutt and the aliases file is pretty simple, I've\nadded basic support for mutt alias files.\n\nTo setup git-send-email to use a mutt aliases file for a repo,\ndo this:\n\n  git-repo-config sendemail.muttaliases <mutt_alias_file_path>\n\nMore email clients/address book formats can easily be supported\nin the future.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n git-send-email.perl |   12 ++++++++++++\n 1 files changed, 12 insertions(+), 0 deletions(-)\n\n8bc65d178dd755ecd1f3c038b975b9bbe58c1015\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 73bba19..207b1fb 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -89,6 +89,15 @@ sub gitvar_ident {\n my ($author) = gitvar_ident('GIT_AUTHOR_IDENT');\n my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');\n \n+my %aliases;\n+if (my $mutt_aliases = `git-repo-config sendemail.muttaliases`) {\n+    chomp $mutt_aliases;\n+    open my $ma, '<', $mutt_aliases or die \"opening $mutt_aliases: $!\\n\";\n+    while (<$ma>) { if (/^alias\\s+(\\S+)\\s+(.*)/) { $aliases{$1} = $2 } }\n+    close $ma;\n+}\n+# aliases for more mail clients can be supported here:\n+\n my $prompting = 0;\n if (!defined $from) {\n \t$from = $author || $committer;\n@@ -112,6 +121,9 @@ if (!@to) {\n \t$prompting++;\n }\n \n+@to = map { $aliases{$_} || $_ } @to;\n+@initial_cc = map { $aliases{$_} || $_ } @initial_cc;\n+\n if (!defined $initial_subject && $compose) {\n \tdo {\n \t\t$_ = $term->readline(\"What subject should the emails start with? \",\n-- \n1.2.4.gb622a\n"},{"id":"17928","messageId":"11432834111972-git-send-email-normalperson@yhbt.net","threadId":"3719","inReplyTo":"11432834101430-git-send-email-normalperson@yhbt.net","subject":"[PATCH 3/4] send-email: lazy-load Email::Valid and make it optional","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-25T10:43:31Z","receivedAt":"2006-03-25T10:43:31Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"It's not installed on enough machines, and is overkill most of\nthe time.  We'll fallback to a very basic regexp (that is a\nlooser variant of what Email::Valid allows) just in case, but\nnothing like the monster regexp Email::Valid has to offer :)\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n git-send-email.perl |   16 +++++++++++++---\n 1 files changed, 13 insertions(+), 3 deletions(-)\n\n140eaf9b9d438ea489e6c72e2148feb3e355aea8\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 5e08817..73bba19 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -22,12 +22,12 @@ use Term::ReadLine;\n use Getopt::Long;\n use Data::Dumper;\n use Net::SMTP;\n-use Email::Valid;\n \n # most mail servers generate the Date: header, but not all...\n $ENV{LC_ALL} = 'C';\n use POSIX qw/strftime/;\n \n+my $have_email_valid = eval { require Email::Valid or undef };\n my $smtp;\n \n sub unique_email_list(@);\n@@ -250,6 +250,16 @@ EOT\n # Variables we set as part of the loop over files\n our ($message_id, $cc, %mail, $subject, $reply_to, $message);\n \n+sub extract_valid_address {\n+\tmy $address = shift;\n+\tif ($have_email_valid) {\n+\t\treturn Email::Valid->address($address);\n+\t} else {\n+\t\t# less robust/correct than the monster regexp in Email::Valid,\n+\t\t# but still does a 99% job, and one less dependency\n+\t\treturn ($address =~ /([^\\\"<>\\s]+@[^<>\\s]+)/);\n+\t}\n+}\n \n # Usually don't need to change anything below here.\n \n@@ -259,7 +269,7 @@ our ($message_id, $cc, %mail, $subject, \n # 1 second since the last time we were called.\n \n # We'll setup a template for the message id, using the \"from\" address:\n-my $message_id_from = Email::Valid->address($from);\n+my $message_id_from = extract_valid_address($from);\n my $message_id_template = \"<%s-git-send-email-$message_id_from>\";\n \n sub make_message_id\n@@ -412,7 +422,7 @@ sub unique_email_list(@) {\n \tmy @emails;\n \n \tforeach my $entry (@_) {\n-\t\tmy $clean = Email::Valid->address($entry);\n+\t\tmy $clean = extract_valid_address($entry);\n \t\tnext if $seen{$clean}++;\n \t\tpush @emails, $entry;\n \t}\n-- \n1.2.4.gb622a\n"},{"id":"17929","messageId":"11432834112657-git-send-email-normalperson@yhbt.net","threadId":"3719","inReplyTo":"11432834101430-git-send-email-normalperson@yhbt.net","subject":"[PATCH 2/4] send-email: use built-in time() instead of /bin/date '+%s'","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-25T10:43:31Z","receivedAt":"2006-03-25T10:43:31Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Signed-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n git-send-email.perl |    3 +--\n 1 files changed, 1 insertions(+), 2 deletions(-)\n\n079ce058710240643369589448660620cd925f5c\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex efaf457..5e08817 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -264,8 +264,7 @@ my $message_id_template = \"<%s-git-send-\n \n sub make_message_id\n {\n-\tmy $date = `date \"+\\%s\"`;\n-\tchomp($date);\n+\tmy $date = time;\n \tmy $pseudo_rand = int (rand(4200));\n \t$message_id = sprintf $message_id_template, \"$date$pseudo_rand\";\n \t#print \"new message id = $message_id\\n\"; # Was useful for debugging\n-- \n1.2.4.gb622a\n"},{"id":"17937","messageId":"86zmje36md.fsf@blue.stonehenge.com","threadId":"3719","inReplyTo":"11432834111972-git-send-email-normalperson@yhbt.net","subject":"Re: [PATCH 3/4] send-email: lazy-load Email::Valid and make it optional","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2006-03-25T15:07:38Z","receivedAt":"2006-03-25T15:07:38Z","isPatch":true,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Eric\" == Eric Wong <normalperson@yhbt.net> writes:\n\nEric> +my $have_email_valid = eval { require Email::Valid or undef };\n\nThis is not necessary... if eval fails, it returns undef by definition.  Your\ncode presumes that the non-zero last-expression-evaluated of a require is also\nreturned from the require, which I believe is only accidentally true, although\nthe behavior may be recently documented and therefore promised.  (On perl 5.8,\nit looks a bit fishy to me at a quick glance.)\n\nMy favorite idiom for a possibly failing eval-step is:\n\n        my $can_I_do_this = eval { riskything; 1 };\n\nIf riskything fails, eval returns undef.  If it succeeds, it evaluates the 1,\nand returns that.\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"},{"id":"17948","messageId":"7vfyl6uuzt.fsf@assigned-by-dhcp.cox.net","threadId":"3719","inReplyTo":"11432834111445-git-send-email-normalperson@yhbt.net","subject":"Re: [PATCH 4/4] send-email: add support for mutt aliases files","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-25T20:31:18Z","receivedAt":"2006-03-25T20:31:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> More email clients/address book formats can easily be supported\n> in the future.\n\n> +if (my $mutt_aliases = `git-repo-config sendemail.muttaliases`) {\n> +    chomp $mutt_aliases;\n> +    open my $ma, '<', $mutt_aliases or die \"opening $mutt_aliases: $!\\n\";\n> +    while (<$ma>) { if (/^alias\\s+(\\S+)\\s+(.*)/) { $aliases{$1} = $2 } }\n> +    close $ma;\n> +}\n> +# aliases for more mail clients can be supported here:\n> +\n\nI'd rather avoid proliferation of sendemail.{foo,bar,mutt,pine,...}aliases\nvariables.  Can we autodetect the alias file format and parse\nthe given file accordingly?\n"},{"id":"17949","messageId":"7v8xqyuuvo.fsf@assigned-by-dhcp.cox.net","threadId":"3719","inReplyTo":"11432834111972-git-send-email-normalperson@yhbt.net","subject":"Re: [PATCH 3/4] send-email: lazy-load Email::Valid and make it optional","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-25T20:33:47Z","receivedAt":"2006-03-25T20:33:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> +my $have_email_valid = eval { require Email::Valid or undef };\n\nMerlyn already commented on this and I'd appreciate this part to\nbe redone.\n"},{"id":"17958","messageId":"20060325235017.GN26071@mythryan2.michonline.com","threadId":"3719","inReplyTo":"7vfyl6uuzt.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 4/4] send-email: add support for mutt aliases files","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2006-03-25T23:50:17Z","receivedAt":"2006-03-25T23:50:17Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"On Sat, Mar 25, 2006 at 12:31:18PM -0800, Junio C Hamano wrote:\n> Eric Wong <normalperson@yhbt.net> writes:\n> \n> > More email clients/address book formats can easily be supported\n> > in the future.\n> \n> > +if (my $mutt_aliases = `git-repo-config sendemail.muttaliases`) {\n> > +    chomp $mutt_aliases;\n> > +    open my $ma, '<', $mutt_aliases or die \"opening $mutt_aliases: $!\\n\";\n> > +    while (<$ma>) { if (/^alias\\s+(\\S+)\\s+(.*)/) { $aliases{$1} = $2 } }\n> > +    close $ma;\n> > +}\n> > +# aliases for more mail clients can be supported here:\n> > +\n> \n> I'd rather avoid proliferation of sendemail.{foo,bar,mutt,pine,...}aliases\n> variables.  Can we autodetect the alias file format and parse\n> the given file accordingly?\n\nDon't bother - instead of lots of variables, just have two:\n\tsendemail.aliasesfile\n\tsendemail.aliasfiletype\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"17959","messageId":"20060325235859.GO26071@mythryan2.michonline.com","threadId":"3719","inReplyTo":"11432834102700-git-send-email-normalperson@yhbt.net","subject":"Re: [PATCH 1/4] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2006-03-25T23:58:59Z","receivedAt":"2006-03-25T23:58:59Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"On Sat, Mar 25, 2006 at 02:43:30AM -0800, Eric Wong wrote:\n> Net::SMTP is in the base Perl distribution, so users are more\n> likely to have it.  Net::SMTP also allows reusing the SMTP\n> connection, so sending multiple emails is faster.\n\nOverall, I like this set of cleanups, just one thing struck me as,\n\"why?\"\n\n>  \tif ($quiet) {\n> -\t\tprintf \"Sent %s\\n\", $subject;\n> +\t\tprint \"Sent $subject\\n\";\n\nThis seems to be a pointless change, and actually, might be long-term\ncounterproductive.\n\nAssumption: Eventually, we're going to want to internationalize git.\n\nIf that is true, we'll eventually do something like this to lines like\nthat:\n\tprintf( gettext(\"Send %s\\n\"), $subject);\n\nThe alternative:\n\tprint gettext(\"Send $subject\\n\");\ndoes not work.\n\n(The line that xgettext will see is 'Send $subject\\n', but when the\nprogram actually runs, gettext will see the interpolated version, which\nfails.)\n\nInternationalization may still be a ways off, but I think we're reaching\nthe point where it might be something we care to think about.\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"17961","messageId":"11433340323396-git-send-email-normalperson@yhbt.net","threadId":"3719","inReplyTo":"7v8xqyuuvo.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] send-email: lazy-load Email::Valid and make it optional","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-26T00:47:12Z","receivedAt":"2006-03-26T00:47:12Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"It's not installed on enough machines, and is overkill most of\nthe time.  We'll fallback to a very basic regexp just in case,\nbut nothing like the monster regexp Email::Valid has to offer :)\n\nSmall cleanup from Merlyn.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n git-send-email.perl |   16 +++++++++++++---\n 1 files changed, 13 insertions(+), 3 deletions(-)\n\n3f09a822e3871eeae521da80c748602862fc52ce\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 5e08817..7cbf11d 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -22,12 +22,12 @@ use Term::ReadLine;\n use Getopt::Long;\n use Data::Dumper;\n use Net::SMTP;\n-use Email::Valid;\n \n # most mail servers generate the Date: header, but not all...\n $ENV{LC_ALL} = 'C';\n use POSIX qw/strftime/;\n \n+my $have_email_valid = eval { require Email::Valid; 1 };\n my $smtp;\n \n sub unique_email_list(@);\n@@ -250,6 +250,16 @@ EOT\n # Variables we set as part of the loop over files\n our ($message_id, $cc, %mail, $subject, $reply_to, $message);\n \n+sub extract_valid_address {\n+\tmy $address = shift;\n+\tif ($have_email_valid) {\n+\t\treturn Email::Valid->address($address);\n+\t} else {\n+\t\t# less robust/correct than the monster regexp in Email::Valid,\n+\t\t# but still does a 99% job, and one less dependency\n+\t\treturn ($address =~ /([^\\\"<>\\s]+@[^<>\\s]+)/);\n+\t}\n+}\n \n # Usually don't need to change anything below here.\n \n@@ -259,7 +269,7 @@ our ($message_id, $cc, %mail, $subject, \n # 1 second since the last time we were called.\n \n # We'll setup a template for the message id, using the \"from\" address:\n-my $message_id_from = Email::Valid->address($from);\n+my $message_id_from = extract_valid_address($from);\n my $message_id_template = \"<%s-git-send-email-$message_id_from>\";\n \n sub make_message_id\n@@ -412,7 +422,7 @@ sub unique_email_list(@) {\n \tmy @emails;\n \n \tforeach my $entry (@_) {\n-\t\tmy $clean = Email::Valid->address($entry);\n+\t\tmy $clean = extract_valid_address($entry);\n \t\tnext if $seen{$clean}++;\n \t\tpush @emails, $entry;\n \t}\n-- \n1.2.4.gb622a\n"},{"id":"17963","messageId":"20060326005424.GA1773@localdomain","threadId":"3719","inReplyTo":"20060325235859.GO26071@mythryan2.michonline.com","subject":"Re: [PATCH 1/4] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-26T00:54:24Z","receivedAt":"2006-03-26T00:54:24Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Ryan Anderson <ryan@michonline.com> wrote:\n> On Sat, Mar 25, 2006 at 02:43:30AM -0800, Eric Wong wrote:\n> > Net::SMTP is in the base Perl distribution, so users are more\n> > likely to have it.  Net::SMTP also allows reusing the SMTP\n> > connection, so sending multiple emails is faster.\n> \n> Overall, I like this set of cleanups, just one thing struck me as,\n> \"why?\"\n> \n> >  \tif ($quiet) {\n> > -\t\tprintf \"Sent %s\\n\", $subject;\n> > +\t\tprint \"Sent $subject\\n\";\n> \n> This seems to be a pointless change, and actually, might be long-term\n> counterproductive.\n\nForce of habit, I think.  I originally rewrote that portion but thought\nI reverted it back to the way it was.  Besides, it's even slightly\nfaster this way :)  It could still be faster(!) if I just printed a list\n(like below).\n\n> Assumption: Eventually, we're going to want to internationalize git.\n> \n> If that is true, we'll eventually do something like this to lines like\n> that:\n> \tprintf( gettext(\"Send %s\\n\"), $subject);\n> \n> The alternative:\n> \tprint gettext(\"Send $subject\\n\");\n> does not work.\n\nprint gettext('Send '),$subject,\"\\n\";\n\n> (The line that xgettext will see is 'Send $subject\\n', but when the\n> program actually runs, gettext will see the interpolated version, which\n> fails.)\n> \n> Internationalization may still be a ways off, but I think we're reaching\n> the point where it might be something we care to think about.\n\n-- \nEric Wong\n"},{"id":"17964","messageId":"7vpskat3jd.fsf@assigned-by-dhcp.cox.net","threadId":"3719","inReplyTo":"20060326005424.GA1773@localdomain","subject":"Re: [PATCH 1/4] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-26T01:09:42Z","receivedAt":"2006-03-26T01:09:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> print gettext('Send '),$subject,\"\\n\";\n\nNak; who said all languages have verb before what the verb acts\nupon?\n"},{"id":"17965","messageId":"11433354063582-git-send-email-normalperson@yhbt.net","threadId":"3719","inReplyTo":"20060325235017.GN26071@mythryan2.michonline.com","subject":"[PATCH] send-email: address expansion for common mailers","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-26T01:10:06Z","receivedAt":"2006-03-26T01:10:06Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"mutt, gnus, pine, mailrc formats should be supported.\n\nTesting and feedback for correctness and completeness of all formats\nand support for additional formats would be good.\n\nNested expansions are also supported.\n\nTwo git repo-config keys are required for this\n(as suggested by Ryan Anderson):\n\n\tsendemail.aliasesfile = <filename of aliases file>\n\tsendemail.aliasfiletype = (mutt|gnus|pine|mailrc)\n\nI was initially working on auto-detection, but mailrc and mutt formats\ntend to throw each other off (they're alike, but handle multiple\naddresses per-alias differently).\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n git-send-email.perl |   46 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 46 insertions(+), 0 deletions(-)\n\naea3aaf9571ab639c67608f62771e73104842294\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 7cbf11d..208c119 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -89,6 +89,39 @@ sub gitvar_ident {\n my ($author) = gitvar_ident('GIT_AUTHOR_IDENT');\n my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');\n \n+my %aliases;\n+chomp(my $aliases_file = `git-repo-config sendemail.aliasesfile`);\n+chomp(my $aliasfiletype = `git-repo-config sendemail.aliasfiletype`);\n+my %parse_alias = (\n+\t# multiline formats can be supported in the future\n+\tmutt => sub { my $fh = shift; while (<$fh>) {\n+\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n+\t\t\tmy ($alias, $addr) = ($1, $2);\n+\t\t\t$addr =~ s/#.*$//; # mutt allows # comments\n+\t\t\t # commas delimit multiple addresses\n+\t\t\t$aliases{$alias} = [ split(/\\s*,\\s*/, $addr) ];\n+\t\t}}},\n+\tmailrc => sub { my $fh = shift; while (<$fh>) {\n+\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n+\t\t\t# spaces delimit multiple addresses\n+\t\t\t$aliases{$1} = [ split(/\\s+/, $2) ];\n+\t\t}}},\n+\tpine => sub { my $fh = shift; while (<$fh>) {\n+\t\tif (/^(\\S+)\\s+(.*)$/) {\n+\t\t\t$aliases{$1} = [ split(/\\s*,\\s*/, $2) ];\n+\t\t}}},\n+\tgnus => sub { my $fh = shift; while (<$fh>) {\n+\t\tif (/\\(define-mail-alias\\s+\"(\\S+?)\"\\s+\"(\\S+?)\"\\)/) {\n+\t\t\t$aliases{$1} = [ $2 ];\n+\t\t}}}\n+);\n+\n+if ($aliases_file && defined $parse_alias{$aliasfiletype}) {\n+\topen my $fh, '<', $aliases_file or die \"opening $aliases_file: $!\\n\";\n+\t$parse_alias{$aliasfiletype}->($fh);\n+\tclose $fh;\n+}\n+\n my $prompting = 0;\n if (!defined $from) {\n \t$from = $author || $committer;\n@@ -112,6 +145,19 @@ if (!@to) {\n \t$prompting++;\n }\n \n+sub expand_aliases {\n+\tmy @cur = @_;\n+\tmy @last;\n+\tdo {\n+\t\t@last = @cur;\n+\t\t@cur = map { $aliases{$_} ? @{$aliases{$_}} : $_ } @last;\n+\t} while (join(',',@cur) ne join(',',@last));\n+\treturn @cur;\n+}\n+\n+@to = expand_aliases(@to);\n+@initial_cc = expand_aliases(@initial_cc);\n+\n if (!defined $initial_subject && $compose) {\n \tdo {\n \t\t$_ = $term->readline(\"What subject should the emails start with? \",\n-- \n1.2.4.gb622a\n"},{"id":"17966","messageId":"1143336048205-git-send-email-normalperson@yhbt.net","threadId":"3719","inReplyTo":"20060325235859.GO26071@mythryan2.michonline.com","subject":"[PATCH] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-26T01:20:48Z","receivedAt":"2006-03-26T01:20:48Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Net::SMTP is in the base Perl distribution, so users are more\nlikely to have it.  Net::SMTP also allows reusing the SMTP\nconnection, so sending multiple emails is faster.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n Notes: Reverted printf => print change from earlier.\n\n git-send-email.perl |   64 ++++++++++++++++++++++++++++++++-------------------\n 1 files changed, 40 insertions(+), 24 deletions(-)\n\n8d65a0a4121ade9f48f186d0dcf9f41adc62b22c\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex b220d11..25daf16 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -19,11 +19,17 @@\n use strict;\n use warnings;\n use Term::ReadLine;\n-use Mail::Sendmail qw(sendmail %mailcfg);\n use Getopt::Long;\n use Data::Dumper;\n+use Net::SMTP;\n use Email::Valid;\n \n+# most mail servers generate the Date: header, but not all...\n+$ENV{LC_ALL} = 'C';\n+use POSIX qw/strftime/;\n+\n+my $smtp;\n+\n sub unique_email_list(@);\n sub cleanup_compose_files();\n \n@@ -271,35 +277,45 @@ $cc = \"\";\n \n sub send_message\n {\n-\tmy $to = join (\", \", unique_email_list(@to));\n-\n-\t%mail = (\tTo\t=>\t$to,\n-\t\t\tFrom\t=>\t$from,\n-\t\t\tCC\t=>\t$cc,\n-\t\t\tSubject\t=>\t$subject,\n-\t\t\tMessage\t=>\t$message,\n-\t\t\t'Reply-to'\t=>\t$from,\n-\t\t\t'In-Reply-To'\t=>\t$reply_to,\n-\t\t\t'Message-ID'\t=>\t$message_id,\n-\t\t\t'X-Mailer'\t=>\t\"git-send-email\",\n-\t\t);\n-\n-\t$mail{smtp} = $smtp_server;\n-\t$mailcfg{mime} = 0;\n-\n-\t#print Data::Dumper->Dump([\\%mail],[qw(*mail)]);\n-\n-\tsendmail(%mail) or die $Mail::Sendmail::error;\n+\tmy @recipients = unique_email_list(@to);\n+\tmy $to = join (\",\\n\\t\", @recipients);\n+\t@recipients = unique_email_list(@recipients,@cc);\n+\tmy $date = strftime('%a, %d %b %Y %H:%M:%S %z', localtime(time));\n+\n+\tmy $header = \"From: $from\n+To: $to\n+Cc: $cc\n+Subject: $subject\n+Reply-To: $from\n+Date: $date\n+Message-Id: $message_id\n+X-Mailer: git-send-email\n+\";\n+\t$header .= \"In-Reply-To: $reply_to\\n\" if $reply_to;\n+\n+\t$smtp ||= Net::SMTP->new( $smtp_server );\n+\t$smtp->mail( $from ) or die $smtp->message;\n+\t$smtp->to( @recipients ) or die $smtp->message;\n+\t$smtp->data or die $smtp->message;\n+\t$smtp->datasend(\"$header\\n$message\") or die $smtp->message;\n+\t$smtp->dataend() or die $smtp->message;\n+\t$smtp->ok or die \"Failed to send $subject\\n\".$smtp->message;\n \n \tif ($quiet) {\n \t\tprintf \"Sent %s\\n\", $subject;\n \t} else {\n-\t\tprint \"OK. Log says:\\n\", $Mail::Sendmail::log;\n-\t\tprint \"\\n\\n\"\n+\t\tprint \"OK. Log says:\n+Date: $date\n+Server: $smtp_server Port: 25\n+From: $from\n+Subject: $subject\n+Cc: $cc\n+To: $to\n+\n+Result: \", $smtp->code, ' ', ($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\n \t}\n }\n \n-\n $reply_to = $initial_reply_to;\n make_message_id();\n $subject = $initial_subject;\n@@ -390,7 +406,7 @@ sub cleanup_compose_files() {\n \n }\n \n-\n+$smtp->quit if $smtp;\n \n sub unique_email_list(@) {\n \tmy %seen;\n-- \n1.2.4.gb622a\n"},{"id":"17967","messageId":"7vlkuyt2ku.fsf@assigned-by-dhcp.cox.net","threadId":"3719","inReplyTo":"11433354063582-git-send-email-normalperson@yhbt.net","subject":"Re: [PATCH] send-email: address expansion for common mailers","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-26T01:30:25Z","receivedAt":"2006-03-26T01:30:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> Two git repo-config keys are required for this\n> (as suggested by Ryan Anderson):\n>\n> \tsendemail.aliasesfile = <filename of aliases file>\n> \tsendemail.aliasfiletype = (mutt|gnus|pine|mailrc)\n>\n> I was initially working on auto-detection, but mailrc and mutt formats\n> tend to throw each other off (they're alike, but handle multiple\n> addresses per-alias differently).\n\nI think specifying the type explicitly is probably not too much\nhassle for the end user, so that is fine.  Now, do we want to\nsupport more than one aliases file?\n"},{"id":"17971","messageId":"20060326024416.GA14234@localdomain","threadId":"3719","inReplyTo":"7vlkuyt2ku.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] send-email: address expansion for common mailers","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-26T02:44:16Z","receivedAt":"2006-03-26T02:44:16Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Eric Wong <normalperson@yhbt.net> writes:\n> \n> > Two git repo-config keys are required for this\n> > (as suggested by Ryan Anderson):\n> >\n> > \tsendemail.aliasesfile = <filename of aliases file>\n> > \tsendemail.aliasfiletype = (mutt|gnus|pine|mailrc)\n> >\n> > I was initially working on auto-detection, but mailrc and mutt formats\n> > tend to throw each other off (they're alike, but handle multiple\n> > addresses per-alias differently).\n> \n> I think specifying the type explicitly is probably not too much\n> hassle for the end user, so that is fine.  Now, do we want to\n> support more than one aliases file?\n\nIf they're different types, probably not.  But if it's the same type,\nit's pretty easy and I don't see why not.  This patch applies on top\nof the previous one.\n\nSubject: [PATCH] send-email: allow more than one alias file to be used\n\nThe aliasfiletype must be the same for all aliasesfiles, though.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n git-send-email.perl |   12 +++++++-----\n 1 files changed, 7 insertions(+), 5 deletions(-)\n\n16306f761b34505672a04bff333d6342724756c8\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex d3e1768..5d1e95c 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -90,7 +90,7 @@ my ($author) = gitvar_ident('GIT_AUTHOR_\n my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');\n \n my %aliases;\n-chomp(my $aliases_file = `git-repo-config sendemail.aliasesfile`);\n+chomp(my @alias_files = `git-repo-config --get-all sendemail.aliasesfile`);\n chomp(my $aliasfiletype = `git-repo-config sendemail.aliasfiletype`);\n my %parse_alias = (\n \t# multiline formats can be supported in the future\n@@ -116,10 +116,12 @@ my %parse_alias = (\n \t\t}}}\n );\n \n-if ($aliases_file && defined $parse_alias{$aliasfiletype}) {\n-\topen my $fh, '<', $aliases_file or die \"opening $aliases_file: $!\\n\";\n-\t$parse_alias{$aliasfiletype}->($fh);\n-\tclose $fh;\n+if (@alias_files && defined $parse_alias{$aliasfiletype}) {\n+\tforeach my $file (@alias_files) {\n+\t\topen my $fh, '<', $file or die \"opening $file: $!\\n\";\n+\t\t$parse_alias{$aliasfiletype}->($fh);\n+\t\tclose $fh;\n+\t}\n }\n \n my $prompting = 0;\n-- \n1.2.4.gb622a\n"},{"id":"19130","messageId":"46a038f90604251745u1b15ad99ka1aeff1cd8d8c344@mail.gmail.com","threadId":"3719","inReplyTo":"1143336048205-git-send-email-normalperson@yhbt.net","subject":"Re: [PATCH] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2006-04-26T00:45:41Z","receivedAt":"2006-04-26T00:45:41Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 3/26/06, Eric Wong <normalperson@yhbt.net> wrote:\n> Net::SMTP is in the base Perl distribution, so users are more\n> likely to have it.  Net::SMTP also allows reusing the SMTP\n> connection, so sending multiple emails is faster.\n\nThis is causing problems for me on my Debian sarge dev box.\n\n * If I have to believe strace(), Net::SMTP is trying to look up\n\"localhost\" via DNS. Sketchy workaround: use 127.0.0.1.\n\n * This box has nothing listening on port 25. It doesn't get email\nfrom the net, being a LAN machine, so I've told the debian config\nsystem that we don't need an smtp daemon. Net::SMTP doesn't know how\nto use /usr/bin/sendmail\n\n * That nasty @@VERSION@@ thing isn't valid perl, so working on this\ncode is a pain. Something like this (warning! broken diff ahead!)\nfixes it for me.\n\n@@ -292,6 +292,11 @@ sub send_message\n        @recipients = unique_email_list(@recipients,@cc);\n        my $date = strftime('%a, %d %b %Y %H:%M:%S %z', localtime($time++));\n\n+       my $gitversion = '@@GIT_VERSION@@';\n+       if ($gitversion eq '@@'.'GIT_VERSION@@') {\n+           $gitversion = `git --version`;\n+       }\n+\n        my $header = \"From: $from\n To: $to\n Cc: $cc\n@@ -299,11 +304,11 @@ Subject: $subject\n Reply-To: $from\n Date: $date\n Message-Id: $message_id\n-X-Mailer: git-send-email @@GIT_VERSION@@\n+X-Mailer: git-send-email $gitversion\n \";\n        $header .= \"In-Reply-To: $reply_to\\n\" if $reply_to;\n\ncheers,\n\n\nmartin\n"},{"id":"19167","messageId":"7vy7xsm6qa.fsf@assigned-by-dhcp.cox.net","threadId":"3719","inReplyTo":"46a038f90604251745u1b15ad99ka1aeff1cd8d8c344@mail.gmail.com","subject":"Re: [PATCH] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-04-26T20:17:49Z","receivedAt":"2006-04-26T20:17:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Martin Langhoff\" <martin.langhoff@gmail.com> writes:\n\n>  * This box has nothing listening on port 25. It doesn't get email\n> from the net, being a LAN machine, so I've told the debian config\n> system that we don't need an smtp daemon. Net::SMTP doesn't know how\n> to use /usr/bin/sendmail\n\nWouldn't --smtp-server=that.smtp.server work for you?  Ah, that\nwould not work if your use is to send a local mail.  Hmph...\n"},{"id":"19168","messageId":"46a038f90604261324w76f272edp93941d7e8645be8@mail.gmail.com","threadId":"3719","inReplyTo":"7vy7xsm6qa.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2006-04-26T20:24:06Z","receivedAt":"2006-04-26T20:24:06Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 4/27/06, Junio C Hamano <junkio@cox.net> wrote:\n> > system that we don't need an smtp daemon. Net::SMTP doesn't know how\n> > to use /usr/bin/sendmail\n\n\n> Wouldn't --smtp-server=that.smtp.server work for you?  Ah, that\n> would not work if your use is to send a local mail.  Hmph...\n\nWell, the machine knows that the smtp server is (I mean, files in /etc\nhave the right values in them), but I don't think often about it. Only\nwhen I am installing OSs or MTAs...\n\nI know... I'm a whiner! ;-) I'll probably do something that does an\neval and tries Mail::Sendmail and post it.\n\n\n\nmartin\n"},{"id":"19207","messageId":"20060428002744.GB9146@hand.yhbt.net","threadId":"3719","inReplyTo":"46a038f90604261324w76f272edp93941d7e8645be8@mail.gmail.com","subject":"Re: [PATCH] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-04-28T00:27:44Z","receivedAt":"2006-04-28T00:27:44Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Martin Langhoff <martin.langhoff@gmail.com> wrote:\n> On 4/27/06, Junio C Hamano <junkio@cox.net> wrote:\n> > > system that we don't need an smtp daemon. Net::SMTP doesn't know how\n> > > to use /usr/bin/sendmail\n> \n> \n> > Wouldn't --smtp-server=that.smtp.server work for you?  Ah, that\n> > would not work if your use is to send a local mail.  Hmph...\n> \n> Well, the machine knows that the smtp server is (I mean, files in /etc\n> have the right values in them), but I don't think often about it. Only\n> when I am installing OSs or MTAs...\n> \n> I know... I'm a whiner! ;-) I'll probably do something that does an\n> eval and tries Mail::Sendmail and post it.\n\nYou should be able to just open a pipe to:\n\t/usr/sbin/sendmail @recipients\nand just write headers\\nbody to that pipe.\n\nPerhaps allow and detect --smtp-server=/path/to/sendmail ?\n\n-- \nEric Wong\n"},{"id":"19208","messageId":"46a038f90604271804j195d62f3x93ae816e809f4ffd@mail.gmail.com","threadId":"3719","inReplyTo":"20060428002744.GB9146@hand.yhbt.net","subject":"Re: [PATCH] send-email: Change from Mail::Sendmail to Net::SMTP","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2006-04-28T01:04:32Z","receivedAt":"2006-04-28T01:04:32Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 4/28/06, Eric Wong <normalperson@yhbt.net> wrote:\n> You should be able to just open a pipe to:\n>         /usr/sbin/sendmail @recipients\n> and just write headers\\nbody to that pipe.\n\nSounds reasonable. I just looked at what Mail::Sendmail does and it\nisn't specially interesting. (There used to be a different Perl module\nthat did smart things, depending on what MTA it found, but I can't\nfind it now).\n\n> Perhaps allow and detect --smtp-server=/path/to/sendmail ?\n\nOh, it should just work with sendmail if it's there and we don't\nprovide --smtp-server ;-)\n\n\n\nm\n"},{"id":"19952","messageId":"11476592243181-git-send-email-normalperson@yhbt.net","threadId":"3719","inReplyTo":"20060326024416.GA14234@localdomain","subject":"[PATCH (resend)] send-email: address expansion for common mailers","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-05-15T02:13:44Z","receivedAt":"2006-05-15T02:13:44Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"mutt, gnus, pine, mailrc formats should be supported.\n\nTesting and feedback for correctness and completeness of all formats\nand support for additional formats would be good.\n\nNested expansions are also supported.\n\nMore than one alias file to be used.\n\nAll alias file formats must still of be the same type, though.\n\nTwo git repo-config keys are required for this\n(as suggested by Ryan Anderson):\n\n    sendemail.aliasesfile = <filename of aliases file>\n    sendemail.aliasfiletype = (mutt|gnus|pine|mailrc)\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\nLooks like this patch got forgotten a while ago, and I never noticed\nbecause I forgot to set WITH_SEND_EMAIL when doing make install.\nOf course, WITH_SEND_EMAIL should no longer be needed...\n\n git-send-email.perl |   48 ++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 48 insertions(+), 0 deletions(-)\n\nff6593287dc500853c1cf05bdb0f32f970f10c9d\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 703dd1f..d8c4b1f 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -89,6 +89,41 @@ sub gitvar_ident {\n my ($author) = gitvar_ident('GIT_AUTHOR_IDENT');\n my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');\n \n+my %aliases;\n+chomp(my @alias_files = `git-repo-config --get-all sendemail.aliasesfile`);\n+chomp(my $aliasfiletype = `git-repo-config sendemail.aliasfiletype`);\n+my %parse_alias = (\n+\t# multiline formats can be supported in the future\n+\tmutt => sub { my $fh = shift; while (<$fh>) {\n+\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n+\t\t\tmy ($alias, $addr) = ($1, $2);\n+\t\t\t$addr =~ s/#.*$//; # mutt allows # comments\n+\t\t\t # commas delimit multiple addresses\n+\t\t\t$aliases{$alias} = [ split(/\\s*,\\s*/, $addr) ];\n+\t\t}}},\n+\tmailrc => sub { my $fh = shift; while (<$fh>) {\n+\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n+\t\t\t# spaces delimit multiple addresses\n+\t\t\t$aliases{$1} = [ split(/\\s+/, $2) ];\n+\t\t}}},\n+\tpine => sub { my $fh = shift; while (<$fh>) {\n+\t\tif (/^(\\S+)\\s+(.*)$/) {\n+\t\t\t$aliases{$1} = [ split(/\\s*,\\s*/, $2) ];\n+\t\t}}},\n+\tgnus => sub { my $fh = shift; while (<$fh>) {\n+\t\tif (/\\(define-mail-alias\\s+\"(\\S+?)\"\\s+\"(\\S+?)\"\\)/) {\n+\t\t\t$aliases{$1} = [ $2 ];\n+\t\t}}}\n+);\n+\n+if (@alias_files && defined $parse_alias{$aliasfiletype}) {\n+\tforeach my $file (@alias_files) {\n+\t\topen my $fh, '<', $file or die \"opening $file: $!\\n\";\n+\t\t$parse_alias{$aliasfiletype}->($fh);\n+\t\tclose $fh;\n+\t}\n+}\n+\n my $prompting = 0;\n if (!defined $from) {\n \t$from = $author || $committer;\n@@ -112,6 +147,19 @@ if (!@to) {\n \t$prompting++;\n }\n \n+sub expand_aliases {\n+\tmy @cur = @_;\n+\tmy @last;\n+\tdo {\n+\t\t@last = @cur;\n+\t\t@cur = map { $aliases{$_} ? @{$aliases{$_}} : $_ } @last;\n+\t} while (join(',',@cur) ne join(',',@last));\n+\treturn @cur;\n+}\n+\n+@to = expand_aliases(@to);\n+@initial_cc = expand_aliases(@initial_cc);\n+\n if (!defined $initial_subject && $compose) {\n \tdo {\n \t\t$_ = $term->readline(\"What subject should the emails start with? \",\n-- \n1.3.2.g1c9b\n"},{"id":"19960","messageId":"20060515041227.GP32076@h4x0r5.com","threadId":"3719","inReplyTo":"11476592243181-git-send-email-normalperson@yhbt.net","subject":"Re: [PATCH (resend)] send-email: address expansion for common mailers","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2006-05-15T04:12:28Z","receivedAt":"2006-05-15T04:12:28Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"On Sun, May 14, 2006 at 07:13:44PM -0700, Eric Wong wrote:\n> mutt, gnus, pine, mailrc formats should be supported.\n> \n> Testing and feedback for correctness and completeness of all formats\n> and support for additional formats would be good.\n> \n> Nested expansions are also supported.\n> \n> More than one alias file to be used.\n> \n> All alias file formats must still of be the same type, though.\n> \n> Two git repo-config keys are required for this\n> (as suggested by Ryan Anderson):\n> \n>     sendemail.aliasesfile = <filename of aliases file>\n>     sendemail.aliasfiletype = (mutt|gnus|pine|mailrc)\n> \n> Signed-off-by: Eric Wong <normalperson@yhbt.net>\nAcked-by: Ryan Anderson <ryan@michonline.com>\n\n> ---\n> \n> Looks like this patch got forgotten a while ago, and I never noticed\n> because I forgot to set WITH_SEND_EMAIL when doing make install.\n> Of course, WITH_SEND_EMAIL should no longer be needed...\n> \n>  git-send-email.perl |   48 ++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 files changed, 48 insertions(+), 0 deletions(-)\n> \n> ff6593287dc500853c1cf05bdb0f32f970f10c9d\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 703dd1f..d8c4b1f 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -89,6 +89,41 @@ sub gitvar_ident {\n>  my ($author) = gitvar_ident('GIT_AUTHOR_IDENT');\n>  my ($committer) = gitvar_ident('GIT_COMMITTER_IDENT');\n>  \n> +my %aliases;\n> +chomp(my @alias_files = `git-repo-config --get-all sendemail.aliasesfile`);\n> +chomp(my $aliasfiletype = `git-repo-config sendemail.aliasfiletype`);\n> +my %parse_alias = (\n> +\t# multiline formats can be supported in the future\n> +\tmutt => sub { my $fh = shift; while (<$fh>) {\n> +\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n> +\t\t\tmy ($alias, $addr) = ($1, $2);\n> +\t\t\t$addr =~ s/#.*$//; # mutt allows # comments\n> +\t\t\t # commas delimit multiple addresses\n> +\t\t\t$aliases{$alias} = [ split(/\\s*,\\s*/, $addr) ];\n> +\t\t}}},\n> +\tmailrc => sub { my $fh = shift; while (<$fh>) {\n> +\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n> +\t\t\t# spaces delimit multiple addresses\n> +\t\t\t$aliases{$1} = [ split(/\\s+/, $2) ];\n> +\t\t}}},\n> +\tpine => sub { my $fh = shift; while (<$fh>) {\n> +\t\tif (/^(\\S+)\\s+(.*)$/) {\n> +\t\t\t$aliases{$1} = [ split(/\\s*,\\s*/, $2) ];\n> +\t\t}}},\n> +\tgnus => sub { my $fh = shift; while (<$fh>) {\n> +\t\tif (/\\(define-mail-alias\\s+\"(\\S+?)\"\\s+\"(\\S+?)\"\\)/) {\n> +\t\t\t$aliases{$1} = [ $2 ];\n> +\t\t}}}\n> +);\n> +\n> +if (@alias_files && defined $parse_alias{$aliasfiletype}) {\n> +\tforeach my $file (@alias_files) {\n> +\t\topen my $fh, '<', $file or die \"opening $file: $!\\n\";\n> +\t\t$parse_alias{$aliasfiletype}->($fh);\n> +\t\tclose $fh;\n> +\t}\n> +}\n> +\n>  my $prompting = 0;\n>  if (!defined $from) {\n>  \t$from = $author || $committer;\n> @@ -112,6 +147,19 @@ if (!@to) {\n>  \t$prompting++;\n>  }\n>  \n> +sub expand_aliases {\n> +\tmy @cur = @_;\n> +\tmy @last;\n> +\tdo {\n> +\t\t@last = @cur;\n> +\t\t@cur = map { $aliases{$_} ? @{$aliases{$_}} : $_ } @last;\n> +\t} while (join(',',@cur) ne join(',',@last));\n> +\treturn @cur;\n> +}\n> +\n> +@to = expand_aliases(@to);\n> +@initial_cc = expand_aliases(@initial_cc);\n> +\n>  if (!defined $initial_subject && $compose) {\n>  \tdo {\n>  \t\t$_ = $term->readline(\"What subject should the emails start with? \",\n> -- \n> 1.3.2.g1c9b\n> \n> \n"}]}