]> git.ipfire.org Git - thirdparty/git.git/blame - pack-bitmap.h
Start the 2.46 cycle
[thirdparty/git.git] / pack-bitmap.h
CommitLineData
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 10struct commit;
7c141127 11struct repository;
ef3ca954
EN
12struct rev_info;
13
af26e2a9
DL
14static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'};
15
fff42755 16struct 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
7cc8f971
VM
24#define NEEDS_BITMAP (1u<<22)
25
28cd7306
AC
26/*
27 * The width in bytes of a single triplet in the lookup table
28 * extension:
29 * (commit_pos, offset, xor_row)
30 *
31 * whose fields ar 32-, 64-, 32- bits wide, respectively.
32 */
33#define BITMAP_LOOKUP_TABLE_TRIPLET_WIDTH (16)
34
fff42755 35enum pack_bitmap_opts {
93eb41e2
AC
36 BITMAP_OPT_FULL_DAG = 0x1,
37 BITMAP_OPT_HASH_CACHE = 0x4,
38 BITMAP_OPT_LOOKUP_TABLE = 0x10,
fff42755
VM
39};
40
7cc8f971
VM
41enum pack_bitmap_flags {
42 BITMAP_FLAG_REUSE = 0x1
43};
44
fff42755 45typedef int (*show_reachable_fn)(
20664967 46 const struct object_id *oid,
fff42755
VM
47 enum object_type type,
48 int flags,
49 uint32_t hash,
50 struct packed_git *found_pack,
51 off_t found_offset);
52
3ae5fa07
JT
53struct bitmap_index;
54
5f5ccd95
TB
55struct bitmapped_pack {
56 struct packed_git *p;
57
58 uint32_t bitmap_pos;
59 uint32_t bitmap_nr;
60
61 uint32_t pack_int_id; /* MIDX only */
62};
63
7c141127 64struct bitmap_index *prepare_bitmap_git(struct repository *r);
bfbb60d3 65struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx);
3ae5fa07
JT
66void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
67 uint32_t *trees, uint32_t *blobs, uint32_t *tags);
68void traverse_bitmap_commit_list(struct bitmap_index *,
4eb707eb 69 struct rev_info *revs,
3ae5fa07 70 show_reachable_fn show_reachable);
fff42755 71void test_bitmap_walk(struct rev_info *revs);
dff5e49e 72int test_bitmap_commits(struct repository *r);
a05f02b1 73int test_bitmap_hashes(struct repository *r);
b0afdce5
TB
74
75#define GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL \
76 "GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL"
77
6663ae0a 78struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
9cf68b27 79 int filter_provided_objects);
83296d20
TB
80void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
81 struct bitmapped_pack **packs_out,
82 size_t *packs_nr_out,
af626ac0
TB
83 struct bitmap **reuse_out,
84 int multi_pack_reuse);
3ae5fa07 85int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
d2bc62b1 86 kh_oid_map_t *reused_bitmaps, int show_progress);
f3c23db2 87void free_bitmap_index(struct bitmap_index *);
40d18ff8
JK
88int bitmap_walk_contains(struct bitmap_index *,
89 struct bitmap *bitmap, const struct object_id *oid);
7cc8f971 90
30cdc33f 91/*
5476fb07 92 * After a traversal has been performed by prepare_bitmap_walk(), this can be
30cdc33f
JK
93 * queried to see if a particular object was reachable from any of the
94 * objects flagged as UNINTERESTING.
95 */
3c771448 96int bitmap_has_oid_in_uninteresting(struct bitmap_index *, const struct object_id *oid);
30cdc33f 97
16950f83
JK
98off_t get_disk_usage_from_bitmap(struct bitmap_index *, struct rev_info *);
99
7cc8f971 100void bitmap_writer_show_progress(int show);
57665249 101void bitmap_writer_set_checksum(const unsigned char *sha1);
06af3bba
NTND
102void bitmap_writer_build_type_index(struct packing_data *to_pack,
103 struct pack_idx_entry **index,
104 uint32_t index_nr);
449fa5ee
JK
105uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git,
106 struct packing_data *mapping);
107int rebuild_bitmap(const uint32_t *reposition,
108 struct ewah_bitmap *source,
109 struct bitmap *dest);
98c31f36
TB
110struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git,
111 struct commit *commit);
7cc8f971
VM
112void bitmap_writer_select_commits(struct commit **indexed_commits,
113 unsigned int indexed_commits_nr, int max_bitmaps);
3ba3d062 114int bitmap_writer_build(struct packing_data *to_pack);
7cc8f971
VM
115void bitmap_writer_finish(struct pack_idx_entry **index,
116 uint32_t index_nr,
ae4f07fb
VM
117 const char *filename,
118 uint16_t options);
0f533c72
TB
119char *midx_bitmap_filename(struct multi_pack_index *midx);
120char *pack_bitmap_filename(struct packed_git *p);
121
122int bitmap_is_midx(struct bitmap_index *bitmap_git);
fff42755 123
3f267a11 124const struct string_list *bitmap_preferred_tips(struct repository *r);
711260fd 125int bitmap_is_preferred_refname(struct repository *r, const char *refname);
3f267a11 126
756f1bcd
DS
127int verify_bitmap_files(struct repository *r);
128
fff42755 129#endif