@matheusbsbs / matheus-bagliano / commits / 1bc995a392
Fork 0

Convert fetch.c: process_tree() to raw tree walker

This leaves only the horrid code in builtin-read-tree.c using the old interface. Some day I will gather the strength to tackle that one too. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed May 29, 2006 at 12:20 UTC 1bc995a3920da4e9143ccf9d34bdabf70ab8a211
1 file changed +15 -9
fetch.c
+15 -9
@@ -3,6 +3,7 @@
3 #include "cache.h"
4 #include "commit.h"
5 #include "tree.h"
6 +#include "tree-walk.h"
7 #include "tag.h"
8 #include "blob.h"
9 #include "refs.h"
@@ -36,27 +37,32 @@ static int process(struct object *obj);
37
38 static int process_tree(struct tree *tree)
39 {
39 - struct tree_entry_list *entry;
40 + struct tree_desc desc;
41
42 if (parse_tree(tree))
43 return -1;
44
44 - entry = create_tree_entry_list(tree);
45 - while (entry) {
46 - struct tree_entry_list *next = entry->next;
45 + desc.buf = tree->buffer;
46 + desc.size = tree->size;
47 + while (desc.size) {
48 + unsigned mode;
49 + const char *name;
50 + const unsigned char *sha1;
51
48 - if (entry->directory) {
49 - struct tree *tree = lookup_tree(entry->sha1);
52 + sha1 = tree_entry_extract(&desc, &name, &mode);
53 + update_tree_entry(&desc);
54 +
55 + if (S_ISDIR(mode)) {
56 + struct tree *tree = lookup_tree(sha1);
57 process_tree(tree);
58 } else {
52 - struct blob *blob = lookup_blob(entry->sha1);
59 + struct blob *blob = lookup_blob(sha1);
60 process(&blob->object);
61 }
55 - free(entry);
56 - entry = next;
62 }
63 free(tree->buffer);
64 tree->buffer = NULL;
65 + tree->size = 0;
66 return 0;
67 }
68