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

builtin-read-tree.c: avoid tree_entry_list in prime_cache_tree_rec()

Use the raw tree walker instead. 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:18 UTC 1ccf5a345a6e7974ec0380eed735c2db97e50b4c
1 file changed +15 -5
builtin-read-tree.c
+15 -5
@@ -9,6 +9,7 @@
9
10 #include "object.h"
11 #include "tree.h"
12 +#include "tree-walk.h"
13 #include "cache-tree.h"
14 #include <sys/time.h>
15 #include <signal.h>
@@ -775,19 +776,28 @@ static int read_cache_unmerged(void)
776
777 static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
778 {
778 - struct tree_entry_list *ent;
779 + struct tree_desc desc;
780 int cnt;
781
782 memcpy(it->sha1, tree->object.sha1, 20);
782 - for (cnt = 0, ent = tree->entries; ent; ent = ent->next) {
783 - if (!ent->directory)
783 + desc.buf = tree->buffer;
784 + desc.size = tree->size;
785 + cnt = 0;
786 + while (desc.size) {
787 + unsigned mode;
788 + const char *name;
789 + const unsigned char *sha1;
790 +
791 + sha1 = tree_entry_extract(&desc, &name, &mode);
792 + update_tree_entry(&desc);
793 + if (!S_ISDIR(mode))
794 cnt++;
795 else {
796 struct cache_tree_sub *sub;
787 - struct tree *subtree = lookup_tree(ent->sha1);
797 + struct tree *subtree = lookup_tree(sha1);
798 if (!subtree->object.parsed)
799 parse_tree(subtree);
790 - sub = cache_tree_sub(it, ent->name);
800 + sub = cache_tree_sub(it, name);
801 sub->cache_tree = cache_tree();
802 prime_cache_tree_rec(sub->cache_tree, subtree);
803 cnt += sub->cache_tree->entry_count;