Re: Subject: [PATCH 2/3] Let git-add--interactive read colors from .gitconfig
- From
- Dan Zwell <dzwell@gmail.com>
- Date
- Nov 13, 2007, 02:55 UTC
- Message-ID
- <47391211.5000606@zwell.net>
- In-Reply-To
- <7v4pfq27tx.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
Show 9 quoted lines
> 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? >
I think we're talking about the same thing. I was referring to the split regular expression, and the question is, "for the current element of split(/\s+/, $str), does it match a color?"
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 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.
Dan