{"thread":{"id":"41733","subject":"[PATCH] send-email: ignore trailing whitespace in mailrc alias file","startedAt":"2016-03-17T22:08:16Z","lastAt":"2016-03-17T23:58:22Z","messageCount":2,"participants":["Stefan Beller","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"281089","messageId":"1458252496-4118-1-git-send-email-sbeller@google.com","threadId":"41733","inReplyTo":null,"subject":"[PATCH] send-email: ignore trailing whitespace in mailrc alias file","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-03-17T22:08:16Z","receivedAt":"2016-03-17T22:08:16Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nThis fixes send-email which would not work with mailrc alias files\nwhich had trailing whitespaces.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\n> On Thu, Mar 17, 2016 at 10:47:50AM -0700, Stefan Beller wrote:\n>\n> sent from git-send-email with a corrupt .mailrc file.\n> \n> Great, but could probably use a better commit message. ;P\n> \n> -Peff\n\nUhm, yes. Why do you ask? ;) \nI forgot again that it is too late to edit the patch when send-email asks:\n> Send this email? ([y]es|[n]o|[q]uit|[a]ll): \nas it has read the patch from disk and keeps it in memory I assume?\n\nI just wrote the commit message as I would do, but offer you to claim authorship\nfor that perl stuff. So in case you'd want to reword that, I'd ask you to that.\nAlso asking for your signoff. (But apart from that I consider this patch final.)\n\nThanks,\nStefan\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex d356901..c45b22a 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -533,7 +533,7 @@ my %parse_alias = (\n \t\t\t$aliases{$alias} = \\@addr\n \t\t}}},\n \tmailrc => sub { my $fh = shift; while (<$fh>) {\n-\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n+\t\tif (/^alias\\s+(\\S+)\\s+(.*?)\\s*$/) {\n \t\t\t# spaces delimit multiple addresses\n \t\t\t$aliases{$1} = [ quotewords('\\s+', 0, $2) ];\n \t\t}}},\n"},{"id":"281099","messageId":"20160317235822.GA10612@sigill.intra.peff.net","threadId":"41733","inReplyTo":"1458252496-4118-1-git-send-email-sbeller@google.com","subject":"Re: [PATCH] send-email: ignore trailing whitespace in mailrc alias file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-03-17T23:58:22Z","receivedAt":"2016-03-17T23:58:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 17, 2016 at 03:08:16PM -0700, Stefan Beller wrote:\n\n> I just wrote the commit message as I would do, but offer you to claim\n> authorship for that perl stuff. So in case you'd want to reword that,\n> I'd ask you to that.  Also asking for your signoff. (But apart from\n> that I consider this patch final.)\n\nYeah, I am happy to take the credit/blame when somebody inevitably shows\na case where this does the wrong thing (I say inevitable because I\nassume that is the fate of all regexes -- to one day be proven to miss a\ncorner case).\n\nBut surely you know that my commit messages are more verbose than that.\n:)\n\nHere's what I would have written:\n\n-- >8 --\nSubject: [PATCH] send-email: ignore trailing whitespace in mailrc alias file\n\nThe regex for parsing mailrc considers everything after the\nsecond whitespace to be the email address, up to the end of\nthe line. We have to include whitespace there, because you\nmay have multiple space-separated addresses, each with their\nown internal quoting.\n\nBut if there is trailing whitespace, we include that, too.\nThis confuses quotewords() when we try to split the\nindividual addresses, and we end up storing \"undef\" in our\nalias list. Later parts of the code then access that,\ngenerating perl warnings.\n\nLet's tweak our regex to throw away any trailing whitespace\non each line.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n git-send-email.perl | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex d356901..c45b22a 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -533,7 +533,7 @@ my %parse_alias = (\n \t\t\t$aliases{$alias} = \\@addr\n \t\t}}},\n \tmailrc => sub { my $fh = shift; while (<$fh>) {\n-\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n+\t\tif (/^alias\\s+(\\S+)\\s+(.*?)\\s*$/) {\n \t\t\t# spaces delimit multiple addresses\n \t\t\t$aliases{$1} = [ quotewords('\\s+', 0, $2) ];\n \t\t}}},\n-- \n2.8.0.rc3.378.gf2f7872\n"}]}