From: Junio C Hamano Date: Mon, 13 Dec 2010 18:10:12 GMT Subject: Re: [PATCH 12/19] tree_entry_interesting(): support wildcard matching Message-ID: <7vaak935ob.fsf@alter.siamese.dyndns.org> In-Reply-To: <1292233616-27692-13-git-send-email-pclouds@gmail.com> Nguyễn Thái Ngọc Duy writes: > Signed-off-by: Nguyễn Thái Ngọc Duy > --- > tree-walk.c | 33 ++++++++++++++++++++++++++++++--- > tree-walk.h | 2 +- > 2 files changed, 31 insertions(+), 4 deletions(-) ;-) Looks almost too easy. > diff --git a/tree-walk.c b/tree-walk.c > index d28de30..b5ad42b 100644 > --- a/tree-walk.c > +++ b/tree-walk.c > @@ -596,6 +598,31 @@ int tree_entry_interesting(const struct name_entry *entry, > &never_interesting)) > return 1; > } > + > +match_wildcards: > + /* > + * Concatenate base and entry->path into one and do > + * fnmatch() on it. > + */ > + > + if (!item->has_wildcard) > + continue; I think the comment comes after this if--continue. > + never_interesting = 0; When we have wildcard we would want to disable the never-interesting optimization, but I wonder if doing so only when we do not have exact hit is what we want. If a sick person had a path "a?b" tracked, and asked to match a pathspec "a?b", don't we still want to say "'a?b' of course matches, but 'a1b' ('1' comes earlier than '?' in the sort order) and 'aAb' ('A' comes later) also match"?