ls-tree: convert show_recursive to use the pathspec struct interface

Convert 'show_recursive()' to use the pathspec struct interface from using the '_raw' entry in the pathspec struct. Signed-off-by: Brandon Williams <bmwill@google.com> Reviewed-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed Jan 4, 2017 at 10:03 UTC e1e24edc1a86ef1f7639b3bbebc82c045d3c27b6
1 file changed +7 -9
builtin/ls-tree.c
+7 -9
@@ -31,21 +31,18 @@ static const char * const ls_tree_usage[] = {
31
32 static int show_recursive(const char *base, int baselen, const char *pathname)
33 {
34 - const char **s;
34 + int i;
35
36 if (ls_options & LS_RECURSIVE)
37 return 1;
38
39 - s = pathspec._raw;
40 - if (!s)
39 + if (!pathspec.nr)
40 return 0;
41
43 - for (;;) {
44 - const char *spec = *s++;
42 + for (i = 0; i < pathspec.nr; i++) {
43 + const char *spec = pathspec.items[i].match;
44 int len, speclen;
45
47 - if (!spec)
48 - return 0;
46 if (strncmp(base, spec, baselen))
47 continue;
48 len = strlen(pathname);
@@ -59,6 +56,7 @@ static int show_recursive(const char *base, int baselen, const char *pathname)
56 continue;
57 return 1;
58 }
59 + return 0;
60 }
61
62 static int show_tree(const unsigned char *sha1, struct strbuf *base,
@@ -175,8 +173,8 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
173 * cannot be lifted until it is converted to use
174 * match_pathspec() or tree_entry_interesting()
175 */
178 - parse_pathspec(&pathspec, PATHSPEC_GLOB | PATHSPEC_ICASE |
179 - PATHSPEC_EXCLUDE,
176 + parse_pathspec(&pathspec, PATHSPEC_ALL_MAGIC &
177 + ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL),
178 PATHSPEC_PREFER_CWD,
179 prefix, argv + 1);
180 for (i = 0; i < pathspec.nr; i++)