Skip to content

Commit 18e4f40

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent 5ab0651 commit 18e4f40

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

builtin/checkout.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,9 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
8383
return 0;
8484
}
8585

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)
8787
{
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);
9289

9390
/* update the index with the given tree's info
9491
* for all args, expanding wildcards, and exit
@@ -266,7 +263,7 @@ static int checkout_paths(const struct checkout_opts *opts,
266263
return error(_("corrupt index file"));
267264

268265
if (opts->source_tree)
269-
read_tree_some(opts->source_tree, opts->pathspec.raw);
266+
read_tree_some(opts->source_tree, &opts->pathspec);
270267

271268
ps_matched = xcalloc(1, opts->pathspec.nr);
272269

tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int read_one_entry_quick(const unsigned char *sha1, const char *base, int
4747
}
4848

4949
static int read_tree_1(struct tree *tree, struct strbuf *base,
50-
int stage, struct pathspec *pathspec,
50+
int stage, const struct pathspec *pathspec,
5151
read_tree_fn_t fn, void *context)
5252
{
5353
struct tree_desc desc;
@@ -116,7 +116,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
116116

117117
int read_tree_recursive(struct tree *tree,
118118
const char *base, int baselen,
119-
int stage, struct pathspec *pathspec,
119+
int stage, const struct pathspec *pathspec,
120120
read_tree_fn_t fn, void *context)
121121
{
122122
struct strbuf sb = STRBUF_INIT;

tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const ch
2525

2626
extern int read_tree_recursive(struct tree *tree,
2727
const char *base, int baselen,
28-
int stage, struct pathspec *pathspec,
28+
int stage, const struct pathspec *pathspec,
2929
read_tree_fn_t fn, void *context);
3030

3131
extern int read_tree(struct tree *tree, int stage, struct pathspec *pathspec);

0 commit comments

Comments
 (0)