aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-02-10 12:52:39 -0800
committerJunio C Hamano <gitster@pobox.com>2010-02-10 12:52:39 -0800
commitc6eba1d5b2fdabda46158a01a80bea2a01ef6016 (patch)
treec84372b7e1b5e8846d02292177d053cd0f634e2c
parent8ff883029a97b38b893b15199393d0e4e7190c0d (diff)
parentd5f53d6d6f20bbd1ec5507824eb213463554b36a (diff)
downloadgit-c6eba1d5b2fdabda46158a01a80bea2a01ef6016.tar.gz
git-c6eba1d5b2fdabda46158a01a80bea2a01ef6016.tar.xz
Merge branch 'rs/maint-archive-match-pathspec' into maint
* rs/maint-archive-match-pathspec: archive: complain about path specs that don't match anything
-rw-r--r--archive.c25
1 files changed, 24 insertions, 1 deletions
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,