Re: Subject: [PATCH 2/3] Let git-add--interactive read colors from .gitconfig
- From
Jeff King <peff@peff.net>
- Date
- Nov 13, 2007, 07:26 UTC
- Message-ID
- <20071113072629.GA21769@sigill.intra.peff.net>
- In-Reply-To
- <47391211.5000606@zwell.net>
On Mon, Nov 12, 2007 at 08:55:13PM -0600, Dan Zwell wrote:
> Anyway, I preferred the regex version for readability, though I should have > used the /x modifier--it would still take two lines, but it would not need
Your regex is wrong, because it doesn't anchor at the beginning and end of the string (so /red/ will match "supercaliredfragilistic", which is probably not what you want). So you probably want /^red$/, which is equivalent to using 'eq' with 'red'. Or, as Junio noted, you are overall trying to say "is element $word in this list"; the canonical perl way of doing that is to make the list a hash for quick lookup.
> to attempt two matches. As for misconfigured color configurations, should we > catch that? I wrote this with the intent that it should ignore invalid color > names, but it would probably be more useful to print a warning.
Your patch doesn't just ignore; sometimes it accidentally matches invalid input (the example above is obviously silly, but consider what accidentally omitting the space in "blinkblack" would do).
-Peff