+ return 1;
+ }
+ return 0;
+}
+
+int read_tree_recursive(struct tree *tree,
+ const char *base, int baselen,
+ int stage, const char **match,
+ read_tree_fn_t fn)
+{
+ struct tree_desc desc;
+ struct name_entry entry;
+
+ if (parse_tree(tree))
+ return -1;
+
+ desc.buf = tree->buffer;
+ desc.size = tree->size;
+
+ while (tree_entry(&desc, &entry)) {
+ if (!match_tree_entry(base, baselen, entry.path, entry.mode, match))
+ continue;
+
+ switch (fn(entry.sha1, base, baselen, entry.path, entry.mode, stage)) {
+ case 0:
+ continue;
+ case READ_TREE_RECURSIVE:
+ break;;
+ default:
+ return -1;
+ }
+ if (S_ISDIR(entry.mode)) {