checkout: convert read_tree_some to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jul 14, 2013 at 15:35 UTC
18e4f4059936dd35dfe929f502101ca371af856c
3 files changed
+6
-9
builtin/checkout.c
+3
-6
@@ -83,12 +83,9 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
83
return 0;
84
}
85
86
-static int read_tree_some(struct tree *tree, const char **pathspec)
86
+static int read_tree_some(struct tree *tree, const struct pathspec *pathspec)
87
{
88
- struct pathspec ps;
89
- init_pathspec(&ps, pathspec);
90
- read_tree_recursive(tree, "", 0, 0, &ps, update_some, NULL);
91
- free_pathspec(&ps);
88
+ read_tree_recursive(tree, "", 0, 0, pathspec, update_some, NULL);
89
90
/* update the index with the given tree's info
91
* for all args, expanding wildcards, and exit
@@ -266,7 +263,7 @@ static int checkout_paths(const struct checkout_opts *opts,
263
return error(_("corrupt index file"));
264
265
if (opts->source_tree)
269
- read_tree_some(opts->source_tree, opts->pathspec.raw);
266
+ read_tree_some(opts->source_tree, &opts->pathspec);
267
268
ps_matched = xcalloc(1, opts->pathspec.nr);
269
tree.c
+2
-2
@@ -47,7 +47,7 @@ static int read_one_entry_quick(const unsigned char *sha1, const char *base, int
47
}
48
49
static int read_tree_1(struct tree *tree, struct strbuf *base,
50
- int stage, struct pathspec *pathspec,
50
+ int stage, const struct pathspec *pathspec,
51
read_tree_fn_t fn, void *context)
52
{
53
struct tree_desc desc;
@@ -116,7 +116,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
116
117
int read_tree_recursive(struct tree *tree,
118
const char *base, int baselen,
119
- int stage, struct pathspec *pathspec,
119
+ int stage, const struct pathspec *pathspec,
120
read_tree_fn_t fn, void *context)
121
{
122
struct strbuf sb = STRBUF_INIT;
tree.h
+1
-1
@@ -25,7 +25,7 @@ typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const ch
25
26
extern int read_tree_recursive(struct tree *tree,
27
const char *base, int baselen,
28
- int stage, struct pathspec *pathspec,
28
+ int stage, const struct pathspec *pathspec,
29
read_tree_fn_t fn, void *context);
30
31
extern int read_tree(struct tree *tree, int stage, struct pathspec *pathspec);