summaryrefslogtreecommitdiff
path: root/builtin-ls-files.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-01-31 09:17:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-02-05 08:46:49 (GMT)
commitd6b8fc303b389b026f2bf9918f6f83041488989b (patch)
treed5ae26059837dac6e778e74fccf7b1fdf01eccd0 /builtin-ls-files.c
parent7a2078b4b00fb1c5d7b0bf8155778f79377b8f2f (diff)
downloadgit-d6b8fc303b389b026f2bf9918f6f83041488989b.zip
git-d6b8fc303b389b026f2bf9918f6f83041488989b.tar.gz
git-d6b8fc303b389b026f2bf9918f6f83041488989b.tar.bz2
gitignore(5): Allow "foo/" in ignore list to match directory "foo"
A pattern "foo/" in the exclude list did not match directory "foo", but a pattern "foo" did. This attempts to extend the exclude mechanism so that it would while not matching a regular file or a symbolic link "foo". In order to differentiate a directory and non directory, this passes down the type of path being checked to excluded() function. A downside is that the recursive directory walk may need to run lstat(2) more often on systems whose "struct dirent" do not give the type of the entry; earlier it did not have to do so for an excluded path, but we now need to figure out if a path is a directory before deciding to exclude it. This is especially bad because an idea similar to the earlier CE_UPTODATE optimization to reduce number of lstat(2) calls would by definition not apply to the codepaths involved, as (1) directories will not be registered in the index, and (2) excluded paths will not be in the index anyway. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-ls-files.c')
-rw-r--r--builtin-ls-files.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 0f0ab2d..dbba371 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -238,7 +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) != dir->show_ignored)
+ if (excluded(dir, ce->name, ce_to_dtype(ce)) !=
+ dir->show_ignored)
continue;
if (show_unmerged && !ce_stage(ce))
continue;
@@ -252,7 +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) != dir->show_ignored)
+ if (excluded(dir, ce->name, ce_to_dtype(ce)) !=
+ dir->show_ignored)
continue;
err = lstat(ce->name, &st);
if (show_deleted && err)