summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-07-11 12:44:34 -0700
committerJunio C Hamano <gitster@pobox.com>2012-07-11 12:44:35 -0700
commitcd733f4f713d46bc175fd57fc9a168ea4f846148 (patch)
tree55214b405870898162163c45daecf651d14a826c /unpack-trees.c
parentfb60f344e441788040dbeec8f85ccd826ceaacd1 (diff)
parent0d316f0ceff1c416c25327f40bc5fbdded98a01a (diff)
downloadgit-cd733f4f713d46bc175fd57fc9a168ea4f846148.tar.gz
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
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index ad40109432..33a581924e 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1023,6 +1023,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
o->el = &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.