Merge branch 'ps/reftable-write-options'
[git.git] / pack-bitmap.h
blob3091095f3368c539218fec40aebf77570965e30b
1 #ifndef PACK_BITMAP_H
2 #define PACK_BITMAP_H
4 #include "ewah/ewok.h"
5 #include "khash.h"
6 #include "pack.h"
7 #include "pack-objects.h"
8 #include "string-list.h"
10 struct commit;
11 struct repository;
12 struct rev_info;
14 static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'};
16 struct bitmap_disk_header {
17 char magic[ARRAY_SIZE(BITMAP_IDX_SIGNATURE)];
18 uint16_t version;
19 uint16_t options;
20 uint32_t entry_count;
21 unsigned char checksum[GIT_MAX_RAWSZ];
24 #define NEEDS_BITMAP (1u<<22)
27 * The width in bytes of a single triplet in the lookup table
28 * extension:
29 * (commit_pos, offset, xor_row)
31 * whose fields ar 32-, 64-, 32- bits wide, respectively.
33 #define BITMAP_LOOKUP_TABLE_TRIPLET_WIDTH (16)
35 enum pack_bitmap_opts {
36 BITMAP_OPT_FULL_DAG = 0x1,
37 BITMAP_OPT_HASH_CACHE = 0x4,
38 BITMAP_OPT_LOOKUP_TABLE = 0x10,
41 enum pack_bitmap_flags {
42 BITMAP_FLAG_REUSE = 0x1
45 typedef int (*show_reachable_fn)(
46 const struct object_id *oid,
47 enum object_type type,
48 int flags,
49 uint32_t hash,
50 struct packed_git *found_pack,
51 off_t found_offset);
53 struct bitmap_index;
55 struct bitmapped_pack {
56 struct packed_git *p;
58 uint32_t bitmap_pos;
59 uint32_t bitmap_nr;
61 uint32_t pack_int_id; /* MIDX only */
64 struct bitmap_index *prepare_bitmap_git(struct repository *r);
65 struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx);
66 void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
67 uint32_t *trees, uint32_t *blobs, uint32_t *tags);
68 void traverse_bitmap_commit_list(struct bitmap_index *,
69 struct rev_info *revs,
70 show_reachable_fn show_reachable);
71 void test_bitmap_walk(struct rev_info *revs);
72 int test_bitmap_commits(struct repository *r);
73 int test_bitmap_hashes(struct repository *r);
75 #define GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL \
76 "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL"
78 struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
79 int filter_provided_objects);
80 void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
81 struct bitmapped_pack **packs_out,
82 size_t *packs_nr_out,
83 struct bitmap **reuse_out,
84 int multi_pack_reuse);
85 int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
86 kh_oid_map_t *reused_bitmaps, int show_progress);
87 void free_bitmap_index(struct bitmap_index *);
88 int bitmap_walk_contains(struct bitmap_index *,
89 struct bitmap *bitmap, const struct object_id *oid);
92 * After a traversal has been performed by prepare_bitmap_walk(), this can be
93 * queried to see if a particular object was reachable from any of the
94 * objects flagged as UNINTERESTING.
96 int bitmap_has_oid_in_uninteresting(struct bitmap_index *, const struct object_id *oid);
98 off_t get_disk_usage_from_bitmap(struct bitmap_index *, struct rev_info *);
100 struct bitmap_writer {
101 struct ewah_bitmap *commits;
102 struct ewah_bitmap *trees;
103 struct ewah_bitmap *blobs;
104 struct ewah_bitmap *tags;
106 kh_oid_map_t *bitmaps;
107 struct packing_data *to_pack;
109 struct bitmapped_commit *selected;
110 unsigned int selected_nr, selected_alloc;
112 struct progress *progress;
113 int show_progress;
114 unsigned char pack_checksum[GIT_MAX_RAWSZ];
117 void bitmap_writer_init(struct bitmap_writer *writer);
118 void bitmap_writer_show_progress(struct bitmap_writer *writer, int show);
119 void bitmap_writer_set_checksum(struct bitmap_writer *writer,
120 const unsigned char *sha1);
121 void bitmap_writer_build_type_index(struct bitmap_writer *writer,
122 struct packing_data *to_pack,
123 struct pack_idx_entry **index,
124 uint32_t index_nr);
125 uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git,
126 struct packing_data *mapping);
127 int rebuild_bitmap(const uint32_t *reposition,
128 struct ewah_bitmap *source,
129 struct bitmap *dest);
130 struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git,
131 struct commit *commit);
132 void bitmap_writer_select_commits(struct bitmap_writer *writer,
133 struct commit **indexed_commits,
134 unsigned int indexed_commits_nr);
135 int bitmap_writer_build(struct bitmap_writer *writer,
136 struct packing_data *to_pack);
137 void bitmap_writer_finish(struct bitmap_writer *writer,
138 struct pack_idx_entry **index,
139 uint32_t index_nr,
140 const char *filename,
141 uint16_t options);
142 void bitmap_writer_free(struct bitmap_writer *writer);
143 char *midx_bitmap_filename(struct multi_pack_index *midx);
144 char *pack_bitmap_filename(struct packed_git *p);
146 int bitmap_is_midx(struct bitmap_index *bitmap_git);
148 const struct string_list *bitmap_preferred_tips(struct repository *r);
149 int bitmap_is_preferred_refname(struct repository *r, const char *refname);
151 int verify_bitmap_files(struct repository *r);
153 #endif