Re: [PATCH 2/4] pathspec: do exact comparison on the leading non-wildcard part
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Nov 20, 2012, 13:09 UTC
- Message-ID
- <CACsJy8DqTR12sckwMm_Zzv2UbdX6jvvyFm3Fx9-b8a-NVXWL9g@mail.gmail.com>
- In-Reply-To
- <7vzk2duw3m.fsf@alter.siamese.dyndns.org>
On Tue, Nov 20, 2012 at 3:54 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 8 quoted lines
> 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