4 #include "git-compat-util.h"
16 * A pseudo-merge group tracks the set of non-bitmapped reference tips
17 * that match the given pattern.
19 * Within those matches, they are further segmented by separating
20 * consecutive capture groups with '-' dash character capture groups
21 * with '-' dash characters.
23 * Those groups are then ordered by committer date and partitioned
24 * into individual pseudo-merge(s) according to the decay, max_merges,
25 * sample_rate, and threshold parameters.
27 struct pseudo_merge_group
{
30 /* capture group(s) -> struct pseudo_merge_matches */
31 struct strmap matches
;
34 * The individual pseudo-merge(s) that are generated from the
35 * above array of matches, partitioned according to the below
38 struct commit
**merges
;
43 * Pseudo-merge grouping parameters. See git-config(1) for
50 timestamp_t threshold
;
51 timestamp_t stable_threshold
;
54 struct pseudo_merge_matches
{
55 struct commit
**stable
;
56 struct commit
**unstable
;
57 size_t stable_nr
, stable_alloc
;
58 size_t unstable_nr
, unstable_alloc
;
62 * Read the repository's configuration:
64 * - bitmapPseudoMerge.<name>.pattern
65 * - bitmapPseudoMerge.<name>.decay
66 * - bitmapPseudoMerge.<name>.sampleRate
67 * - bitmapPseudoMerge.<name>.threshold
68 * - bitmapPseudoMerge.<name>.maxMerges
69 * - bitmapPseudoMerge.<name>.stableThreshold
70 * - bitmapPseudoMerge.<name>.stableSize
72 * and populates the given `list` with pseudo-merge groups. String
73 * entry keys are the pseudo-merge group names, and the values are
74 * pointers to the pseudo_merge_group structure itself.
76 void load_pseudo_merges_from_config(struct repository
*r
, struct string_list
*list
);
79 * A pseudo-merge commit index (pseudo_merge_commit_idx) maps a
80 * particular (non-pseudo-merge) commit to the list of pseudo-merge(s)
83 struct pseudo_merge_commit_idx
{
84 uint32_t *pseudo_merge
;
89 * Selects pseudo-merges from a list of commits, populating the given
90 * string_list of pseudo-merge groups.
92 * Populates the pseudo_merge_commits map with a commit_idx
93 * corresponding to each commit in the list. Counts the total number
94 * of pseudo-merges generated.
96 * Optionally shows a progress meter.
98 void select_pseudo_merges(struct bitmap_writer
*writer
);
101 * Represents a serialized view of a file containing pseudo-merge(s)
102 * (see Documentation/technical/bitmap-format.txt for a specification
105 struct pseudo_merge_map
{
107 * An array of pseudo-merge(s), lazily loaded from the .bitmap
110 struct pseudo_merge
*v
;
115 * Pointers into a memory-mapped view of the .bitmap file:
117 * - map: the beginning of the .bitmap file
118 * - commits: the beginning of the pseudo-merge commit index
119 * - map_size: the size of the .bitmap file
121 const unsigned char *map
;
122 const unsigned char *commits
;
128 * An individual pseudo-merge, storing a pair of lazily-loaded
131 * - commits: the set of commit(s) that are part of the pseudo-merge
132 * - bitmap: the set of object(s) reachable from the above set of
135 * The `at` and `bitmap_at` fields are used to store the locations of
136 * each of the above bitmaps in the .bitmap file.
138 struct pseudo_merge
{
139 struct ewah_bitmap
*commits
;
140 struct ewah_bitmap
*bitmap
;
146 * `satisfied` indicates whether the given pseudo-merge has been
149 * `loaded_commits` and `loaded_bitmap` indicate whether the
150 * respective bitmaps have been loaded and read from the
153 unsigned satisfied
: 1,
159 * Frees the given pseudo-merge map, releasing any memory held by (a)
160 * parsed EWAH bitmaps, or (b) the array of pseudo-merges itself. Does
161 * not free the memory-mapped view of the .bitmap file.
163 void free_pseudo_merge_map(struct pseudo_merge_map
*pm
);
166 * Loads the bitmap corresponding to the given pseudo-merge from the
167 * map, if it has not already been loaded.
169 struct ewah_bitmap
*pseudo_merge_bitmap(const struct pseudo_merge_map
*pm
,
170 struct pseudo_merge
*merge
);
173 * Loads the pseudo-merge and its commits bitmap from the given
174 * pseudo-merge map, if it has not already been loaded.
176 struct pseudo_merge
*use_pseudo_merge(const struct pseudo_merge_map
*pm
,
177 struct pseudo_merge
*merge
);
180 * Applies pseudo-merge(s) containing the given commit to the bitmap
183 * If any pseudo-merge(s) were satisfied, returns the number
184 * satisfied, otherwise returns 0. If any were satisfied, the
185 * remaining unsatisfied pseudo-merges are cascaded (see below).
187 int apply_pseudo_merges_for_commit(const struct pseudo_merge_map
*pm
,
188 struct bitmap
*result
,
189 struct commit
*commit
, uint32_t commit_pos
);
192 * Applies pseudo-merge(s) which are satisfied according to the
193 * current bitmap in result (or roots, see below). If any
194 * pseudo-merges were satisfied, repeat the process over unsatisfied
195 * pseudo-merge commits until no more pseudo-merges are satisfied.
197 * Result is the bitmap to which the pseudo-merge(s) are applied.
198 * Roots (if given) is a bitmap of the traversal tip(s) for either
199 * side of a reachability traversal.
201 * Roots may given instead of a populated results bitmap at the
202 * beginning of a traversal on either side where the reachability
203 * closure over tips is not yet known.
205 int cascade_pseudo_merges(const struct pseudo_merge_map
*pm
,
206 struct bitmap
*result
,
207 struct bitmap
*roots
);
210 * Returns a pseudo-merge which contains the exact set of commits
211 * listed in the "parents" bitamp, or NULL if none could be found.
213 struct pseudo_merge
*pseudo_merge_for_parents(const struct pseudo_merge_map
*pm
,
214 struct bitmap
*parents
);