X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=fetch.c;h=e040ef97b6b7e29d9e6482ad0ebead589e86a2a2;hb=1d84a60459a32fb1707ff7de4a013b5d9673f55d;hp=cc6013e7afb4479f325cf20bb22684246ead8022;hpb=99bd0f555823f3c3868561af33d85864a90a7d9a;p=git.git diff --git a/fetch.c b/fetch.c index cc6013e7..e040ef97 100644 --- a/fetch.c +++ b/fetch.c @@ -3,6 +3,7 @@ #include "cache.h" #include "commit.h" #include "tree.h" +#include "tree-walk.h" #include "tag.h" #include "blob.h" #include "refs.h" @@ -37,21 +38,33 @@ static int process(struct object *obj); static int process_tree(struct tree *tree) { - struct tree_entry_list *entry; + struct tree_desc desc; + struct name_entry entry; if (parse_tree(tree)) return -1; - entry = tree->entries; - tree->entries = NULL; - while (entry) { - struct tree_entry_list *next = entry->next; - if (process(entry->item.any)) + desc.buf = tree->buffer; + desc.size = tree->size; + while (tree_entry(&desc, &entry)) { + struct object *obj = NULL; + + if (S_ISDIR(entry.mode)) { + struct tree *tree = lookup_tree(entry.sha1); + if (tree) + obj = &tree->object; + } + else { + struct blob *blob = lookup_blob(entry.sha1); + if (blob) + obj = &blob->object; + } + if (!obj || process(obj)) return -1; - free(entry->name); - free(entry); - entry = next; } + free(tree->buffer); + tree->buffer = NULL; + tree->size = 0; return 0; }