]>
Commit | Line | Data |
---|---|---|
fff42755 VM |
1 | #ifndef PACK_BITMAP_H |
2 | #define PACK_BITMAP_H | |
3 | ||
4 | #include "ewah/ewok.h" | |
5 | #include "khash.h" | |
40d18ff8 | 6 | #include "pack.h" |
7cc8f971 | 7 | #include "pack-objects.h" |
3f267a11 | 8 | #include "string-list.h" |
fff42755 | 9 | |
ef3ca954 | 10 | struct commit; |
7c141127 | 11 | struct repository; |
ef3ca954 EN |
12 | struct rev_info; |
13 | ||
af26e2a9 DL |
14 | static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'}; |
15 | ||
fff42755 | 16 | struct bitmap_disk_header { |
af26e2a9 | 17 | char magic[ARRAY_SIZE(BITMAP_IDX_SIGNATURE)]; |
fff42755 VM |
18 | uint16_t version; |
19 | uint16_t options; | |
20 | uint32_t entry_count; | |
0f4d6cad | 21 | unsigned char checksum[GIT_MAX_RAWSZ]; |
fff42755 VM |
22 | }; |
23 | ||
0d41b183 | 24 | #define BITMAP_PSEUDO_MERGE (1u<<21) |
7cc8f971 VM |
25 | #define NEEDS_BITMAP (1u<<22) |
26 | ||
28cd7306 AC |
27 | /* |
28 | * The width in bytes of a single triplet in the lookup table | |
29 | * extension: | |
30 | * (commit_pos, offset, xor_row) | |
31 | * | |
32 | * whose fields ar 32-, 64-, 32- bits wide, respectively. | |
33 | */ | |
34 | #define BITMAP_LOOKUP_TABLE_TRIPLET_WIDTH (16) | |
35 | ||
fff42755 | 36 | enum pack_bitmap_opts { |
93eb41e2 AC |
37 | BITMAP_OPT_FULL_DAG = 0x1, |
38 | BITMAP_OPT_HASH_CACHE = 0x4, | |
39 | BITMAP_OPT_LOOKUP_TABLE = 0x10, | |
53ea3ec4 | 40 | BITMAP_OPT_PSEUDO_MERGES = 0x20, |
fff42755 VM |
41 | }; |
42 | ||
7cc8f971 VM |
43 | enum pack_bitmap_flags { |
44 | BITMAP_FLAG_REUSE = 0x1 | |
45 | }; | |
46 | ||
fff42755 | 47 | typedef int (*show_reachable_fn)( |
20664967 | 48 | const struct object_id *oid, |
fff42755 VM |
49 | enum object_type type, |
50 | int flags, | |
51 | uint32_t hash, | |
52 | struct packed_git *found_pack, | |
3d454838 PS |
53 | off_t found_offset, |
54 | void *payload); | |
fff42755 | 55 | |
3ae5fa07 JT |
56 | struct bitmap_index; |
57 | ||
5f5ccd95 TB |
58 | struct bitmapped_pack { |
59 | struct packed_git *p; | |
60 | ||
61 | uint32_t bitmap_pos; | |
62 | uint32_t bitmap_nr; | |
63 | ||
41cd4b47 | 64 | struct multi_pack_index *from_midx; /* MIDX only */ |
5f5ccd95 TB |
65 | uint32_t pack_int_id; /* MIDX only */ |
66 | }; | |
67 | ||
7c141127 | 68 | struct bitmap_index *prepare_bitmap_git(struct repository *r); |
bfbb60d3 | 69 | struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx); |
c9b94a77 PS |
70 | |
71 | /* | |
72 | * Given a bitmap index, determine whether it contains the pack either directly | |
73 | * or via the multi-pack-index. | |
74 | */ | |
75 | int bitmap_index_contains_pack(struct bitmap_index *bitmap, struct packed_git *pack); | |
76 | ||
3ae5fa07 JT |
77 | void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits, |
78 | uint32_t *trees, uint32_t *blobs, uint32_t *tags); | |
79 | void traverse_bitmap_commit_list(struct bitmap_index *, | |
4eb707eb | 80 | struct rev_info *revs, |
3ae5fa07 | 81 | show_reachable_fn show_reachable); |
fff42755 | 82 | void test_bitmap_walk(struct rev_info *revs); |
dff5e49e | 83 | int test_bitmap_commits(struct repository *r); |
a05f02b1 | 84 | int test_bitmap_hashes(struct repository *r); |
71eca9ab TB |
85 | int test_bitmap_pseudo_merges(struct repository *r); |
86 | int test_bitmap_pseudo_merge_commits(struct repository *r, uint32_t n); | |
87 | int test_bitmap_pseudo_merge_objects(struct repository *r, uint32_t n); | |
b0afdce5 | 88 | |
5420901b PS |
89 | struct list_objects_filter_options; |
90 | ||
91 | /* | |
92 | * Filter bitmapped objects and iterate through all resulting objects, | |
93 | * executing `show_reach` for each of them. Returns `-1` in case the filter is | |
94 | * not supported, `0` otherwise. | |
95 | */ | |
96 | int for_each_bitmapped_object(struct bitmap_index *bitmap_git, | |
97 | struct list_objects_filter_options *filter, | |
98 | show_reachable_fn show_reach, | |
99 | void *payload); | |
100 | ||
b0afdce5 TB |
101 | #define GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL \ |
102 | "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL" | |
103 | ||
6663ae0a | 104 | struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, |
9cf68b27 | 105 | int filter_provided_objects); |
83296d20 TB |
106 | void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git, |
107 | struct bitmapped_pack **packs_out, | |
108 | size_t *packs_nr_out, | |
af626ac0 TB |
109 | struct bitmap **reuse_out, |
110 | int multi_pack_reuse); | |
3ae5fa07 | 111 | int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping, |
d2bc62b1 | 112 | kh_oid_map_t *reused_bitmaps, int show_progress); |
f3c23db2 | 113 | void free_bitmap_index(struct bitmap_index *); |
40d18ff8 JK |
114 | int bitmap_walk_contains(struct bitmap_index *, |
115 | struct bitmap *bitmap, const struct object_id *oid); | |
7cc8f971 | 116 | |
30cdc33f | 117 | /* |
5476fb07 | 118 | * After a traversal has been performed by prepare_bitmap_walk(), this can be |
30cdc33f JK |
119 | * queried to see if a particular object was reachable from any of the |
120 | * objects flagged as UNINTERESTING. | |
121 | */ | |
3c771448 | 122 | int bitmap_has_oid_in_uninteresting(struct bitmap_index *, const struct object_id *oid); |
30cdc33f | 123 | |
16950f83 JK |
124 | off_t get_disk_usage_from_bitmap(struct bitmap_index *, struct rev_info *); |
125 | ||
07647c92 | 126 | struct bitmap_writer { |
1a6768d1 | 127 | struct repository *repo; |
07647c92 TB |
128 | struct ewah_bitmap *commits; |
129 | struct ewah_bitmap *trees; | |
130 | struct ewah_bitmap *blobs; | |
131 | struct ewah_bitmap *tags; | |
132 | ||
133 | kh_oid_map_t *bitmaps; | |
134 | struct packing_data *to_pack; | |
27afc272 | 135 | struct multi_pack_index *midx; /* if appending to a MIDX chain */ |
07647c92 TB |
136 | |
137 | struct bitmapped_commit *selected; | |
138 | unsigned int selected_nr, selected_alloc; | |
139 | ||
faf558b2 TB |
140 | struct string_list pseudo_merge_groups; |
141 | kh_oid_map_t *pseudo_merge_commits; /* oid -> pseudo merge(s) */ | |
0d41b183 TB |
142 | uint32_t pseudo_merges_nr; |
143 | ||
07647c92 TB |
144 | struct progress *progress; |
145 | int show_progress; | |
146 | unsigned char pack_checksum[GIT_MAX_RAWSZ]; | |
147 | }; | |
148 | ||
01e9d129 | 149 | void bitmap_writer_init(struct bitmap_writer *writer, struct repository *r, |
27afc272 TB |
150 | struct packing_data *pdata, |
151 | struct multi_pack_index *midx); | |
07647c92 TB |
152 | void bitmap_writer_show_progress(struct bitmap_writer *writer, int show); |
153 | void bitmap_writer_set_checksum(struct bitmap_writer *writer, | |
154 | const unsigned char *sha1); | |
155 | void bitmap_writer_build_type_index(struct bitmap_writer *writer, | |
125ee4ae | 156 | struct pack_idx_entry **index); |
245a7f2e TB |
157 | int bitmap_writer_has_bitmapped_object_id(struct bitmap_writer *writer, |
158 | const struct object_id *oid); | |
c059c879 TB |
159 | void bitmap_writer_push_commit(struct bitmap_writer *writer, |
160 | struct commit *commit, unsigned pseudo_merge); | |
449fa5ee JK |
161 | uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git, |
162 | struct packing_data *mapping); | |
163 | int rebuild_bitmap(const uint32_t *reposition, | |
164 | struct ewah_bitmap *source, | |
165 | struct bitmap *dest); | |
98c31f36 TB |
166 | struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git, |
167 | struct commit *commit); | |
7252d9a0 TB |
168 | struct ewah_bitmap *pseudo_merge_bitmap_for_commit(struct bitmap_index *bitmap_git, |
169 | struct commit *commit); | |
07647c92 TB |
170 | void bitmap_writer_select_commits(struct bitmap_writer *writer, |
171 | struct commit **indexed_commits, | |
9675b069 | 172 | unsigned int indexed_commits_nr); |
f00dda48 | 173 | int bitmap_writer_build(struct bitmap_writer *writer); |
07647c92 TB |
174 | void bitmap_writer_finish(struct bitmap_writer *writer, |
175 | struct pack_idx_entry **index, | |
ae4f07fb VM |
176 | const char *filename, |
177 | uint16_t options); | |
85f360fe | 178 | void bitmap_writer_free(struct bitmap_writer *writer); |
0f533c72 TB |
179 | char *midx_bitmap_filename(struct multi_pack_index *midx); |
180 | char *pack_bitmap_filename(struct packed_git *p); | |
181 | ||
182 | int bitmap_is_midx(struct bitmap_index *bitmap_git); | |
fff42755 | 183 | |
3f267a11 | 184 | const struct string_list *bitmap_preferred_tips(struct repository *r); |
711260fd | 185 | int bitmap_is_preferred_refname(struct repository *r, const char *refname); |
3f267a11 | 186 | |
756f1bcd DS |
187 | int verify_bitmap_files(struct repository *r); |
188 | ||
79621f3e TB |
189 | struct ewah_bitmap *read_bitmap(const unsigned char *map, |
190 | size_t map_size, size_t *map_pos); | |
fff42755 | 191 | #endif |