tree_entry_interesting(): optimize wildcard matching when base is matched
If base is already matched, skip that part when calling fnmatch(). This happens quite often if users start a command from worktree's subdirectory and prefix is usually prepended to all pathspecs. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
d38f28093e
commit
f1a2ddbbc2
14
tree-walk.c
14
tree-walk.c
@ -595,6 +595,20 @@ int tree_entry_interesting(const struct name_entry *entry,
|
||||
match + baselen, matchlen - baselen,
|
||||
&never_interesting))
|
||||
return 1;
|
||||
|
||||
if (ps->items[i].has_wildcard) {
|
||||
if (!fnmatch(match + baselen, entry->path, 0))
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* Match all directories. We'll try to
|
||||
* match files later on.
|
||||
*/
|
||||
if (ps->recursive && S_ISDIR(entry->mode))
|
||||
return 1;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
match_wildcards:
|
||||
|
Reference in New Issue
Block a user