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