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

Re: [PATCH v2] git-svn: trim leading and trailing whitespaces in author name

From
Tobias Klauser <tklauser@distanz.ch>
Date
Sep 13, 2019, 07:47 UTC
Message-ID
<20190913074700.hwmyalfmn66kkgbs@distanz.ch>
In-Reply-To
<CAPig+cTAY=4cuDyrsPiDH+MUvz4+H4eMKAsmTAETep2On5=q3g@mail.gmail.com>
Thank you for the review Eric!
On 2019-09-12 at 20:20:11 +0200, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 15 quoted lines
> On Thu, Sep 12, 2019 at 10:56 AM Tobias Klauser <tklauser@distanz.ch> wrote:
> > v2:
> >  - move whitespace trimming below defined'ness check as per Eric Sunshine's
> >    review comment
> > diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
> > @@ -1494,6 +1494,7 @@ sub check_author {
> >         if (!defined $author || length $author == 0) {
> >                 $author = '(no author)';
> >         }
> > +       $author =~ s/^\s+|\s+$//g;
> 
> Hmm, this still looks questionable. I would have expected the
> whitespace trimming to be below the 'defined' check but before the
> length($author)==0 check (since the length might become 0 once
> whitespace is trimmed).
Agree, I didn't consider this case. Will change in v3.
Show 10 quoted lines
> Also, a minor style/comprehension nit: Perhaps I'm just old-school,
> but for me, the idiom:
> 
>     $author =~ s/^\s+//;
>     $author =~ s/\s+$//;
> 
> is easier to understand at-a-glance as trimming leading and trailing
> whitespace than the more compact (noisy) expression this patch uses.
> But that's just a subjective review comment, not necessarily
> actionable.

Agree, the form you propose is more readable and saving just a line doesn't seem worth the possible impact on comprehension/readability. Will change in v3.

Previous: Eric Sunshine
Message 3 of 3 in “git-svn: trim leading and trailing whitespaces in author name”
  1. git-svn: trim leading and trailing whitespaces in author nameTobias Klauser, Sep 12, 2019
  2. Eric SunshineSep 12, 2019
  3. Tobias KlauserSep 13, 2019

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.