pack-bitmap: implement BLOB_LIMIT filtering
[git] / pack-bitmap.h
1 #ifndef PACK_BITMAP_H
2 #define PACK_BITMAP_H
3
4 #include "ewah/ewok.h"
5 #include "khash.h"
6 #include "pack-objects.h"
7
8 struct commit;
9 struct repository;
10 struct rev_info;
11 struct list_objects_filter_options;
12
13 static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'};
14
15 struct bitmap_disk_header {
16         char magic[ARRAY_SIZE(BITMAP_IDX_SIGNATURE)];
17         uint16_t version;
18         uint16_t options;
19         uint32_t entry_count;
20         unsigned char checksum[GIT_MAX_RAWSZ];
21 };
22
23 #define NEEDS_BITMAP (1u<<22)
24
25 enum pack_bitmap_opts {
26         BITMAP_OPT_FULL_DAG = 1,
27         BITMAP_OPT_HASH_CACHE = 4,
28 };
29
30 enum pack_bitmap_flags {
31         BITMAP_FLAG_REUSE = 0x1
32 };
33
34 typedef int (*show_reachable_fn)(
35         const struct object_id *oid,
36         enum object_type type,
37         int flags,
38         uint32_t hash,
39         struct packed_git *found_pack,
40         off_t found_offset);
41
42 struct bitmap_index;
43
44 struct bitmap_index *prepare_bitmap_git(struct repository *r);
45 void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
46                               uint32_t *trees, uint32_t *blobs, uint32_t *tags);
47 void traverse_bitmap_commit_list(struct bitmap_index *,
48                                  struct rev_info *revs,
49                                  show_reachable_fn show_reachable);
50 void test_bitmap_walk(struct rev_info *revs);
51 struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
52                                          struct list_objects_filter_options *filter);
53 int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
54                                        struct packed_git **packfile,
55                                        uint32_t *entries, off_t *up_to);
56 int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
57                              kh_oid_map_t *reused_bitmaps, int show_progress);
58 void free_bitmap_index(struct bitmap_index *);
59
60 /*
61  * After a traversal has been performed by prepare_bitmap_walk(), this can be
62  * queried to see if a particular object was reachable from any of the
63  * objects flagged as UNINTERESTING.
64  */
65 int bitmap_has_oid_in_uninteresting(struct bitmap_index *, const struct object_id *oid);
66
67 void bitmap_writer_show_progress(int show);
68 void bitmap_writer_set_checksum(unsigned char *sha1);
69 void bitmap_writer_build_type_index(struct packing_data *to_pack,
70                                     struct pack_idx_entry **index,
71                                     uint32_t index_nr);
72 void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack);
73 void bitmap_writer_select_commits(struct commit **indexed_commits,
74                 unsigned int indexed_commits_nr, int max_bitmaps);
75 void bitmap_writer_build(struct packing_data *to_pack);
76 void bitmap_writer_finish(struct pack_idx_entry **index,
77                           uint32_t index_nr,
78                           const char *filename,
79                           uint16_t options);
80
81 #endif