aboutsummaryrefslogtreecommitdiff
path: root/tree.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-03-25 16:34:19 +0700
committerJunio C Hamano <gitster@pobox.com>2011-03-25 09:20:33 -0700
commitf0096c06bcdeb7aa6ae8a749ddc9d6d4a2c381d1 (patch)
treeb5b28251c9e48186b9e6168cbfefe4ace0f57602 /tree.c
parentffd31f661d5c5dddc091750ca86cfaa5d9d04b38 (diff)
downloadgit-f0096c06bcdeb7aa6ae8a749ddc9d6d4a2c381d1.tar.gz
git-f0096c06bcdeb7aa6ae8a749ddc9d6d4a2c381d1.tar.xz
Convert read_tree{,_recursive} to support struct pathspec
This patch changes behavior of the two functions. Previously it does prefix matching only. Now it can also do wildcard matching. All callers are updated. Some gain wildcard matching (archive, checkout), others reset pathspec_item.has_wildcard to retain old behavior (ls-files, ls-tree as they are plumbing). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/tree.c b/tree.c
index db3a5c331..698ecf7af 100644
--- a/tree.c
+++ b/tree.c
@@ -114,20 +114,15 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
int read_tree_recursive(struct tree *tree,
const char *base, int baselen,
- int stage, const char **match,
+ int stage, struct pathspec *pathspec,
read_tree_fn_t fn, void *context)
{
struct strbuf sb = STRBUF_INIT;
- struct pathspec pathspec;
- int i, ret;
+ int ret;
- init_pathspec(&pathspec, match);
- for (i = 0; i < pathspec.nr; i++)
- pathspec.items[i].has_wildcard = 0;
strbuf_add(&sb, base, baselen);
- ret = read_tree_1(tree, &sb, stage, &pathspec, fn, context);
+ ret = read_tree_1(tree, &sb, stage, pathspec, fn, context);
strbuf_release(&sb);
- free_pathspec(&pathspec);
return ret;
}
@@ -141,7 +136,7 @@ static int cmp_cache_name_compare(const void *a_, const void *b_)
ce2->name, ce2->ce_flags);
}
-int read_tree(struct tree *tree, int stage, const char **match)
+int read_tree(struct tree *tree, int stage, struct pathspec *match)
{
read_tree_fn_t fn = NULL;
int i, err;