Merge branch 'en/rename-directory-detection-reboot'
[git.git] / pack-objects.h
blobaf4f46c02671597f810cd70aa25102d128a39a5f
1 #ifndef PACK_OBJECTS_H
2 #define PACK_OBJECTS_H
4 #define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024)
6 struct object_entry {
7 struct pack_idx_entry idx;
8 unsigned long size; /* uncompressed size */
9 struct packed_git *in_pack; /* already in pack */
10 off_t in_pack_offset;
11 struct object_entry *delta; /* delta base object */
12 struct object_entry *delta_child; /* deltified objects who bases me */
13 struct object_entry *delta_sibling; /* other deltified objects who
14 * uses the same base as me
16 void *delta_data; /* cached delta (uncompressed) */
17 unsigned long delta_size; /* delta data size (uncompressed) */
18 unsigned long z_delta_size; /* delta data size (compressed) */
19 enum object_type type;
20 enum object_type in_pack_type; /* could be delta */
21 uint32_t hash; /* name hint hash */
22 unsigned int in_pack_pos;
23 unsigned char in_pack_header_size;
24 unsigned preferred_base:1; /*
25 * we do not pack this, but is available
26 * to be used as the base object to delta
27 * objects against.
29 unsigned no_try_delta:1;
30 unsigned tagged:1; /* near the very tip of refs */
31 unsigned filled:1; /* assigned write-order */
34 * State flags for depth-first search used for analyzing delta cycles.
36 * The depth is measured in delta-links to the base (so if A is a delta
37 * against B, then A has a depth of 1, and B a depth of 0).
39 enum {
40 DFS_NONE = 0,
41 DFS_ACTIVE,
42 DFS_DONE
43 } dfs_state;
44 int depth;
47 struct packing_data {
48 struct object_entry *objects;
49 uint32_t nr_objects, nr_alloc;
51 int32_t *index;
52 uint32_t index_size;
55 struct object_entry *packlist_alloc(struct packing_data *pdata,
56 const unsigned char *sha1,
57 uint32_t index_pos);
59 struct object_entry *packlist_find(struct packing_data *pdata,
60 const unsigned char *sha1,
61 uint32_t *index_pos);
63 static inline uint32_t pack_name_hash(const char *name)
65 uint32_t c, hash = 0;
67 if (!name)
68 return 0;
71 * This effectively just creates a sortable number from the
72 * last sixteen non-whitespace characters. Last characters
73 * count "most", so things that end in ".c" sort together.
75 while ((c = *name++) != 0) {
76 if (isspace(c))
77 continue;
78 hash = (hash >> 2) + (c << 24);
80 return hash;
83 #endif