unpack-trees: allow pruning with pathspec

Use the pathspec pruning of traverse_trees() from unpack_trees(). Again,
the unpack_trees() machinery is primarily meant for merging two (or more)
trees, and because a merge is a full tree operation, it didn't support any
pruning with pathspec, and this codepath probably should not be enabled
while running a merge, but the caller in diff-lib.c::diff_cache() should
be able to take advantage of it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2011-08-29 12:31:06 -07:00
parent 2842c0f914
commit 40e372563c
2 changed files with 3 additions and 0 deletions

View File

@ -444,6 +444,7 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
newinfo = *info; newinfo = *info;
newinfo.prev = info; newinfo.prev = info;
newinfo.pathspec = info->pathspec;
newinfo.name = *p; newinfo.name = *p;
newinfo.pathlen += tree_entry_len(p->path, p->sha1) + 1; newinfo.pathlen += tree_entry_len(p->path, p->sha1) + 1;
newinfo.conflicts |= df_conflicts; newinfo.conflicts |= df_conflicts;
@ -1040,6 +1041,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
info.fn = unpack_callback; info.fn = unpack_callback;
info.data = o; info.data = o;
info.show_all_errors = o->show_all_errors; info.show_all_errors = o->show_all_errors;
info.pathspec = o->pathspec;
if (o->prefix) { if (o->prefix) {
/* /*

View File

@ -51,6 +51,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 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];
/* /*