Re: [PATCH 02/18] Change style of some regular expressions to make them clearer
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 7, 2013, 04:51 UTC
- Message-ID
- <7v7gi6wmkm.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CAPig+cRyHc0SiWrHKQ3w4jCW5a-2p=k0TsjeRBe_kyw+DfnrqA@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 19 quoted lines
> On Thu, Jun 6, 2013 at 10:30 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Eric Sunshine <sunshine@sunshineco.com> writes:
>>
>>>> - if (my ($child, $parents) = $line =~ m/^-?([a-f0-9]+) ([a-f0-9 ]+)/) {
>>>> - foreach my $parent (split(' ', $parents)) {
>>>> + if (my ($child, $parents) = $line =~ /^-?([a-f0-9]+) ([a-f0-9 ]+)/) {
>>>> + foreach my $parent (split(/ /, $parents)) {
>>>
>>> This is a behavior-altering change. split(' ',...) is handled as a
>>> special case[*1*] which strips leading whitespace and then splits on
>>> /\s+/ (run of whitespace). Changing it to split(/ /,...) makes it
>>> match only a single space (rather than a run of whitespace).
>>
>> I initially had the same reaction, but this is reading the output of
>> the "rev-list --parents" command, whose fields are separated by one
>> SP each, so there is indeed no behaviour change.
>
> True. This potentially subtle point may deserve mention in the commit
> message (or this particular change can be dropped).I agree that the log message should mention it; but the resulting code is more correct than the original, so I do not see a need to drop it, or add any in-code comment to it.