Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/pack-bitmap.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / pack-bitmap.h` 212 lines ยท 7070 bytes Raw Blame History 1 #ifndef PACK_BITMAP_H 2 #define PACK_BITMAP_H 3 4 #include "ewah/ewok.h" 5 #include "khash.h" 6 #include "pack.h" 7 #include "pack-objects.h" 8 #include "refs.h" 9 #include "string-list.h" 10 11 struct commit; 12 struct odb_source_packed; 13 struct repository; 14 struct rev_info; 15 16 static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'}; 17 18 struct bitmap_disk_header { 19 char magic[ARRAY_SIZE(BITMAP_IDX_SIGNATURE)]; 20 uint16_t version; 21 uint16_t options; 22 uint32_t entry_count; 23 unsigned char checksum[GIT_MAX_RAWSZ]; 24 }; 25 26 #define BITMAP_PSEUDO_MERGE (1u<<21) 27 #define NEEDS_BITMAP (1u<<22) 28 29 /* 30 * The width in bytes of a single triplet in the lookup table 31 * extension: 32 * (commit_pos, offset, xor_row) 33 * 34 * whose fields ar 32-, 64-, 32- bits wide, respectively. 35 */ 36 #define BITMAP_LOOKUP_TABLE_TRIPLET_WIDTH (16) 37 38 enum pack_bitmap_opts { 39 BITMAP_OPT_FULL_DAG = 0x1, 40 BITMAP_OPT_HASH_CACHE = 0x4, 41 BITMAP_OPT_LOOKUP_TABLE = 0x10, 42 BITMAP_OPT_PSEUDO_MERGES = 0x20, 43 }; 44 45 enum pack_bitmap_flags { 46 BITMAP_FLAG_REUSE = 0x1 47 }; 48 49 typedef int (*show_reachable_fn)( 50 const struct object_id *oid, 51 enum object_type type, 52 int flags, 53 uint32_t hash, 54 struct packed_git *found_pack, 55 off_t found_offset, 56 void *payload); 57 58 struct bitmap_index; 59 60 struct bitmapped_pack { 61 struct packed_git *p; 62 63 uint32_t bitmap_pos; 64 uint32_t bitmap_nr; 65 66 struct multi_pack_index *from_midx; /* MIDX only */ 67 uint32_t pack_int_id; /* MIDX only */ 68 }; 69 70 struct bitmap_index *prepare_bitmap_git(struct repository *r); 71 struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx); 72 struct bitmap_index *prepare_bitmap_git_for_source(struct odb_source_packed *source); 73 74 /* 75 * Given a bitmap index, determine whether it contains the pack either directly 76 * or via the multi-pack-index. 77 */ 78 int bitmap_index_contains_pack(struct bitmap_index *bitmap, struct packed_git *pack); 79 80 void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits, 81 uint32_t *trees, uint32_t *blobs, uint32_t *tags); 82 void traverse_bitmap_commit_list(struct bitmap_index *, 83 struct rev_info *revs, 84 show_reachable_fn show_reachable); 85 void test_bitmap_walk(struct rev_info *revs); 86 int test_bitmap_commits(struct repository *r); 87 int test_bitmap_commits_with_offset(struct repository *r); 88 int test_bitmap_hashes(struct repository *r); 89 int test_bitmap_pseudo_merges(struct repository *r); 90 int test_bitmap_pseudo_merge_commits(struct repository *r, uint32_t n); 91 int test_bitmap_pseudo_merge_objects(struct repository *r, uint32_t n); 92 93 struct list_objects_filter_options; 94 95 /* Check whether the filter can be computed via the bitmap. */ 96 bool can_filter_bitmap(const struct list_objects_filter_options *filter); 97 98 /* 99 * Filter bitmapped objects and iterate through all resulting objects, 100 * executing `show_reach` for each of them. Returns `-1` in case the filter is 101 * not supported, `0` otherwise. Aborts iteration and bubbles up the return 102 * value in case `show_reach()` returns non-zero. 103 */ 104 int for_each_bitmapped_object(struct bitmap_index *bitmap_git, 105 const struct list_objects_filter_options *filter, 106 show_reachable_fn show_reach, 107 void *payload); 108 109 /* 110 * Iterate over all references that are configured as preferred bitmap tips via 111 * "pack.preferBitmapTips" and invoke the callback on each function. 112 */ 113 void for_each_preferred_bitmap_tip(struct repository *repo, 114 refs_for_each_cb cb, void *cb_data); 115 116 #define GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL \ 117 "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL" 118 119 struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, 120 int filter_provided_objects); 121 void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git, 122 struct bitmapped_pack **packs_out, 123 size_t *packs_nr_out, 124 struct bitmap **reuse_out, 125 int multi_pack_reuse); 126 int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping, 127 kh_oid_map_t *reused_bitmaps, int show_progress); 128 void free_bitmap_index(struct bitmap_index *); 129 int bitmap_walk_contains(struct bitmap_index *, 130 struct bitmap *bitmap, const struct object_id *oid); 131 132 /* 133 * After a traversal has been performed by prepare_bitmap_walk(), this can be 134 * queried to see if a particular object was reachable from any of the 135 * objects flagged as UNINTERESTING. 136 */ 137 int bitmap_has_oid_in_uninteresting(struct bitmap_index *, const struct object_id *oid); 138 139 off_t get_disk_usage_from_bitmap(struct bitmap_index *, struct rev_info *); 140 141 struct bitmap_pos_cache_entry; 142 143 struct bitmap_writer { 144 struct repository *repo; 145 struct ewah_bitmap *commits; 146 struct ewah_bitmap *trees; 147 struct ewah_bitmap *blobs; 148 struct ewah_bitmap *tags; 149 150 kh_oid_map_t *bitmaps; 151 struct packing_data *to_pack; 152 struct multi_pack_index *midx; /* if appending to a MIDX chain */ 153 154 struct bitmap_pos_cache_entry *pos_cache; 155 size_t pos_cache_nr; 156 uint64_t pos_cache_hits; 157 uint64_t pos_cache_misses; 158 159 struct bitmapped_commit *selected; 160 unsigned int selected_nr, selected_alloc; 161 162 struct string_list pseudo_merge_groups; 163 kh_oid_map_t *pseudo_merge_commits; /* oid -> pseudo merge(s) */ 164 uint32_t pseudo_merges_nr; 165 166 struct progress *progress; 167 int show_progress; 168 unsigned char pack_checksum[GIT_MAX_RAWSZ]; 169 }; 170 171 void bitmap_writer_init(struct bitmap_writer *writer, struct repository *r, 172 struct packing_data *pdata, 173 struct multi_pack_index *midx); 174 void bitmap_writer_show_progress(struct bitmap_writer *writer, int show); 175 void bitmap_writer_set_checksum(struct bitmap_writer *writer, 176 const unsigned char *sha1); 177 void bitmap_writer_build_type_index(struct bitmap_writer *writer, 178 struct pack_idx_entry **index); 179 int bitmap_writer_has_bitmapped_object_id(struct bitmap_writer *writer, 180 const struct object_id *oid); 181 void bitmap_writer_push_commit(struct bitmap_writer *writer, 182 struct commit *commit, unsigned pseudo_merge); 183 uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git, 184 struct packing_data *mapping); 185 int rebuild_bitmap(const uint32_t *reposition, 186 struct ewah_bitmap *source, 187 struct bitmap *dest); 188 struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git, 189 struct commit *commit); 190 struct ewah_bitmap *pseudo_merge_bitmap_for_commit(struct bitmap_index *bitmap_git, 191 struct commit *commit); 192 void bitmap_writer_select_commits(struct bitmap_writer *writer, 193 struct commit **indexed_commits, 194 unsigned int indexed_commits_nr); 195 int bitmap_writer_build(struct bitmap_writer *writer); 196 void bitmap_writer_finish(struct bitmap_writer *writer, 197 struct pack_idx_entry **index, 198 const char *filename, 199 uint16_t options); 200 void bitmap_writer_free(struct bitmap_writer *writer); 201 char *midx_bitmap_filename(struct multi_pack_index *midx); 202 char *pack_bitmap_filename(struct packed_git *p); 203 204 int bitmap_is_midx(struct bitmap_index *bitmap_git); 205 206 int bitmap_is_preferred_refname(struct repository *r, const char *refname); 207 208 int verify_bitmap_files(struct odb_source_packed *source); 209 210 struct ewah_bitmap *read_bitmap(const unsigned char *map, 211 size_t map_size, size_t *map_pos); 212 #endif