Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- archive.c | 16 ++++++++++------ archive.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/archive.c b/archive.c index 93e00bb..f1a28c9 100644 --- a/archive.c +++ b/archive.c @@ -151,7 +151,6 @@ int write_archive_entries(struct archiver_args *args, struct archiver_context context; struct unpack_trees_options opts; struct tree_desc t; - struct pathspec pathspec; int err; if (args->baselen > 0 && args->base[args->baselen - 1] == '/') { @@ -186,10 +185,8 @@ int write_archive_entries(struct archiver_args *args, git_attr_set_direction(GIT_ATTR_INDEX, &the_index); } - init_pathspec(&pathspec, args->pathspec); - err = read_tree_recursive(args->tree, "", 0, 0, &pathspec, + err = read_tree_recursive(args->tree, "", 0, 0, &args->pathspec, write_archive_entry, &context); - free_pathspec(&pathspec); if (err == READ_TREE_RECURSIVE) err = 0; return err; @@ -231,8 +228,15 @@ static int path_exists(struct tree *tree, const char *path) static void parse_pathspec_arg(const char **pathspec, struct archiver_args *ar_args) { - ar_args->pathspec = pathspec = get_pathspec("", pathspec); - if (pathspec) { + /* + * raw[] is used to check for unused pathspec. This is + * tree_entry_interesting's limitation because it does not + * mark "used" pathspec. The magic mask cannot be lifted until + * it does. + */ + parse_pathspec(&ar_args->pathspec, PATHSPEC_FROMTOP, 0, "", pathspec); + if (ar_args->pathspec.nr) { + pathspec = ar_args->pathspec.raw; while (*pathspec) { if (!path_exists(ar_args->tree, *pathspec)) die("path not found: %s", *pathspec); diff --git a/archive.h b/archive.h index 895afcd..a98c49e 100644 --- a/archive.h +++ b/archive.h @@ -8,7 +8,7 @@ struct archiver_args { const unsigned char *commit_sha1; const struct commit *commit; time_t time; - const char **pathspec; + struct pathspec pathspec; unsigned int verbose : 1; unsigned int worktree_attributes : 1; unsigned int convert : 1; -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html