Merge branch 'jc/ls-files-i-dir'
"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:
@ -1023,6 +1023,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
||||
o->el = ⪙
|
||||
}
|
||||
|
||||
if (o->dir) {
|
||||
o->path_exclude_check = xmalloc(sizeof(struct path_exclude_check));
|
||||
path_exclude_check_init(o->path_exclude_check, o->dir);
|
||||
}
|
||||
memset(&o->result, 0, sizeof(o->result));
|
||||
o->result.initialized = 1;
|
||||
o->result.timestamp.sec = o->src_index->timestamp.sec;
|
||||
@ -1148,6 +1152,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
||||
|
||||
done:
|
||||
free_excludes(&el);
|
||||
if (o->path_exclude_check) {
|
||||
path_exclude_check_clear(o->path_exclude_check);
|
||||
free(o->path_exclude_check);
|
||||
}
|
||||
return ret;
|
||||
|
||||
return_failed:
|
||||
@ -1363,7 +1371,8 @@ static int check_ok_to_remove(const char *name, int len, int dtype,
|
||||
if (ignore_case && icase_exists(o, name, len, st))
|
||||
return 0;
|
||||
|
||||
if (o->dir && excluded(o->dir, name, &dtype))
|
||||
if (o->dir &&
|
||||
path_excluded(o->path_exclude_check, name, -1, &dtype))
|
||||
/*
|
||||
* ce->name is explicitly excluded, so it is Ok to
|
||||
* overwrite it.
|
||||
|
||||
Reference in New Issue
Block a user