This makes read_tree_recursive and read_tree take a struct tree
instead of a buffer. It also move the declaration of read_tree into
tree.h (where struct tree is defined), and updates ls-tree and
diff-index (the only places that presently use read_tree*()) to use
the new versions.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Daniel Barkalow19 years agocommitted byJunio C Hamano
@ -74,27 +74,24 @@ static int match_tree_entry(const char *base, int baselen, const char *path, uns
@@ -74,27 +74,24 @@ static int match_tree_entry(const char *base, int baselen, const char *path, uns
return 0;
}
int read_tree_recursive(void *buffer, unsigned long size,
int read_tree_recursive(struct tree *tree,
const char *base, int baselen,
int stage, const char **match,
read_tree_fn_t fn)
{
while (size) {
int len = strlen(buffer)+1;
unsigned char *sha1 = buffer + len;
char *path = strchr(buffer, ' ')+1;
unsigned int mode;
if (size < len + 20 || sscanf(buffer, "%o", &mode) != 1)
return -1;
buffer = sha1 + 20;
size -= len + 20;
if (!match_tree_entry(base, baselen, path, mode, match))
struct tree_entry_list *list;
if (parse_tree(tree))
return -1;
list = tree->entries;
while (list) {
struct tree_entry_list *current = list;
list = list->next;
if (!match_tree_entry(base, baselen, current->name,
@ -102,28 +99,19 @@ int read_tree_recursive(void *buffer, unsigned long size,
@@ -102,28 +99,19 @@ int read_tree_recursive(void *buffer, unsigned long size,
@ -133,9 +121,9 @@ int read_tree_recursive(void *buffer, unsigned long size,
@@ -133,9 +121,9 @@ int read_tree_recursive(void *buffer, unsigned long size,
return 0;
}
int read_tree(void *buffer, unsigned long size, int stage, const char **match)
int read_tree(struct tree *tree, int stage, const char **match)