interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / repack.h

180 lines · 5503 bytes Raw Blame History
1#ifndef REPACK_H
2#define REPACK_H
3
4#include "list-objects-filter-options.h"
5#include "string-list.h"
6#include "oidset.h"
7
8struct pack_objects_args {
9 char *window;
10 char *window_memory;
11 char *depth;
12 char *threads;
13 unsigned long max_pack_size;
14 int no_reuse_delta;
15 int no_reuse_object;
16 int quiet;
17 int local;
18 int name_hash_version;
19 int path_walk;
20 int delta_base_offset;
21 int pack_kept_objects;
22 struct list_objects_filter_options filter_options;
23};
24
25#define PACK_OBJECTS_ARGS_INIT { \
26 .delta_base_offset = 1, \
27 .pack_kept_objects = -1, \
28}
29
30struct child_process;
31
32void prepare_pack_objects(struct child_process *cmd,
33 const struct pack_objects_args *args,
34 const char *out);
35void pack_objects_args_release(struct pack_objects_args *args);
36
37void repack_remove_redundant_pack(struct repository *repo, const char *dir_name,
38 const char *base_name,
39 bool wrote_incremental_midx);
40
41struct write_pack_opts {
42 struct pack_objects_args *po_args;
43 const char *destination;
44 const char *packdir;
45 const char *packtmp;
46};
47
48const char *write_pack_opts_pack_prefix(const struct write_pack_opts *opts);
49bool write_pack_opts_is_local(const struct write_pack_opts *opts);
50
51int finish_pack_objects_cmd(const struct git_hash_algo *algop,
52 const struct write_pack_opts *opts,
53 struct child_process *cmd,
54 struct string_list *names);
55
56struct repository;
57struct packed_git;
58
59struct existing_packs {
60 struct repository *repo;
61 struct odb_source *source;
62 struct string_list kept_packs;
63 struct string_list non_kept_packs;
64 struct string_list cruft_packs;
65 struct string_list midx_packs;
66};
67
68#define EXISTING_PACKS_INIT { \
69 .kept_packs = STRING_LIST_INIT_DUP, \
70 .non_kept_packs = STRING_LIST_INIT_DUP, \
71 .cruft_packs = STRING_LIST_INIT_DUP, \
72}
73
74/*
75 * Adds all packs hex strings (pack-$HASH) to either packs->non_kept
76 * or packs->kept based on whether each pack has a corresponding
77 * .keep file or not. Packs without a .keep file are not to be kept
78 * if we are going to pack everything into one file.
79 */
80void existing_packs_collect(struct existing_packs *existing,
81 const struct string_list *extra_keep);
82int existing_packs_has_non_kept(const struct existing_packs *existing);
83int existing_pack_is_marked_for_deletion(struct string_list_item *item);
84void existing_packs_retain_cruft(struct existing_packs *existing,
85 struct packed_git *cruft);
86void existing_packs_mark_for_deletion(struct existing_packs *existing,
87 struct string_list *names);
88void existing_packs_retain_midx_packs(struct existing_packs *existing);
89void existing_packs_remove_redundant(struct existing_packs *existing,
90 const char *packdir,
91 bool wrote_incremental_midx);
92void existing_packs_release(struct existing_packs *existing);
93
94struct generated_pack;
95
96struct generated_pack *generated_pack_populate(const char *name,
97 const char *packtmp);
98int generated_pack_has_ext(const struct generated_pack *pack, const char *ext);
99void generated_pack_install(struct generated_pack *pack, const char *name,
100 const char *packdir, const char *packtmp);
101
102void repack_promisor_objects(struct repository *repo,
103 const struct pack_objects_args *args,
104 struct string_list *names, const char *packtmp,
105 const struct oidset *to_drop);
106
107struct pack_geometry {
108 struct packed_git **pack;
109 uint32_t pack_nr, pack_alloc;
110 uint32_t split;
111
112 struct packed_git **promisor_pack;
113 uint32_t promisor_pack_nr, promisor_pack_alloc;
114 uint32_t promisor_split;
115
116 uint32_t midx_layer_threshold;
117 bool midx_layer_threshold_set;
118 bool midx_tip_rewritten;
119
120 int split_factor;
121};
122
123void pack_geometry_repack_promisors(struct repository *repo,
124 const struct pack_objects_args *args,
125 const struct pack_geometry *geometry,
126 struct string_list *names,
127 const char *packtmp);
128
129void pack_geometry_init(struct pack_geometry *geometry,
130 struct existing_packs *existing,
131 const struct pack_objects_args *args);
132void pack_geometry_split(struct pack_geometry *geometry);
133struct packed_git *pack_geometry_preferred_pack(struct pack_geometry *geometry);
134void pack_geometry_remove_redundant(struct pack_geometry *geometry,
135 struct string_list *names,
136 struct existing_packs *existing,
137 const char *packdir,
138 bool wrote_incremental_midx);
139void pack_geometry_release(struct pack_geometry *geometry);
140
141struct tempfile;
142
143enum repack_write_midx_mode {
144 REPACK_WRITE_MIDX_NONE,
145 REPACK_WRITE_MIDX_DEFAULT,
146 REPACK_WRITE_MIDX_INCREMENTAL,
147};
148
149struct repack_write_midx_opts {
150 struct existing_packs *existing;
151 struct pack_geometry *geometry;
152 struct string_list *names;
153 const char *refs_snapshot;
154 const char *packdir;
155 int show_progress;
156 int write_bitmaps;
157 int midx_must_contain_cruft;
158 int midx_split_factor;
159 int midx_new_layer_threshold;
160 enum repack_write_midx_mode mode;
161};
162
163void midx_snapshot_refs(struct repository *repo, struct tempfile *f);
164int repack_write_midx(struct repack_write_midx_opts *opts);
165
166int write_filtered_pack(const struct write_pack_opts *opts,
167 struct existing_packs *existing,
168 struct string_list *names);
169
170int enumerate_promisor_blobs(struct repository *repo,
171 const struct list_objects_filter_options *filter,
172 struct oidset *to_drop);
173
174int write_cruft_pack(const struct write_pack_opts *opts,
175 const char *cruft_expiration,
176 unsigned long combine_cruft_below_size,
177 struct string_list *names,
178 struct existing_packs *existing);
179
180#endif /* REPACK_H */