This patch adds actual information to struct tree, making it possible to tell what sorts of things the referenced objects are. This is needed for http-pull, and Junio wanted something of the sort.
Signed-Off-By: Daniel Barkalow <[EMAIL PROTECTED]> Index: tree.c =================================================================== --- 1172a9b8f45b2fd640985595cc5258db3b027828/tree.c (mode:100644 sha1:7c5e5e46f4967b0812b06c0114946c3a6432c8d8) +++ 7e5a0d93117ecadfb15de3a6bebdb1aa94234fde/tree.c (mode:100644 sha1:39f9cbd1908e9046c148339f816025c9313ec142) @@ -27,6 +27,7 @@ char type[20]; void *buffer, *bufptr; unsigned long size; + struct tree_entry_list **list_p; if (item->object.parsed) return 0; item->object.parsed = 1; @@ -38,8 +39,10 @@ if (strcmp(type, tree_type)) return error("Object %s not a tree", sha1_to_hex(item->object.sha1)); + 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, ' '); @@ -48,6 +51,11 @@ sscanf(bufptr, "%o", &mode) != 1) return -1; + entry = malloc(sizeof(struct tree_entry_list)); + 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; @@ -56,12 +64,17 @@ bufptr += len + 20; size -= len + 20; - if (S_ISDIR(mode)) { - obj = &lookup_tree(file_sha1)->object; + if (entry->directory) { + entry->item.tree = lookup_tree(file_sha1); + obj = &entry->item.tree->object; } else { - obj = &lookup_blob(file_sha1)->object; + entry->item.blob = lookup_blob(file_sha1); + obj = &entry->item.blob->object; } add_ref(&item->object, obj); + + *list_p = entry; + list_p = &entry->next; } return 0; } Index: tree.h =================================================================== --- 1172a9b8f45b2fd640985595cc5258db3b027828/tree.h (mode:100644 sha1:14ebbacded09d5e058c7f94652dcb9e12bc31cae) +++ 7e5a0d93117ecadfb15de3a6bebdb1aa94234fde/tree.h (mode:100644 sha1:985500e2a9130fe8c33134ca121838af9320c465) @@ -5,9 +5,20 @@ extern const char *tree_type; +struct tree_entry_list { + struct tree_entry_list *next; + unsigned directory : 1; + unsigned executable : 1; + union { + struct tree *tree; + struct blob *blob; + } item; +}; + struct tree { struct object object; unsigned has_full_path : 1; + struct tree_entry_list *entries; }; struct tree *lookup_tree(unsigned char *sha1); - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html