From 6831a88ac03759a8133f10ffd52ad235a081a8a3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 31 Jan 2008 20:23:25 -0800 Subject: 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 --- unpack-trees.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'unpack-trees.c') diff --git a/unpack-trees.c b/unpack-trees.c index 11af2636c..29848e926 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -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. -- cgit v1.2.1