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:
Nguyễn Thái Ngọc Duy
2010-12-15 22:02:47 +07:00
committed by Junio C Hamano
parent d38f28093e
commit f1a2ddbbc2
2 changed files with 32 additions and 0 deletions

View File

@ -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: