unpack-trees.c: use path_excluded() in check_ok_to_remove()
This function is responsible for determining if a path that is not tracked is ignored and allow "checkout" to overwrite it as needed. It used excluded() without checking if higher level directory in the path is ignored; correct it to use path_excluded() for this check. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * There are uses of lower-level interface excluded_from_list() in the codepath for narrow-checkout hack; they are supposed to be already checking each level as they descend, and are not touched with this patch.
This commit is contained in:
@ -1016,6 +1016,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
|||||||
o->el = ⪙
|
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));
|
memset(&o->result, 0, sizeof(o->result));
|
||||||
o->result.initialized = 1;
|
o->result.initialized = 1;
|
||||||
o->result.timestamp.sec = o->src_index->timestamp.sec;
|
o->result.timestamp.sec = o->src_index->timestamp.sec;
|
||||||
@ -1140,6 +1144,10 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
|||||||
|
|
||||||
done:
|
done:
|
||||||
free_excludes(&el);
|
free_excludes(&el);
|
||||||
|
if (o->path_exclude_check) {
|
||||||
|
path_exclude_check_clear(o->path_exclude_check);
|
||||||
|
free(o->path_exclude_check);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return_failed:
|
return_failed:
|
||||||
@ -1355,7 +1363,8 @@ static int check_ok_to_remove(const char *name, int len, int dtype,
|
|||||||
if (ignore_case && icase_exists(o, name, len, st))
|
if (ignore_case && icase_exists(o, name, len, st))
|
||||||
return 0;
|
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
|
* ce->name is explicitly excluded, so it is Ok to
|
||||||
* overwrite it.
|
* overwrite it.
|
||||||
|
@ -52,6 +52,7 @@ struct unpack_trees_options {
|
|||||||
const char *prefix;
|
const char *prefix;
|
||||||
int cache_bottom;
|
int cache_bottom;
|
||||||
struct dir_struct *dir;
|
struct dir_struct *dir;
|
||||||
|
struct path_exclude_check *path_exclude_check;
|
||||||
struct pathspec *pathspec;
|
struct pathspec *pathspec;
|
||||||
merge_fn_t fn;
|
merge_fn_t fn;
|
||||||
const char *msgs[NB_UNPACK_TREES_ERROR_TYPES];
|
const char *msgs[NB_UNPACK_TREES_ERROR_TYPES];
|
||||||
|
Reference in New Issue
Block a user