checkout: convert read_tree_some to take struct pathspec
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 14 Jul 2013 08:35:52 +0000 (15:35 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Jul 2013 17:56:08 +0000 (10:56 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c
tree.c
tree.h
index 5d317670eaa28befba4363a0e40a4b87dd328244..c2f3571f5680ff377926955de0469341f8b05cb4 100644 (file)
@@ -83,12 +83,9 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
        return 0;
 }
 
-static int read_tree_some(struct tree *tree, const char **pathspec)
+static int read_tree_some(struct tree *tree, const struct pathspec *pathspec)
 {
-       struct pathspec ps;
-       init_pathspec(&ps, pathspec);
-       read_tree_recursive(tree, "", 0, 0, &ps, update_some, NULL);
-       free_pathspec(&ps);
+       read_tree_recursive(tree, "", 0, 0, pathspec, update_some, NULL);
 
        /* update the index with the given tree's info
         * for all args, expanding wildcards, and exit
@@ -266,7 +263,7 @@ static int checkout_paths(const struct checkout_opts *opts,
                return error(_("corrupt index file"));
 
        if (opts->source_tree)
-               read_tree_some(opts->source_tree, opts->pathspec.raw);
+               read_tree_some(opts->source_tree, &opts->pathspec);
 
        ps_matched = xcalloc(1, opts->pathspec.nr);
 
diff --git a/tree.c b/tree.c
index 62fed632d8a1ade389dd645b5887155c21ae25ba..ff72f67dc128f60b64662654ea9df5a6f9beb2f8 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -47,7 +47,7 @@ static int read_one_entry_quick(const unsigned char *sha1, const char *base, int
 }
 
 static int read_tree_1(struct tree *tree, struct strbuf *base,
-                      int stage, struct pathspec *pathspec,
+                      int stage, const struct pathspec *pathspec,
                       read_tree_fn_t fn, void *context)
 {
        struct tree_desc desc;
@@ -116,7 +116,7 @@ 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, struct pathspec *pathspec,
+                       int stage, const struct pathspec *pathspec,
                        read_tree_fn_t fn, void *context)
 {
        struct strbuf sb = STRBUF_INIT;
diff --git a/tree.h b/tree.h
index 69bcb5e0ec27de6699e349b8dcec26f1cbc4e741..9dc90bac38dff0970840e507af980092af78d31d 100644 (file)
--- a/tree.h
+++ b/tree.h
@@ -25,7 +25,7 @@ typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const ch
 
 extern int read_tree_recursive(struct tree *tree,
                               const char *base, int baselen,
-                              int stage, struct pathspec *pathspec,
+                              int stage, const struct pathspec *pathspec,
                               read_tree_fn_t fn, void *context);
 
 extern int read_tree(struct tree *tree, int stage, struct pathspec *pathspec);