{"thread":{"id":"39400","subject":"[PATCH] git-send-email.perl: Add sendmail aliases support","startedAt":"2015-05-21T18:51:40Z","lastAt":"2015-05-21T22:45:26Z","messageCount":8,"participants":["Allen Hubbe","Junio C Hamano","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"261837","messageId":"3f1091c3de6e4e62037bc3c84c69026e33ee9707.1432229888.git.allenbh@gmail.com","threadId":"39400","inReplyTo":null,"subject":"[PATCH] git-send-email.perl: Add sendmail aliases support","fromName":"Allen Hubbe","fromEmail":"allenbh@gmail.com","sentAt":"2015-05-21T18:51:40Z","receivedAt":"2015-05-21T18:51:40Z","isPatch":true,"sender":{"key":"allenbh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/812915?v=4"},"body":"Support sendmail (and postfix) style email aliases in git-send-email.\nThis is the format of /etc/mail/aliases, documented by `man 5 aliases`.\nThe man page may be provided by sendmail or postfix on your system, or\nby another email service that uses the same configuration file.\n\nSee also: http://www.postfix.org/aliases.5.html.\n\nThis format is more simple than the other alias file formats, so it may\nbe preferred by some users.  The format is as follows.\n\n<alias>: <address|alias>[, <address|alias>...]\n\nExample (no indent in aliases file):\n\talice: Alice W Land <awol@example.com>\n\tbob: Robert Bobbyton <bob@example.com>\n\tchloe: chloe@example.com\n\tabgroup: alice, bob\n\tbcgrp: bob, chloe, Other <o@example.com>\n\nThis patch DOES NOT support line continuations as are described by the\nspecification.  Line continuations are indicated by either (or both) a\ntrailing '\\' on the line to be continued, or leading whitespace on the\ncontinuing line.  This patch does not do anything with the trailing '\\',\nand ignores lines starting with whitespace.\n\nThis patch also ignores lines that starts with '#', comment character,\nand empty lines.\n\nSigned-off-by: Allen Hubbe <allenbh@gmail.com>\n---\n git-send-email.perl | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex e1e9b14..5f2ec0d 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -515,7 +515,12 @@ my %parse_alias = (\n \t\t\t       $aliases{$alias} = [ split_addrs($addr) ];\n \t\t\t  }\n \t\t      } },\n-\n+\tsendmail => sub { my $fh = shift; while (<$fh>) {\n+\t\tnext if /^$|^#|^\\s/;\n+\t\tif (/^(\\S+)\\s*:\\s*(.*?)\\\\?$/) {\n+\t\t\tmy ($alias, $addr) = ($1, $2);\n+\t\t\t$aliases{$alias} = [ split_addrs($addr) ];\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-- \n2.3.4\n"},{"id":"261844","messageId":"xmqqioblisyk.fsf@gitster.dls.corp.google.com","threadId":"39400","inReplyTo":"3f1091c3de6e4e62037bc3c84c69026e33ee9707.1432229888.git.allenbh@gmail.com","subject":"Re: [PATCH] git-send-email.perl: Add sendmail aliases support","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-21T20:19:47Z","receivedAt":"2015-05-21T20:19:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Allen Hubbe <allenbh@gmail.com> writes:\n\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index e1e9b14..5f2ec0d 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -515,7 +515,12 @@ my %parse_alias = (\n>  \t\t\t       $aliases{$alias} = [ split_addrs($addr) ];\n>  \t\t\t  }\n>  \t\t      } },\n> -\n> +\tsendmail => sub { my $fh = shift; while (<$fh>) {\n> +\t\tnext if /^$|^#|^\\s/;\n> +\t\tif (/^(\\S+)\\s*:\\s*(.*?)\\\\?$/) {\n> +\t\t\tmy ($alias, $addr) = ($1, $2);\n> +\t\t\t$aliases{$alias} = [ split_addrs($addr) ];\n> +\t\t}}},\n\nLet me unfold the line only to make commenting it easier.\n\n\tsendmail => sub {\n        \tmy $fh = shift;\n                while (<$fh>) {\n\t\t\tnext if /^$|^#|^\\s/;\n\t\t\tif (/^(\\S+)\\s*:\\s*(.*?)\\\\?$/) {\n\t\t\t\tmy ($alias, $addr) = ($1, $2);\n\t\t\t\t$aliases{$alias} = [ split_addrs($addr) ];\n\t\t\t}\n\t\t}\n\t},\n\nIt is probably OK to omit support for folded lines, but wouldn't it\nbe easy enough to be a bit more helpful to give a warning when you\nfind such lines in the input?  Otherwise you will leave the users\nwondering why some of their aliases work while others don't.\n\nPerhaps like this (this is not even an output from \"diff\" but typed\nin my MUA, so there may be typos---take it just as illustrating\nideas)?\n\nThat way, users can fold the input themselves and try again if they\nwanted to.  The warning _may_ have to be squelched after a few hits\nto keep the result usable, though.\n\n\tsendmail => sub {\n        \tmy $fh = shift;\n                while (<$fh>) {\n-\t\t\tnext if /^$|^#|^\\s/;\n-\t\t\tif (/^(\\S+)\\s*:\\s*(.*?)\\\\?$/) {\n+\t\t\tnext if /^$|^#/;\n+\t\t\tif (/^\\s/ || /\\\\$/) {\n+\t\t\t\tprint STDERR \"$.: $_\";\n+\t\t\t\tprint STDERR \"continuation lines in alias not supported\\n\";\n+\t\t\t\tnext;\n+\t\t\t}\n+\t\t\tif (/^(\\S+)\\s*:\\s*(.*)$/) {\n\t\t\t\tmy ($alias, $addr) = ($1, $2);\n\t\t\t\t$aliases{$alias} = [ split_addrs($addr) ];\n\t\t\t}\n\t\t}\n\t},\n\nThanks.\n"},{"id":"261850","messageId":"CAJ80satMSCGydLRb5k=xpSqxXSBL=_T7nsHEz3jsuFV9MdmmtA@mail.gmail.com","threadId":"39400","inReplyTo":"xmqqioblisyk.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-send-email.perl: Add sendmail aliases support","fromName":"Allen Hubbe","fromEmail":"allenbh@gmail.com","sentAt":"2015-05-21T20:48:15Z","receivedAt":"2015-05-21T20:48:15Z","isPatch":true,"sender":{"key":"allenbh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/812915?v=4"},"body":"On Thu, May 21, 2015 at 4:19 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Allen Hubbe <allenbh@gmail.com> writes:\n>\n>> diff --git a/git-send-email.perl b/git-send-email.perl\n>> index e1e9b14..5f2ec0d 100755\n>> --- a/git-send-email.perl\n>> +++ b/git-send-email.perl\n>> @@ -515,7 +515,12 @@ my %parse_alias = (\n>>                              $aliases{$alias} = [ split_addrs($addr) ];\n>>                         }\n>>                     } },\n>> -\n>> +     sendmail => sub { my $fh = shift; while (<$fh>) {\n>> +             next if /^$|^#|^\\s/;\n>> +             if (/^(\\S+)\\s*:\\s*(.*?)\\\\?$/) {\n>> +                     my ($alias, $addr) = ($1, $2);\n>> +                     $aliases{$alias} = [ split_addrs($addr) ];\n>> +             }}},\n>\n> Let me unfold the line only to make commenting it easier.\n>\n>         sendmail => sub {\n>                 my $fh = shift;\n>                 while (<$fh>) {\n>                         next if /^$|^#|^\\s/;\n>                         if (/^(\\S+)\\s*:\\s*(.*?)\\\\?$/) {\n>                                 my ($alias, $addr) = ($1, $2);\n>                                 $aliases{$alias} = [ split_addrs($addr) ];\n>                         }\n>                 }\n>         },\n>\n> It is probably OK to omit support for folded lines, but wouldn't it\n> be easy enough to be a bit more helpful to give a warning when you\n> find such lines in the input?  Otherwise you will leave the users\n> wondering why some of their aliases work while others don't.\n\nThe diff doesn't show enough context to include this comment:\n\nmy %parse_alias = (\n        # multiline formats can be supported in the future\n...\n\nI can't be sure the author's intent, but my interpretation is such.\nThe parsers do not support multiline, even though the format might\nallow it by definition.  Another interpretation could be, no multiline\nformats allowed, or, the first person to add a multiline format should\nremove this comment.\n\nI think the first interpretation is correct, because according to this\nscript, the mutt format also has continuation lines.  I didn't find a\nmore authoritative document in my quick search.\n\nhttp://www.wizzu.com/mutt/checkalias.pl\n\nI suppose at this point it is also worth mentioning that /etc/aliases\ndoesn't claim to support aliases of aliases, but does support\nnon-email-addresses like mail directories and pipes.  I don't think\nmost git users would try to send email directly to a pipe.\n\nMy motivation for this patch was not really to support the sendmail\naliases file directly.  The commit message may therefore be\nmisleading.  So, I could also rewrite the commit message to say\nsomething like, \"loosely based on\" the sendmail aliases format, if the\nexceptions to the format in the current message are not enough.\nReally, I just prefer the simpler <alias>: <email|alias> syntax\ninstead of the ones for mutt, elm, etc, and that is why I wrote this\npatch.\n\n>\n> Perhaps like this (this is not even an output from \"diff\" but typed\n> in my MUA, so there may be typos---take it just as illustrating\n> ideas)?\n>\n> That way, users can fold the input themselves and try again if they\n> wanted to.  The warning _may_ have to be squelched after a few hits\n> to keep the result usable, though.\n>\n>         sendmail => sub {\n>                 my $fh = shift;\n>                 while (<$fh>) {\n> -                       next if /^$|^#|^\\s/;\n> -                       if (/^(\\S+)\\s*:\\s*(.*?)\\\\?$/) {\n> +                       next if /^$|^#/;\n> +                       if (/^\\s/ || /\\\\$/) {\n> +                               print STDERR \"$.: $_\";\n> +                               print STDERR \"continuation lines in alias not supported\\n\";\n> +                               next;\n> +                       }\n> +                       if (/^(\\S+)\\s*:\\s*(.*)$/) {\n>                                 my ($alias, $addr) = ($1, $2);\n>                                 $aliases{$alias} = [ split_addrs($addr) ];\n>                         }\n>                 }\n>         },\n\nThat's interesting.  I'd like to hear a second opinion before I add\nthat.  It's a good idea, but none of the other parsing routines print\nout messages.\n\n>\n> Thanks.\n"},{"id":"261852","messageId":"CAPig+cQFana40n=SCBOC0P2v4Ss7Via3eS6Ms2rU=M9_V_3Osg@mail.gmail.com","threadId":"39400","inReplyTo":"CAJ80satMSCGydLRb5k=xpSqxXSBL=_T7nsHEz3jsuFV9MdmmtA@mail.gmail.com","subject":"Re: [PATCH] git-send-email.perl: Add sendmail aliases support","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-05-21T21:05:27Z","receivedAt":"2015-05-21T21:05:27Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, May 21, 2015 at 4:48 PM, Allen Hubbe <allenbh@gmail.com> wrote:\n> My motivation for this patch was not really to support the sendmail\n> aliases file directly.  The commit message may therefore be\n> misleading.  So, I could also rewrite the commit message to say\n> something like, \"loosely based on\" the sendmail aliases format, if the\n> exceptions to the format in the current message are not enough.\n\nThat probably would be a good idea. After reading the 'aliases' man\npage you cited[1], I was wondering why your parser diverged from it in\nso many ways. In addition to lack of support for folded lines, your\nformat:\n\n* only recognizes comment lines when '#' is the first character,\nwhereas [1] allows whitespace before '#'\n\n* only recognizes zero-length lines as empty, whereas [1] more loosely\ninterprets a whitespace-only line as empty\n\n* doesn't support quoting the 'name' part of \"name: value\" as [1] does\n\n> Really, I just prefer the simpler <alias>: <email|alias> syntax\n> instead of the ones for mutt, elm, etc, and that is why I wrote this\n> patch.\n\nYour patch is missing a documentation update\n(Documentation/git-send-email.txt) and new tests\n(t/t9001-send-email.sh).\n\n[1] http://www.postfix.org/aliases.5.html\n"},{"id":"261854","messageId":"xmqq617liq6l.fsf@gitster.dls.corp.google.com","threadId":"39400","inReplyTo":"CAJ80satMSCGydLRb5k=xpSqxXSBL=_T7nsHEz3jsuFV9MdmmtA@mail.gmail.com","subject":"Re: [PATCH] git-send-email.perl: Add sendmail aliases support","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-21T21:19:46Z","receivedAt":"2015-05-21T21:19:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Allen Hubbe <allenbh@gmail.com> writes:\n\n> The diff doesn't show enough context to include this comment:\n>\n> my %parse_alias = (\n>         # multiline formats can be supported in the future\n> ...\n>\n> I can't be sure the author's intent, but my interpretation is such.\n> The parsers do not support multiline, even though the format might\n> allow it by definition.  Another interpretation could be, no multiline\n> formats allowed, or, the first person to add a multiline format should\n> remove this comment.\n\nI think that comment were only meant to apply to the first one, mutt.\n\nIn any case, you should read it this way:\n\n    Some formats may support multi-line; this parser back when the\n    comment was written did not support an alias file that uses such\n    a feature, but it is OK to make it support them in the future. \n\nAfter all, these subs are slurping from $fh and doing the parsing\nthemselves, so they are free to do multi-line if they wanted to.\nIt's not like there is a calling function that feeds input line by\nline after splitting a logically continued line into two (and if\nthat were the case, supporting multi-line format may become harder\nor even impossible).\n\nAnd as I said, it is OK not to support ones that have folded lines.\n\nAll I was saying was that we should not SILENTLY fail or do a wrong\nthing when we find something we do not support.\n"},{"id":"261856","messageId":"CAJ80savEBYGKLJx8pN+4xsDodi0PJcV2YHJLukDKztg3YV__FQ@mail.gmail.com","threadId":"39400","inReplyTo":"CAPig+cQFana40n=SCBOC0P2v4Ss7Via3eS6Ms2rU=M9_V_3Osg@mail.gmail.com","subject":"Re: [PATCH] git-send-email.perl: Add sendmail aliases support","fromName":"Allen Hubbe","fromEmail":"allenbh@gmail.com","sentAt":"2015-05-21T21:30:30Z","receivedAt":"2015-05-21T21:30:30Z","isPatch":true,"sender":{"key":"allenbh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/812915?v=4"},"body":"On Thu, May 21, 2015 at 5:05 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Thu, May 21, 2015 at 4:48 PM, Allen Hubbe <allenbh@gmail.com> wrote:\n>> My motivation for this patch was not really to support the sendmail\n>> aliases file directly.  The commit message may therefore be\n>> misleading.  So, I could also rewrite the commit message to say\n>> something like, \"loosely based on\" the sendmail aliases format, if the\n>> exceptions to the format in the current message are not enough.\n>\n> That probably would be a good idea. After reading the 'aliases' man\n> page you cited[1], I was wondering why your parser diverged from it in\n> so many ways. In addition to lack of support for folded lines, your\n> format:\n>\n> * only recognizes comment lines when '#' is the first character,\n> whereas [1] allows whitespace before '#'\n>\n> * only recognizes zero-length lines as empty, whereas [1] more loosely\n> interprets a whitespace-only line as empty\n>\n> * doesn't support quoting the 'name' part of \"name: value\" as [1] does\n>\n\nThose are good points.  Maybe I shouldn't even mention sendmail at\nall, not in the name of the format, and not in the commit message.\nWhat name would be a good name for this format?\n\nAll the other formats would are based on the formats of email clients.\nAdding sendmail was a departure from that.  Adding a format that is\nnot associated with any email program would be an even further\ndeparture.  I don't know how other people feel about this.  Hopefully,\nif this new format seems like it would be useful, the fact that it is\nnot an email client format can be overlooked.\n\n>> Really, I just prefer the simpler <alias>: <email|alias> syntax\n>> instead of the ones for mutt, elm, etc, and that is why I wrote this\n>> patch.\n>\n> Your patch is missing a documentation update\n> (Documentation/git-send-email.txt) and new tests\n> (t/t9001-send-email.sh).\n\nThanks for the direction.\n\n>\n> [1] http://www.postfix.org/aliases.5.html\n"},{"id":"261857","messageId":"xmqqwq01haqq.fsf@gitster.dls.corp.google.com","threadId":"39400","inReplyTo":"CAJ80savEBYGKLJx8pN+4xsDodi0PJcV2YHJLukDKztg3YV__FQ@mail.gmail.com","subject":"Re: [PATCH] git-send-email.perl: Add sendmail aliases support","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-05-21T21:38:37Z","receivedAt":"2015-05-21T21:38:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Allen Hubbe <allenbh@gmail.com> writes:\n\n> Those are good points.  Maybe I shouldn't even mention sendmail at\n> all, not in the name of the format, and not in the commit message.\n> What name would be a good name for this format?\n\n\"simple\"?\n\nAnd if you are going to define such a format, then I do not think\nyou would even need to pretend that someday you might support\nline folding (hence there is no need for \"eh, excuse me, you seem to\nhave wanted to express a long folded line here, but I do not support\nit (yet)\" warning messages).\n"},{"id":"261862","messageId":"CAJ80sau3EzaDgvTkM1mNDWSd_+xHC66YkRUS0c618yAm444Czg@mail.gmail.com","threadId":"39400","inReplyTo":"xmqqwq01haqq.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-send-email.perl: Add sendmail aliases support","fromName":"Allen Hubbe","fromEmail":"allenbh@gmail.com","sentAt":"2015-05-21T22:45:26Z","receivedAt":"2015-05-21T22:45:26Z","isPatch":true,"sender":{"key":"allenbh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/812915?v=4"},"body":"On Thu, May 21, 2015 at 5:38 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Allen Hubbe <allenbh@gmail.com> writes:\n>\n>> Those are good points.  Maybe I shouldn't even mention sendmail at\n>> all, not in the name of the format, and not in the commit message.\n>> What name would be a good name for this format?\n>\n> \"simple\"?\n\nAlright, as long as people agree that _this_ is the simple format, and\nnot something else.  I'll call it simple in v2, and see if anyone\ncomplains.\n\n>\n> And if you are going to define such a format, then I do not think\n> you would even need to pretend that someday you might support\n> line folding (hence there is no need for \"eh, excuse me, you seem to\n> have wanted to express a long folded line here, but I do not support\n> it (yet)\" warning messages).\n>\n"}]}