gitignore: lazily find dtype
When we process "foo/" entries in gitignore files on a system that does not have d_type member in "struct dirent", the earlier implementation ran lstat(2) separately when matching with entries that came from the command line, in-tree .gitignore files, and $GIT_DIR/info/excludes file. This optimizes it by delaying the lstat(2) call until it becomes absolutely necessary. The initial idea for this change was by Jeff King, but I optimized it further to pass pointers to around. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -522,8 +522,9 @@ static void verify_absent(struct cache_entry *ce, const char *action,
|
||||
|
||||
if (!lstat(ce->name, &st)) {
|
||||
int cnt;
|
||||
int dtype = ce_to_dtype(ce);
|
||||
|
||||
if (o->dir && excluded(o->dir, ce->name, ce_to_dtype(ce)))
|
||||
if (o->dir && excluded(o->dir, ce->name, &dtype))
|
||||
/*
|
||||
* ce->name is explicitly excluded, so it is Ok to
|
||||
* overwrite it.
|
||||
|
Reference in New Issue
Block a user