Re: Subject: [PATCH 2/3] Let git-add--interactive read colors from .gitconfig

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dan Zwell <dzwell@xxxxxxxxx> writes:

> Junio C Hamano wrote:
>>> +			$fg_done = "true";
>>> +		}
>>> +		elsif ($word =~ /black|red|green|yellow/ ||
>>> +			   $word =~ /blue|magenta|cyan|white/) {
>>
>> 	exists $color_name{$word}
>>
>> with
>>
>> 	my %color_name = map { $_ => 1 } qw(black red ... white);
>>
>> at the beginning?
>>
> I don't see the advantage of doing it that way. After all, we're
> pattern matching. Does using a hash, an array, and a call to map()
> gain us something? I think a regular expression is clearer. Of course,
> as Jeff pointed out, I should have used a whitespace-agnostic regular
> expression.

I suggested the hash approach only because (1) it is easier to
read than two regexp matches that are split only to keep the
line less than 80-chars long, and (2) a misconfiguration like
"color.foo = fred" can be caught more easily.

I do not quite understand the "after all, we're pattern
matching" part, though.  Are you talking about "split(/\s+/, $str)" 
your for-loop iterates over?




-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux