refs API: add a version of refs_resolve_ref_unsafe() with "errno"
[git/debian.git] / pack-bitmap.h
blobed46d27077f7fb3dfd4f698da1c29f9e5748d665
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;
13 struct list_objects_filter_options;
15 static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'};
17 struct bitmap_disk_header {
18 char magic[ARRAY_SIZE(BITMAP_IDX_SIGNATURE)];
19 uint16_t version;
20 uint16_t options;
21 uint32_t entry_count;
22 unsigned char checksum[GIT_MAX_RAWSZ];
25 #define NEEDS_BITMAP (1u<<22)
27 enum pack_bitmap_opts {
28 BITMAP_OPT_FULL_DAG = 1,
29 BITMAP_OPT_HASH_CACHE = 4,
32 enum pack_bitmap_flags {
33 BITMAP_FLAG_REUSE = 0x1
36 typedef int (*show_reachable_fn)(
37 const struct object_id *oid,
38 enum object_type type,
39 int flags,
40 uint32_t hash,
41 struct packed_git *found_pack,
42 off_t found_offset);
44 struct bitmap_index;
46 struct bitmap_index *prepare_bitmap_git(struct repository *r);
47 struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx);
48 void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
49 uint32_t *trees, uint32_t *blobs, uint32_t *tags);
50 void traverse_bitmap_commit_list(struct bitmap_index *,
51 struct rev_info *revs,
52 show_reachable_fn show_reachable);
53 void test_bitmap_walk(struct rev_info *revs);
54 int test_bitmap_commits(struct repository *r);
55 int test_bitmap_hashes(struct repository *r);
56 struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
57 struct list_objects_filter_options *filter,
58 int filter_provided_objects);
59 int reuse_partial_packfile_from_bitmap(struct bitmap_index *,
60 struct packed_git **packfile,
61 uint32_t *entries,
62 struct bitmap **reuse_out);
63 int rebuild_existing_bitmaps(struct bitmap_index *, struct packing_data *mapping,
64 kh_oid_map_t *reused_bitmaps, int show_progress);
65 void free_bitmap_index(struct bitmap_index *);
66 int bitmap_walk_contains(struct bitmap_index *,
67 struct bitmap *bitmap, const struct object_id *oid);
70 * After a traversal has been performed by prepare_bitmap_walk(), this can be
71 * queried to see if a particular object was reachable from any of the
72 * objects flagged as UNINTERESTING.
74 int bitmap_has_oid_in_uninteresting(struct bitmap_index *, const struct object_id *oid);
76 off_t get_disk_usage_from_bitmap(struct bitmap_index *, struct rev_info *);
78 void bitmap_writer_show_progress(int show);
79 void bitmap_writer_set_checksum(unsigned char *sha1);
80 void bitmap_writer_build_type_index(struct packing_data *to_pack,
81 struct pack_idx_entry **index,
82 uint32_t index_nr);
83 uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git,
84 struct packing_data *mapping);
85 int rebuild_bitmap(const uint32_t *reposition,
86 struct ewah_bitmap *source,
87 struct bitmap *dest);
88 struct ewah_bitmap *bitmap_for_commit(struct bitmap_index *bitmap_git,
89 struct commit *commit);
90 void bitmap_writer_select_commits(struct commit **indexed_commits,
91 unsigned int indexed_commits_nr, int max_bitmaps);
92 int bitmap_writer_build(struct packing_data *to_pack);
93 void bitmap_writer_finish(struct pack_idx_entry **index,
94 uint32_t index_nr,
95 const char *filename,
96 uint16_t options);
97 char *midx_bitmap_filename(struct multi_pack_index *midx);
98 char *pack_bitmap_filename(struct packed_git *p);
100 int bitmap_is_midx(struct bitmap_index *bitmap_git);
102 const struct string_list *bitmap_preferred_tips(struct repository *r);
103 int bitmap_is_preferred_refname(struct repository *r, const char *refname);
105 #endif