aboutsummaryrefslogtreecommitdiff
path: root/builtin-ls-files.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-01-31 20:23:25 -0800
committerJunio C Hamano <gitster@pobox.com>2008-02-05 00:46:49 -0800
commit6831a88ac03759a8133f10ffd52ad235a081a8a3 (patch)
tree1f9dcec12142df59bcaff2200349fbef78ee4100 /builtin-ls-files.c
parentd6b8fc303b389b026f2bf9918f6f83041488989b (diff)
downloadgit-6831a88ac03759a8133f10ffd52ad235a081a8a3.tar.gz
git-6831a88ac03759a8133f10ffd52ad235a081a8a3.tar.xz
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>
Diffstat (limited to 'builtin-ls-files.c')
-rw-r--r--builtin-ls-files.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index dbba371b8..54cb2518d 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -238,8 +238,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
if (show_cached | show_stage) {
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
- if (excluded(dir, ce->name, ce_to_dtype(ce)) !=
- dir->show_ignored)
+ int dtype = ce_to_dtype(ce);
+ if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
continue;
if (show_unmerged && !ce_stage(ce))
continue;
@@ -253,8 +253,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
struct cache_entry *ce = active_cache[i];
struct stat st;
int err;
- if (excluded(dir, ce->name, ce_to_dtype(ce)) !=
- dir->show_ignored)
+ int dtype = ce_to_dtype(ce);
+ if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
continue;
err = lstat(ce->name, &st);
if (show_deleted && err)