git-daemon: produce output when ready
[gitweb.git] / tree.c
diff --git a/tree.c b/tree.c
index db3a5c3319c81a7eb94cd267a671776d46742dc0..676e9f710ca8d5a568e0c6ea2fa88132da81b48c 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -52,7 +52,8 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
        struct tree_desc desc;
        struct name_entry entry;
        unsigned char sha1[20];
-       int len, retval = 0, oldlen = base->len;
+       int len, oldlen = base->len;
+       enum interesting retval = entry_not_interesting;
 
        if (parse_tree(tree))
                return -1;
@@ -60,11 +61,11 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
        init_tree_desc(&desc, tree->buffer, tree->size);
 
        while (tree_entry(&desc, &entry)) {
-               if (retval != 2) {
+               if (retval != all_entries_interesting) {
                        retval = tree_entry_interesting(&entry, base, 0, pathspec);
-                       if (retval < 0)
+                       if (retval == all_entries_not_interesting)
                                break;
-                       if (retval == 0)
+                       if (retval == entry_not_interesting)
                                continue;
                }
 
@@ -99,7 +100,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
                else
                        continue;
 
-               len = tree_entry_len(entry.path, entry.sha1);
+               len = tree_entry_len(&entry);
                strbuf_add(base, entry.path, len);
                strbuf_addch(base, '/');
                retval = read_tree_1(lookup_tree(sha1),
@@ -114,20 +115,15 @@ 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, const char **match,
+                       int stage, struct pathspec *pathspec,
                        read_tree_fn_t fn, void *context)
 {
        struct strbuf sb = STRBUF_INIT;
-       struct pathspec pathspec;
-       int i, ret;
+       int ret;
 
-       init_pathspec(&pathspec, match);
-       for (i = 0; i < pathspec.nr; i++)
-               pathspec.items[i].has_wildcard = 0;
        strbuf_add(&sb, base, baselen);
-       ret = read_tree_1(tree, &sb, stage, &pathspec, fn, context);
+       ret = read_tree_1(tree, &sb, stage, pathspec, fn, context);
        strbuf_release(&sb);
-       free_pathspec(&pathspec);
        return ret;
 }
 
@@ -141,7 +137,7 @@ static int cmp_cache_name_compare(const void *a_, const void *b_)
                                  ce2->name, ce2->ce_flags);
 }
 
-int read_tree(struct tree *tree, int stage, const char **match)
+int read_tree(struct tree *tree, int stage, struct pathspec *match)
 {
        read_tree_fn_t fn = NULL;
        int i, err;