pack-objects: reuse on-disk deltas for thin "have" objects
[git/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"
7cc8f971 6#include "pack-objects.h"
fff42755 7
ef3ca954
EN
8struct commit;
9struct rev_info;
10
fff42755
VM
11struct bitmap_disk_header {
12 char magic[4];
13 uint16_t version;
14 uint16_t options;
15 uint32_t entry_count;
16 unsigned char checksum[20];
17};
18
19static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'};
20
7cc8f971
VM
21#define NEEDS_BITMAP (1u<<22)
22
fff42755 23enum pack_bitmap_opts {
ae4f07fb
VM
24 BITMAP_OPT_FULL_DAG = 1,
25 BITMAP_OPT_HASH_CACHE = 4,
fff42755
VM
26};
27
7cc8f971
VM
28enum pack_bitmap_flags {
29 BITMAP_FLAG_REUSE = 0x1
30};
31
fff42755 32typedef int (*show_reachable_fn)(
20664967 33 const struct object_id *oid,
fff42755
VM
34 enum object_type type,
35 int flags,
36 uint32_t hash,
37 struct packed_git *found_pack,
38 off_t found_offset);
39
3ae5fa07
JT
40struct bitmap_index;
41
42struct bitmap_index *prepare_bitmap_git(void);
43void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
44 uint32_t *trees, uint32_t *blobs, uint32_t *tags);
45void traverse_bitmap_commit_list(struct bitmap_index *,
46 show_reachable_fn show_reachable);
fff42755 47void test_bitmap_walk(struct rev_info *revs);
3ae5fa07
JT
48struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs);
49int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
50 struct packed_git **packfile,
51 uint32_t *entries, off_t *up_to);
52int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
53 khash_sha1 *reused_bitmaps, int show_progress);
f3c23db2 54void free_bitmap_index(struct bitmap_index *);
7cc8f971 55
30cdc33f
JK
56/*
57 * After a traversal has been performed on the bitmap_index, this can be
58 * queried to see if a particular object was reachable from any of the
59 * objects flagged as UNINTERESTING.
60 */
61int bitmap_has_sha1_in_uninteresting(struct bitmap_index *, const unsigned char *sha1);
62
7cc8f971
VM
63void bitmap_writer_show_progress(int show);
64void bitmap_writer_set_checksum(unsigned char *sha1);
06af3bba
NTND
65void bitmap_writer_build_type_index(struct packing_data *to_pack,
66 struct pack_idx_entry **index,
67 uint32_t index_nr);
7cc8f971
VM
68void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack);
69void bitmap_writer_select_commits(struct commit **indexed_commits,
70 unsigned int indexed_commits_nr, int max_bitmaps);
71void bitmap_writer_build(struct packing_data *to_pack);
72void bitmap_writer_finish(struct pack_idx_entry **index,
73 uint32_t index_nr,
ae4f07fb
VM
74 const char *filename,
75 uint16_t options);
fff42755
VM
76
77#endif