git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-send-email: fix get_maintainer.pl regression

From
Alex Bennée <alex.bennee@linaro.org>
Date
Nov 21, 2017, 20:46 UTC
Message-ID
<87wp2jwe9o.fsf@linaro.org>
In-Reply-To
<CAPig+cTXq6jSN9f2_xyj=Jfv_cg2kUFUtA5uVkZDrRRSi2x7vg@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 28 quoted lines
> A few more comments/observations...
>
> On Thu, Nov 16, 2017 at 10:48 AM, Alex Bennée <alex.bennee@linaro.org> wrote:
>> diff --git a/perl/Git.pm b/perl/Git.pm
>> @@ -936,6 +936,9 @@ sub parse_mailboxes {
>>                         $end_of_addr_seen = 0;
>>                 } elsif ($token =~ /^\(/) {
>>                         push @comment, $token;
>> +               } elsif ($token =~ /^\)/) {
>> +                       my $nested_comment = pop @comment;
>> +                       push @comment, "$nested_comment$token";
>
> Due to the way tokenization works, it looks like you will only ever
> see a ")" as a single character. That suggests that you should be
> using ($token eq ")"), as is done for "<" and ">", rather than ($token
> =~ /^\)/).
>
> What happens if there is text before the final closing ')'? For
> instance, "foo@bar (bibble (bobble) smoo)" or "...)smoo)". The result
> is that "smoo" ends up tacked onto the end of the email address
> ("foo@barsmoo") rather than incorporated into the comment, as
> intended.
>
> What happens if you encounter a ")" but haven't yet encountered an
> opening "(" (that is, @comment is empty)? For example, "foo@bar )". In
> that case, it unconditionally pops from the empty array, which seems
> iffy at best. It might be nice to see this case taken into
> consideration explicitly.

Yeah I was only really aiming for the current regression but I'm sure it could be more solid. I do note that my @known_failure_list in test.pl has a bunch of other cases that need fixing up.

> I also was wondering if it would make more sense to take advantage of
> Perl's ability to match nested expressions (??{$nested}), however,
> that feature apparently was added in 5.10, and Git.pm only requires
> 5.8, so perhaps not (unless we want to bump the requirement higher).

Hmm that might be a case of abusing regex to do something better suited to a proper tokenizer.

Show 11 quoted lines
>
> Aside from those observations, it looks like the tokenizer in this
> function is broken. For any input with the address enclosed in "<" and
> ">", the comment is lost entirely; it doesn't even end up in the
> @tokens array. Since you're already fixing bugs/regressions in this
> code, perhaps that's something you'd like to tackle as well in a
> separate patch? ("No" is an acceptable answer, of course.)
>
>>                 } elsif ($token eq "<") {
>>                         push @phrase, (splice @address), (splice @buffer);
>>                 } elsif ($token eq ">") {

I can have a go but my perl-fu has weakened somewhat since I stopped having to maintain perl code for a living. It's almost as though my brain was glad to dump the knowledge ;-)

I guess we could maintain a nesting count and a current token type and use that to more intelligently direct the nested portions to the appropriate bits. Maybe Matthieu or Remi (CC'ed) might want to chime in on other options?

-- Alex Bennée

Previous: Eric SunshineNext: Thomas Adam
Message 11 of 27 in “git-send-email: fix get_maintainer.pl regression”
  1. git-send-email: fix get_maintainer.pl regressionAlex Bennée, Nov 16, 2017
  2. Alex BennéeNov 16, 2017
  3. Eric SunshineNov 19, 2017
  4. Alex BennéeNov 20, 2017
  5. Eric SunshineNov 20, 2017
  6. Eric SunshineNov 20, 2017
  7. Philip OakleyNov 21, 2017
  8. Eric SunshineNov 21, 2017
  9. Junio C HamanoNov 21, 2017
  10. Eric SunshineNov 20, 2017
  11. Alex BennéeNov 21, 2017
  12. Thomas AdamNov 21, 2017
  13. Junio C HamanoNov 22, 2017
  14. Alex BennéeDec 11, 2017
  15. Thomas AdamDec 11, 2017
  16. Ævar Arnfjörð BjarmasonDec 11, 2017
  17. Thomas AdamDec 12, 2017
  18. Ævar Arnfjörð BjarmasonDec 12, 2017
  19. Alex BennéeDec 12, 2017
  20. Ævar Arnfjörð BjarmasonDec 12, 2017
  21. Junio C HamanoDec 12, 2017
  22. Ævar Arnfjörð BjarmasonDec 12, 2017
  23. Junio C HamanoDec 12, 2017
  24. Matthieu MoyNov 22, 2017
  25. Alex BennéeNov 22, 2017
  26. Thomas AdamNov 22, 2017
  27. Junio C HamanoNov 22, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.