From: Nguyen Thai Ngoc Duy Date: Tue, 20 Nov 2012 13:09:50 GMT Subject: Re: [PATCH 2/4] pathspec: do exact comparison on the leading non-wildcard part Message-ID: In-Reply-To: <7vzk2duw3m.fsf@alter.siamese.dyndns.org> On Tue, Nov 20, 2012 at 3:54 AM, Junio C Hamano wrote: > How would we protect this optimization from future breakages? > > Once we start using FNM_PERIOD, this becomes unsafe, as the simple > part in "foo/bar*baz" would be "foo/bar" with remainder "*baz". > > The pattern "foo/bar*baz" should match "foo/bar.baz" with FNM_PERIOD > set. But with this optimization, fnmatch is fed pattern="*baz", > string=".baz" and they would not match. The first question is how FNM_PERIOD comes in the first place without breaking the current syntax. I guess we just turn off the optimization if FNM_PERIOD is used. My secret "plan" is to convert all fnmatch() calls to git_fnmatch() then replace fnmatch() with wildmatch() and move these optimization down to wildmatch(). I think we can handle FNM_PERIOD case better down there because string is still "foo/bar.baz". -- Duy