git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Allen Hubbe <allenbh@gmail.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
Date: Tue, 26 May 2015 16:53:14 -0400	[thread overview]
Message-ID: <CAPig+cQoUrAhpvyrBTFyDDjaZt8brkhhw3aehC-hNeS7gND6jw@mail.gmail.com> (raw)
In-Reply-To: <CAJ80sasp6kNgbJJw-2TzZnPPDVgYdAwwsdh=hNH4xxu1TBtiyA@mail.gmail.com>

On Tue, May 26, 2015 at 3:41 PM, Allen Hubbe <allenbh@gmail.com> wrote:
> On Tue, May 26, 2015 at 3:10 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Saturday, May 23, 2015, Allen Hubbe <allenbh@gmail.com> wrote:
>>> diff --git a/git-send-email.perl b/git-send-email.perl
>>> index e1e9b1460ced..ffea50094a48 100755
>>> --- a/git-send-email.perl
>>> +++ b/git-send-email.perl
>>> @@ -516,6 +518,33 @@ my %parse_alias = (
>>>                           }
>>>                       } },
>>>
>>> +       sendmail => sub { my $fh = shift; while (<$fh>) {
>>> +               # ignore comment lines
>>> +               if (/^\s*(?:#.*)?$/) { }
>>
>> This confused me at first because the comment talks only about
>> "comment lines", for which a simpler /^\s*#/ would suffice. The regex,
>> however, actually matches blank lines and comment lines (both of which
>> get skipped). Either the comment should be fixed or the regex could be
>> split into two much simpler ones. The splitting into simpler regex's
>> has the benefit of being easier to comprehend at a glance. For
>> instance:
>>
>>     next if /^\s*$/;
>>     next if /^\s*#/;
>
> I noticed this too after sending the patch, and I have already changed
> the comment to mention blank lines or comment lines.
>
> Splitting the regex would be more simple, but the regex is already
> quite simple as it is.

To be clear, the reason that I brought up the idea of splitting the
regex was that /^\s*$/ and /^\s*#/ are very common idioms which people
can and do recognize and understand at-a-glance without having to
spend time deciphering them. On the other hand, /^\s*(?:#.*)?$/
doesn't lend itself to that sort of instant comprehension; it requires
a certain amount of mental effort to understand.

Anyhow, it's just an idea put forth in case you or someone favors it;
not an outright request for a change.

>>> +               # recognize lines that look like an alias
>>> +               elsif (/^(\S+)\s*:\s*(.+?)$/) {
>>
>> Observation: Given "foo:bar:baz", this regex will take "foo:bar" as
>> the key, and "baz" as the value, which is probably not what was
>> intended, however, it likely doesn't matter much in this case since
>> colon isn't legal in an email address[1].
>
> That's a keen observation.  I think it would work simply to use a
> non-greedy +? in the first capture group.

Yes, that would work. Alternately: /^([^\s:]+)\s*:\s*(.+?)$/

  reply	other threads:[~2015-05-26 20:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-23 13:21 [PATCH v5 1/1] send-email: Add sendmail email aliases format Allen Hubbe
2015-05-23 17:45 ` Junio C Hamano
2015-05-23 18:00   ` Junio C Hamano
2015-05-23 23:01     ` Allen Hubbe
2015-05-23 18:07   ` Junio C Hamano
2015-05-23 22:24     ` Allen Hubbe
2015-05-25 12:47       ` Allen Hubbe
2015-05-25 16:32         ` Junio C Hamano
2015-05-25 21:12           ` Junio C Hamano
2015-05-25 21:35             ` Junio C Hamano
2015-05-26  1:51               ` Allen Hubbe
2015-05-26  1:58                 ` Junio C Hamano
2015-05-26  2:16                   ` Allen Hubbe
2015-05-26  2:55                     ` Junio C Hamano
2015-05-26  3:34                       ` Junio C Hamano
2015-05-26 18:47   ` Eric Sunshine
2015-05-26 19:10 ` Eric Sunshine
2015-05-26 19:41   ` Allen Hubbe
2015-05-26 20:53     ` Eric Sunshine [this message]
2015-05-26 21:04       ` Allen Hubbe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPig+cQoUrAhpvyrBTFyDDjaZt8brkhhw3aehC-hNeS7gND6jw@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=allenbh@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).