Remove "refs" field from "struct object"
[git/git.git] / object.h
CommitLineData
6eb8ae00
DB
1#ifndef OBJECT_H
2#define OBJECT_H
3
4struct object_list {
5 struct object *item;
6 struct object_list *next;
9ce43d1c 7 const char *name;
6eb8ae00
DB
8};
9
27dedf0c
JH
10struct object_refs {
11 unsigned count;
3e4339e6 12 struct object *base;
8f1d2e6f 13 struct object *ref[FLEX_ARRAY]; /* more */
27dedf0c
JH
14};
15
885a86ab
LT
16#define TYPE_BITS 3
17#define FLAG_BITS 27
18
19#define TYPE_NONE 0
20#define TYPE_BLOB 1
21#define TYPE_TREE 2
22#define TYPE_COMMIT 3
23#define TYPE_TAG 4
24#define TYPE_BAD 5
25
6eb8ae00
DB
26struct object {
27 unsigned parsed : 1;
28 unsigned used : 1;
885a86ab
LT
29 unsigned type : TYPE_BITS;
30 unsigned flags : FLAG_BITS;
6eb8ae00 31 unsigned char sha1[20];
6eb8ae00
DB
32};
33
8805ccac 34extern int track_object_refs;
070879ca 35extern int obj_allocs;
88355048 36extern struct object **objs;
885a86ab
LT
37extern const char *type_names[];
38
39static inline const char *typename(unsigned int type)
40{
41 return type_names[type > TYPE_TAG ? TYPE_BAD : type];
42}
6eb8ae00 43
3e4339e6
LT
44extern struct object_refs *lookup_object_refs(struct object *);
45
89e4202f 46/** Internal only **/
5d6ccf5c 47struct object *lookup_object(const unsigned char *sha1);
6eb8ae00 48
89e4202f
DB
49/** Returns the object, having looked it up as being the given type. **/
50struct object *lookup_object_type(const unsigned char *sha1, const char *type);
51
5d6ccf5c 52void created_object(const unsigned char *sha1, struct object *obj);
6eb8ae00 53
e9eefa67 54/** Returns the object, having parsed it to find out what it is. **/
5d6ccf5c 55struct object *parse_object(const unsigned char *sha1);
e9eefa67 56
66e481b0
DB
57/** Returns the object, with potentially excess memory allocated. **/
58struct object *lookup_unknown_object(const unsigned char *sha1);
59
27dedf0c
JH
60struct object_refs *alloc_object_refs(unsigned count);
61void set_object_refs(struct object *obj, struct object_refs *refs);
6eb8ae00
DB
62
63void mark_reachable(struct object *obj, unsigned int mask);
64
66e481b0
DB
65struct object_list *object_list_insert(struct object *item,
66 struct object_list **list_p);
67
680bab3d
DB
68void object_list_append(struct object *item,
69 struct object_list **list_p);
70
66e481b0
DB
71unsigned object_list_length(struct object_list *list);
72
73int object_list_contains(struct object_list *list, struct object *obj);
74
6eb8ae00 75#endif /* OBJECT_H */