4 #define OE_DFS_STATE_BITS 2
7 * State flags for depth-first search used for analyzing delta cycles.
9 * The depth is measured in delta-links to the base (so if A is a delta
10 * against B, then A has a depth of 1, and B a depth of 0).
22 * idx.oid is filled up before delta searching starts. idx.crc32 is
23 * only valid after the object is written out and will be used for
24 * generating the index. idx.offset will be both gradually set and
25 * used in writing phase (base objects get offset first, then deltas
28 * "size" is the uncompressed object size. Compressed size of the raw
29 * data for an object in a pack is not stored anywhere but is computed
30 * and made available when reverse .idx is made.
32 * "hash" contains a path name hash which is used for sorting the
33 * delta list and also during delta searching. Once prepare_pack()
34 * returns it's no longer needed.
38 * The (in_pack, in_pack_offset) tuple contains the location of the
39 * object in the source pack. in_pack_header_size allows quickly
40 * skipping the header and going straight to the zlib stream.
42 * "type" and "in_pack_type" both describe object type. in_pack_type
43 * may contain a delta type, while type is always the canonical type.
47 * Delta links (delta, delta_child and delta_sibling) are created to
48 * reflect that delta graph from the source pack then updated or added
49 * during delta searching phase when we find better deltas.
51 * delta_child and delta_sibling are last needed in
52 * compute_write_order(). "delta" and "delta_size" must remain valid
53 * at object writing phase in case the delta is not cached.
55 * If a delta is cached in memory and is compressed, delta_data points
56 * to the data and z_delta_size contains the compressed size. If it's
57 * uncompressed [1], z_delta_size must be zero. delta_size is always
58 * the uncompressed size and must be valid even if the delta is not
61 * [1] during try_delta phase we don't bother with compressing because
62 * the delta could be quickly replaced with a better one.
65 struct pack_idx_entry idx;
66 unsigned long size; /* uncompressed size */
67 struct packed_git *in_pack; /* already in pack */
69 struct object_entry *delta; /* delta base object */
70 struct object_entry *delta_child; /* deltified objects who bases me */
71 struct object_entry *delta_sibling; /* other deltified objects who
72 * uses the same base as me
74 void *delta_data; /* cached delta (uncompressed) */
75 unsigned long delta_size; /* delta data size (uncompressed) */
76 unsigned long z_delta_size; /* delta data size (compressed) */
77 unsigned type_:TYPE_BITS;
78 unsigned in_pack_type:TYPE_BITS; /* could be delta */
79 unsigned type_valid:1;
80 uint32_t hash; /* name hint hash */
81 unsigned int in_pack_pos;
82 unsigned char in_pack_header_size;
83 unsigned preferred_base:1; /*
84 * we do not pack this, but is available
85 * to be used as the base object to delta
88 unsigned no_try_delta:1;
89 unsigned tagged:1; /* near the very tip of refs */
90 unsigned filled:1; /* assigned write-order */
91 unsigned dfs_state:OE_DFS_STATE_BITS;
98 struct object_entry *objects;
99 uint32_t nr_objects, nr_alloc;
105 struct object_entry *packlist_alloc(struct packing_data *pdata,
106 const unsigned char *sha1,
109 struct object_entry *packlist_find(struct packing_data *pdata,
110 const unsigned char *sha1,
111 uint32_t *index_pos);
113 static inline uint32_t pack_name_hash(const char *name)
115 uint32_t c, hash = 0;
121 * This effectively just creates a sortable number from the
122 * last sixteen non-whitespace characters. Last characters
123 * count "most", so things that end in ".c" sort together.
125 while ((c = *name++) != 0) {
128 hash = (hash >> 2) + (c << 24);
133 static inline enum object_type oe_type(const struct object_entry *e)
135 return e->type_valid ? e->type_ : OBJ_BAD;
138 static inline void oe_set_type(struct object_entry *e,
139 enum object_type type)
142 BUG("OBJ_ANY cannot be set in pack-objects code");
144 e->type_valid = type >= OBJ_NONE;
145 e->type_ = (unsigned)type;