[PATCH 04/17] ls-tree: convert show_recursive to use the pathspec struct interface
- From
- Brandon Williams <bmwill@google.com>
- Date
- Dec 6, 2016, 21:51 UTC
- Message-ID
- <1481061106-117775-5-git-send-email-bmwill@google.com>
- In-Reply-To
- <1481061106-117775-1-git-send-email-bmwill@google.com>
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> --- builtin/ls-tree.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c index 0e30d86..e0f4307 100644 --- a/builtin/ls-tree.c +++ b/builtin/ls-tree.c @@ -31,21 +31,18 @@ static const char * const ls_tree_usage[] = { static int show_recursive(const char *base, int baselen, const char *pathname) { - const char **s; + int i; if (ls_options & LS_RECURSIVE) return 1; - s = pathspec._raw; - if (!s) + if (!pathspec.nr) return 0; - for (;;) { - const char *spec = *s++; + for (i = 0; i < pathspec.nr; i++) { + const char *spec = pathspec.items[i].match; int len, speclen; - if (!spec) - return 0; if (strncmp(base, spec, baselen)) continue; len = strlen(pathname); @@ -59,6 +56,7 @@ static int show_recursive(const char *base, int baselen, const char *pathname) continue; return 1; } + return 0; } static int show_tree(const unsigned char *sha1, struct strbuf *base,
-- 2.8.0.rc3.226.g39d4020