X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=archive.c;h=5b88507374f08e118a83fe7479766e078c5616ca;hb=85e2233f982f760d0e731b1258da2580834d8027;hp=55b273246e006ad55c51d3e5cb6bed3153ae8cf4;hpb=ff86bdd5cac70850eea4791bea78efa19b228ebe;p=git.git diff --git a/archive.c b/archive.c index 55b273246..5b8850737 100644 --- a/archive.c +++ b/archive.c @@ -211,10 +211,33 @@ static const struct archiver *lookup_archiver(const char *name) return NULL; } +static int reject_entry(const unsigned char *sha1, const char *base, + int baselen, const char *filename, unsigned mode, + int stage, void *context) +{ + return -1; +} + +static int path_exists(struct tree *tree, const char *path) +{ + const char *pathspec[] = { path, NULL }; + + if (read_tree_recursive(tree, "", 0, 0, pathspec, reject_entry, NULL)) + return 1; + return 0; +} + static void parse_pathspec_arg(const char **pathspec, struct archiver_args *ar_args) { - ar_args->pathspec = get_pathspec("", pathspec); + ar_args->pathspec = pathspec = get_pathspec("", pathspec); + if (pathspec) { + while (*pathspec) { + if (!path_exists(ar_args->tree, *pathspec)) + die("path not found: %s", *pathspec); + pathspec++; + } + } } static void parse_treeish_arg(const char **argv,