summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-04-23 11:21:23 -0700
committerJunio C Hamano <gitster@pobox.com>2013-04-23 11:21:23 -0700
commit7093d2c0dd986c70a98b712440b34f98599b3539 (patch)
treed4c22d38c71d388dce709fc36d6318ca873f9570 /builtin
parent9e94f9ba9e902d48c75df6ba53e6e87cefe187a8 (diff)
parent0aaf62b6e018484bad9cea47dc00644d57b7ad49 (diff)
downloadgit-7093d2c0dd986c70a98b712440b34f98599b3539.tar.gz
Merge branch 'kb/status-ignored-optim-2'
Fixes a handful of issues in the code to traverse working tree to find untracked and/or ignored files, cleans up and optimizes the codepath in general. * kb/status-ignored-optim-2: dir.c: git-status --ignored: don't scan the work tree twice dir.c: git-status --ignored: don't scan the work tree three times dir.c: git-status: avoid is_excluded checks for tracked files dir.c: replace is_path_excluded with now equivalent is_excluded API dir.c: unify is_excluded and is_path_excluded APIs dir.c: move prep_exclude dir.c: factor out parts of last_exclude_matching for later reuse dir.c: git-clean -d -X: don't delete tracked directories dir.c: make 'git-status --ignored' work within leading directories dir.c: git-status --ignored: don't list empty directories as ignored dir.c: git-ls-files --directories: don't hide empty directories dir.c: git-status --ignored: don't list empty ignored directories dir.c: git-status --ignored: don't list files in ignored directories dir.c: git-status --ignored: don't drop ignored directories
Diffstat (limited to 'builtin')
-rw-r--r--builtin/add.c5
-rw-r--r--builtin/check-ignore.c7
-rw-r--r--builtin/ls-files.c15
3 files changed, 6 insertions, 21 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 54cd2d417d..d4b40f2b7a 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -545,9 +545,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (pathspec) {
int i;
- struct path_exclude_check check;
- path_exclude_check_init(&check, &dir);
if (!seen)
seen = find_pathspecs_matching_against_index(pathspec);
for (i = 0; pathspec[i]; i++) {
@@ -555,7 +553,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
&& !file_exists(pathspec[i])) {
if (ignore_missing) {
int dtype = DT_UNKNOWN;
- if (is_path_excluded(&check, pathspec[i], -1, &dtype))
+ if (is_excluded(&dir, pathspec[i], &dtype))
dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
} else
die(_("pathspec '%s' did not match any files"),
@@ -563,7 +561,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
}
}
free(seen);
- path_exclude_check_clear(&check);
}
plug_bulk_checkin();
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 0240f99b57..854a88a056 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -59,7 +59,6 @@ static int check_ignore(const char *prefix, const char **pathspec)
const char *path, *full_path;
char *seen;
int num_ignored = 0, dtype = DT_UNKNOWN, i;
- struct path_exclude_check check;
struct exclude *exclude;
/* read_cache() is only necessary so we can watch out for submodules. */
@@ -67,7 +66,6 @@ static int check_ignore(const char *prefix, const char **pathspec)
die(_("index file corrupt"));
memset(&dir, 0, sizeof(dir));
- dir.flags |= DIR_COLLECT_IGNORED;
setup_standard_excludes(&dir);
if (!pathspec || !*pathspec) {
@@ -76,7 +74,6 @@ static int check_ignore(const char *prefix, const char **pathspec)
return 0;
}
- path_exclude_check_init(&check, &dir);
/*
* look for pathspecs matching entries in the index, since these
* should not be ignored, in order to be consistent with
@@ -90,8 +87,7 @@ static int check_ignore(const char *prefix, const char **pathspec)
full_path = check_path_for_gitlink(full_path);
die_if_path_beyond_symlink(full_path, prefix);
if (!seen[i]) {
- exclude = last_exclude_matching_path(&check, full_path,
- -1, &dtype);
+ exclude = last_exclude_matching(&dir, full_path, &dtype);
if (exclude) {
if (!quiet)
output_exclude(path, exclude);
@@ -101,7 +97,6 @@ static int check_ignore(const char *prefix, const char **pathspec)
}
free(seen);
clear_directory(&dir);
- path_exclude_check_clear(&check);
return num_ignored;
}
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 175e6e3e72..22020729cb 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -201,19 +201,15 @@ static void show_ru_info(void)
}
}
-static int ce_excluded(struct path_exclude_check *check, struct cache_entry *ce)
+static int ce_excluded(struct dir_struct *dir, struct cache_entry *ce)
{
int dtype = ce_to_dtype(ce);
- return is_path_excluded(check, ce->name, ce_namelen(ce), &dtype);
+ return is_excluded(dir, ce->name, &dtype);
}
static void show_files(struct dir_struct *dir)
{
int i;
- struct path_exclude_check check;
-
- if ((dir->flags & DIR_SHOW_IGNORED))
- path_exclude_check_init(&check, dir);
/* For cached/deleted files we don't need to even do the readdir */
if (show_others || show_killed) {
@@ -227,7 +223,7 @@ static void show_files(struct dir_struct *dir)
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
if ((dir->flags & DIR_SHOW_IGNORED) &&
- !ce_excluded(&check, ce))
+ !ce_excluded(dir, ce))
continue;
if (show_unmerged && !ce_stage(ce))
continue;
@@ -243,7 +239,7 @@ static void show_files(struct dir_struct *dir)
struct stat st;
int err;
if ((dir->flags & DIR_SHOW_IGNORED) &&
- !ce_excluded(&check, ce))
+ !ce_excluded(dir, ce))
continue;
if (ce->ce_flags & CE_UPDATE)
continue;
@@ -256,9 +252,6 @@ static void show_files(struct dir_struct *dir)
show_ce_entry(tag_modified, ce);
}
}
-
- if ((dir->flags & DIR_SHOW_IGNORED))
- path_exclude_check_clear(&check);
}
/*