1#ifndef PACK_OBJECTS_H 2#define PACK_OBJECTS_H 3 4#define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024) 5 6struct object_entry { 7struct pack_idx_entry idx; 8unsigned long size;/* uncompressed size */ 9struct packed_git *in_pack;/* already in pack */ 10 off_t in_pack_offset; 11struct object_entry *delta;/* delta base object */ 12struct object_entry *delta_child;/* deltified objects who bases me */ 13struct object_entry *delta_sibling;/* other deltified objects who 14 * uses the same base as me 15 */ 16void*delta_data;/* cached delta (uncompressed) */ 17unsigned long delta_size;/* delta data size (uncompressed) */ 18unsigned long z_delta_size;/* delta data size (compressed) */ 19enum object_type type; 20enum object_type in_pack_type;/* could be delta */ 21uint32_t hash;/* name hint hash */ 22unsigned int in_pack_pos; 23unsigned char in_pack_header_size; 24unsigned 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. 28 */ 29unsigned no_try_delta:1; 30unsigned tagged:1;/* near the very tip of refs */ 31unsigned filled:1;/* assigned write-order */ 32 33/* 34 * State flags for depth-first search used for analyzing delta cycles. 35 * 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). 38 */ 39enum{ 40 DFS_NONE =0, 41 DFS_ACTIVE, 42 DFS_DONE 43} dfs_state; 44int depth; 45}; 46 47struct packing_data { 48struct object_entry *objects; 49uint32_t nr_objects, nr_alloc; 50 51int32_t*index; 52uint32_t index_size; 53}; 54 55struct object_entry *packlist_alloc(struct packing_data *pdata, 56const unsigned char*sha1, 57uint32_t index_pos); 58 59struct object_entry *packlist_find(struct packing_data *pdata, 60const unsigned char*sha1, 61uint32_t*index_pos); 62 63staticinlineuint32_tpack_name_hash(const char*name) 64{ 65uint32_t c, hash =0; 66 67if(!name) 68return0; 69 70/* 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. 74 */ 75while((c = *name++) !=0) { 76if(isspace(c)) 77continue; 78 hash = (hash >>2) + (c <<24); 79} 80return hash; 81} 82 83#endif