- list_p = &item->entries;
- while (size) {
- struct object *obj;
- struct tree_entry_list *entry;
- int len = 1+strlen(bufptr);
- unsigned char *file_sha1 = bufptr + len;
- char *path = strchr(bufptr, ' ');
- unsigned int mode;
- if (size < len + 20 || !path ||
- sscanf(bufptr, "%o", &mode) != 1)
- return -1;
-
- entry = malloc(sizeof(struct tree_entry_list));
- entry->name = strdup(path + 1);
- entry->directory = S_ISDIR(mode);
- entry->executable = mode & S_IXUSR;
- entry->next = NULL;
-
- /* Warn about trees that don't do the recursive thing.. */
- if (strchr(path, '/')) {
- item->has_full_path = 1;
- }
-
- bufptr += len + 20;
- size -= len + 20;
-
- if (entry->directory) {
- entry->item.tree = lookup_tree(file_sha1);
- obj = &entry->item.tree->object;
- } else {
- entry->item.blob = lookup_blob(file_sha1);
- obj = &entry->item.blob->object;
- }
- if (obj)
- add_ref(&item->object, obj);
-
- *list_p = entry;
- list_p = &entry->next;