diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-05-06 10:50:06 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-05-06 10:50:06 -0700 |
commit | 1273738f05dedc63865085deb5d1fb8816ff809c (patch) | |
tree | b63d47e65064ac061ed300c01ab26129a31db678 /archive.c | |
parent | 9fdc1cc872308869d76665be55367eef48f05ff6 (diff) | |
parent | 33e0f62ba981ebfdcab8c9fb6d2935712a7b9d41 (diff) | |
download | git-1273738f05dedc63865085deb5d1fb8816ff809c.tar.gz |
Merge branch 'nd/struct-pathspec'
* nd/struct-pathspec:
pathspec: rename per-item field has_wildcard to use_wildcard
Improve tree_entry_interesting() handling code
Convert read_tree{,_recursive} to support struct pathspec
Reimplement read_tree_recursive() using tree_entry_interesting()
Diffstat (limited to 'archive.c')
-rw-r--r-- | archive.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -157,6 +157,7 @@ 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] == '/') { @@ -191,8 +192,10 @@ int write_archive_entries(struct archiver_args *args, git_attr_set_direction(GIT_ATTR_INDEX, &the_index); } - err = read_tree_recursive(args->tree, "", 0, 0, args->pathspec, + init_pathspec(&pathspec, args->pathspec); + err = read_tree_recursive(args->tree, "", 0, 0, &pathspec, write_archive_entry, &context); + free_pathspec(&pathspec); if (err == READ_TREE_RECURSIVE) err = 0; return err; @@ -221,11 +224,14 @@ static int reject_entry(const unsigned char *sha1, const char *base, 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; + const char *paths[] = { path, NULL }; + struct pathspec pathspec; + int ret; + + init_pathspec(&pathspec, paths); + ret = read_tree_recursive(tree, "", 0, 0, &pathspec, reject_entry, NULL); + free_pathspec(&pathspec); + return ret != 0; } static void parse_pathspec_arg(const char **pathspec, |