From: Junio C Hamano Date: Sat, 11 Feb 2012 23:43:34 GMT Subject: Re: [PATCHv2 1/4] refs: add common refname_match_patterns() Message-ID: <7vzkcpkkbd.fsf@alter.siamese.dyndns.org> In-Reply-To: <20120211193742.GD4903@tgrennan-laptop> Tom Grennan writes: > Yes, I should have stated that this emphasized containment over > efficiency. If instead we stipulate that the caller must list exclusion > patterns before others, this could simply be: No. You have to pre-parse and rearrange the pattern[] list *only once* before matching them against dozens of refs, so instead of forcing the callers do anything funky, you give a function that gets a pattern[] list and returns something that can be efficiently used by the match_pattern() function, and have the caller pass that thing, not the original pattern[] list, to the match_pattern() function. That is how pathspec matching side of the logic is arranged. I keep saying that it is probably not a good idea to directly reuse the pathspec code, but you would want to study and learn from the overall structure of it.