Merge branch 'jc/ls-files-i-dir' into maint
"git ls-files --exclude=t -i" did not consider anything under t/ as excluded, as it did not pay attention to exclusion of leading paths while walking the index. Other two users of excluded() are also updated. * jc/ls-files-i-dir: dir.c: make excluded() file scope static unpack-trees.c: use path_excluded() in check_ok_to_remove() builtin/add.c: use path_excluded() path_excluded(): update API to less cache-entry centric ls-files -i: micro-optimize path_excluded() ls-files -i: pay attention to exclusion of leading paths
This commit is contained in:
@ -443,6 +443,9 @@ 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_used_pathspec(pathspec);
|
||||
for (i = 0; pathspec[i]; i++) {
|
||||
@ -450,7 +453,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
|
||||
&& !file_exists(pathspec[i])) {
|
||||
if (ignore_missing) {
|
||||
int dtype = DT_UNKNOWN;
|
||||
if (excluded(&dir, pathspec[i], &dtype))
|
||||
if (path_excluded(&check, pathspec[i], -1, &dtype))
|
||||
dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
|
||||
} else
|
||||
die(_("pathspec '%s' did not match any files"),
|
||||
@ -458,6 +461,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
|
||||
}
|
||||
}
|
||||
free(seen);
|
||||
path_exclude_check_clear(&check);
|
||||
}
|
||||
|
||||
plug_bulk_checkin();
|
||||
|
@ -200,9 +200,19 @@ static void show_ru_info(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int ce_excluded(struct path_exclude_check *check, struct cache_entry *ce)
|
||||
{
|
||||
int dtype = ce_to_dtype(ce);
|
||||
return path_excluded(check, ce->name, ce_namelen(ce), &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) {
|
||||
@ -215,9 +225,8 @@ static void show_files(struct dir_struct *dir)
|
||||
if (show_cached | show_stage) {
|
||||
for (i = 0; i < active_nr; i++) {
|
||||
struct cache_entry *ce = active_cache[i];
|
||||
int dtype = ce_to_dtype(ce);
|
||||
if (dir->flags & DIR_SHOW_IGNORED &&
|
||||
!excluded(dir, ce->name, &dtype))
|
||||
if ((dir->flags & DIR_SHOW_IGNORED) &&
|
||||
!ce_excluded(&check, ce))
|
||||
continue;
|
||||
if (show_unmerged && !ce_stage(ce))
|
||||
continue;
|
||||
@ -232,9 +241,8 @@ static void show_files(struct dir_struct *dir)
|
||||
struct cache_entry *ce = active_cache[i];
|
||||
struct stat st;
|
||||
int err;
|
||||
int dtype = ce_to_dtype(ce);
|
||||
if (dir->flags & DIR_SHOW_IGNORED &&
|
||||
!excluded(dir, ce->name, &dtype))
|
||||
if ((dir->flags & DIR_SHOW_IGNORED) &&
|
||||
!ce_excluded(&check, ce))
|
||||
continue;
|
||||
if (ce->ce_flags & CE_UPDATE)
|
||||
continue;
|
||||
@ -247,6 +255,9 @@ 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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user