1#ifndef OBJECT_H2#define OBJECT_H34struct object_list {5struct object *item;6struct object_list *next;7const char *name;8};910struct object_refs {11unsigned count;12struct object *base;13struct object *ref[FLEX_ARRAY]; /* more */14};1516#define TYPE_BITS 317#define FLAG_BITS 271819#define TYPE_NONE 020#define TYPE_BLOB 121#define TYPE_TREE 222#define TYPE_COMMIT 323#define TYPE_TAG 424#define TYPE_BAD 52526struct object {27unsigned parsed : 1;28unsigned used : 1;29unsigned type : TYPE_BITS;30unsigned flags : FLAG_BITS;31unsigned char sha1[20];32};3334extern int track_object_refs;35extern int obj_allocs;36extern struct object **objs;37extern const char *type_names[];3839static inline const char *typename(unsigned int type)40{41return type_names[type > TYPE_TAG ? TYPE_BAD : type];42}4344extern struct object_refs *lookup_object_refs(struct object *);4546/** Internal only **/47struct object *lookup_object(const unsigned char *sha1);4849/** Returns the object, having looked it up as being the given type. **/50struct object *lookup_object_type(const unsigned char *sha1, const char *type);5152void created_object(const unsigned char *sha1, struct object *obj);5354/** Returns the object, having parsed it to find out what it is. **/55struct object *parse_object(const unsigned char *sha1);5657/** Returns the object, with potentially excess memory allocated. **/58struct object *lookup_unknown_object(const unsigned char *sha1);5960struct object_refs *alloc_object_refs(unsigned count);61void set_object_refs(struct object *obj, struct object_refs *refs);6263void mark_reachable(struct object *obj, unsigned int mask);6465struct object_list *object_list_insert(struct object *item,66struct object_list **list_p);6768void object_list_append(struct object *item,69struct object_list **list_p);7071unsigned object_list_length(struct object_list *list);7273int object_list_contains(struct object_list *list, struct object *obj);7475#endif /* OBJECT_H */