Blame


1 301e83b3 2022-10-16 stsp /*
2 301e83b3 2022-10-16 stsp * Copyright (c) 2020 Ori Bernstein
3 301e83b3 2022-10-16 stsp * Copyright (c) 2021, 2022 Stefan Sperling <stsp@openbsd.org>
4 301e83b3 2022-10-16 stsp *
5 301e83b3 2022-10-16 stsp * Permission to use, copy, modify, and distribute this software for any
6 301e83b3 2022-10-16 stsp * purpose with or without fee is hereby granted, provided that the above
7 301e83b3 2022-10-16 stsp * copyright notice and this permission notice appear in all copies.
8 301e83b3 2022-10-16 stsp *
9 301e83b3 2022-10-16 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 301e83b3 2022-10-16 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 301e83b3 2022-10-16 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 301e83b3 2022-10-16 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 301e83b3 2022-10-16 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 301e83b3 2022-10-16 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 301e83b3 2022-10-16 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 301e83b3 2022-10-16 stsp */
17 301e83b3 2022-10-16 stsp
18 301e83b3 2022-10-16 stsp #include <sys/types.h>
19 301e83b3 2022-10-16 stsp #include <sys/queue.h>
20 301e83b3 2022-10-16 stsp #include <sys/tree.h>
21 301e83b3 2022-10-16 stsp #include <sys/uio.h>
22 301e83b3 2022-10-16 stsp
23 301e83b3 2022-10-16 stsp #include <sha1.h>
24 5822e79e 2023-02-23 op #include <sha2.h>
25 301e83b3 2022-10-16 stsp #include <limits.h>
26 301e83b3 2022-10-16 stsp #include <stdio.h>
27 301e83b3 2022-10-16 stsp #include <stdint.h>
28 301e83b3 2022-10-16 stsp #include <stdlib.h>
29 301e83b3 2022-10-16 stsp #include <string.h>
30 cae60ab8 2022-10-18 stsp #include <time.h>
31 301e83b3 2022-10-16 stsp #include <imsg.h>
32 301e83b3 2022-10-16 stsp #include <inttypes.h>
33 301e83b3 2022-10-16 stsp #include <unistd.h>
34 301e83b3 2022-10-16 stsp
35 301e83b3 2022-10-16 stsp #include "got_error.h"
36 301e83b3 2022-10-16 stsp #include "got_cancel.h"
37 301e83b3 2022-10-16 stsp #include "got_object.h"
38 301e83b3 2022-10-16 stsp #include "got_reference.h"
39 301e83b3 2022-10-16 stsp #include "got_repository_admin.h"
40 301e83b3 2022-10-16 stsp #include "got_path.h"
41 301e83b3 2022-10-16 stsp
42 301e83b3 2022-10-16 stsp #include "got_lib_delta.h"
43 301e83b3 2022-10-16 stsp #include "got_lib_object.h"
44 301e83b3 2022-10-16 stsp #include "got_lib_object_cache.h"
45 301e83b3 2022-10-16 stsp #include "got_lib_object_idset.h"
46 301e83b3 2022-10-16 stsp #include "got_lib_privsep.h"
47 cae60ab8 2022-10-18 stsp #include "got_lib_ratelimit.h"
48 301e83b3 2022-10-16 stsp #include "got_lib_pack.h"
49 301e83b3 2022-10-16 stsp #include "got_lib_pack_create.h"
50 301e83b3 2022-10-16 stsp #include "got_lib_repository.h"
51 301e83b3 2022-10-16 stsp
52 301e83b3 2022-10-16 stsp struct send_id_arg {
53 301e83b3 2022-10-16 stsp struct imsgbuf *ibuf;
54 301e83b3 2022-10-16 stsp struct got_object_id *ids[GOT_IMSG_OBJ_ID_LIST_MAX_NIDS];
55 301e83b3 2022-10-16 stsp size_t nids;
56 301e83b3 2022-10-16 stsp };
57 301e83b3 2022-10-16 stsp
58 301e83b3 2022-10-16 stsp static const struct got_error *
59 301e83b3 2022-10-16 stsp send_id(struct got_object_id *id, void *data, void *arg)
60 301e83b3 2022-10-16 stsp {
61 301e83b3 2022-10-16 stsp const struct got_error *err = NULL;
62 301e83b3 2022-10-16 stsp struct send_id_arg *a = arg;
63 301e83b3 2022-10-16 stsp
64 301e83b3 2022-10-16 stsp a->ids[a->nids++] = id;
65 301e83b3 2022-10-16 stsp
66 301e83b3 2022-10-16 stsp if (a->nids >= GOT_IMSG_OBJ_ID_LIST_MAX_NIDS) {
67 301e83b3 2022-10-16 stsp err = got_privsep_send_object_idlist(a->ibuf, a->ids, a->nids);
68 301e83b3 2022-10-16 stsp if (err)
69 301e83b3 2022-10-16 stsp return err;
70 301e83b3 2022-10-16 stsp a->nids = 0;
71 301e83b3 2022-10-16 stsp }
72 301e83b3 2022-10-16 stsp
73 301e83b3 2022-10-16 stsp return NULL;
74 301e83b3 2022-10-16 stsp }
75 301e83b3 2022-10-16 stsp
76 301e83b3 2022-10-16 stsp static const struct got_error *
77 301e83b3 2022-10-16 stsp send_idset(struct imsgbuf *ibuf, struct got_object_idset *idset)
78 301e83b3 2022-10-16 stsp {
79 301e83b3 2022-10-16 stsp const struct got_error *err;
80 301e83b3 2022-10-16 stsp struct send_id_arg sia;
81 301e83b3 2022-10-16 stsp
82 301e83b3 2022-10-16 stsp memset(&sia, 0, sizeof(sia));
83 301e83b3 2022-10-16 stsp sia.ibuf = ibuf;
84 301e83b3 2022-10-16 stsp err = got_object_idset_for_each(idset, send_id, &sia);
85 301e83b3 2022-10-16 stsp if (err)
86 301e83b3 2022-10-16 stsp return err;
87 301e83b3 2022-10-16 stsp
88 301e83b3 2022-10-16 stsp if (sia.nids > 0) {
89 301e83b3 2022-10-16 stsp err = got_privsep_send_object_idlist(ibuf, sia.ids, sia.nids);
90 301e83b3 2022-10-16 stsp if (err)
91 301e83b3 2022-10-16 stsp return err;
92 301e83b3 2022-10-16 stsp }
93 301e83b3 2022-10-16 stsp
94 301e83b3 2022-10-16 stsp return got_privsep_send_object_idlist_done(ibuf);
95 301e83b3 2022-10-16 stsp }
96 301e83b3 2022-10-16 stsp
97 301e83b3 2022-10-16 stsp static const struct got_error *
98 301e83b3 2022-10-16 stsp recv_reused_delta(struct got_imsg_reused_delta *delta,
99 301e83b3 2022-10-16 stsp struct got_object_idset *idset, struct got_pack_metavec *v)
100 301e83b3 2022-10-16 stsp {
101 301e83b3 2022-10-16 stsp struct got_pack_meta *m, *base;
102 301e83b3 2022-10-16 stsp
103 301e83b3 2022-10-16 stsp if (delta->delta_offset + delta->delta_size < delta->delta_offset ||
104 301e83b3 2022-10-16 stsp delta->delta_offset +
105 301e83b3 2022-10-16 stsp delta->delta_compressed_size < delta->delta_offset)
106 301e83b3 2022-10-16 stsp return got_error(GOT_ERR_BAD_PACKFILE);
107 301e83b3 2022-10-16 stsp
108 301e83b3 2022-10-16 stsp m = got_object_idset_get(idset, &delta->id);
109 301e83b3 2022-10-16 stsp if (m == NULL)
110 301e83b3 2022-10-16 stsp return got_error(GOT_ERR_NO_OBJ);
111 301e83b3 2022-10-16 stsp
112 301e83b3 2022-10-16 stsp base = got_object_idset_get(idset, &delta->base_id);
113 301e83b3 2022-10-16 stsp if (base == NULL)
114 301e83b3 2022-10-16 stsp return got_error(GOT_ERR_NO_OBJ);
115 301e83b3 2022-10-16 stsp
116 301e83b3 2022-10-16 stsp m->delta_len = delta->delta_size;
117 301e83b3 2022-10-16 stsp m->delta_compressed_len = delta->delta_compressed_size;
118 24b7de1c 2022-12-03 stsp m->delta_offset = 0;
119 301e83b3 2022-10-16 stsp m->prev = base;
120 301e83b3 2022-10-16 stsp m->size = delta->result_size;
121 301e83b3 2022-10-16 stsp m->reused_delta_offset = delta->delta_offset;
122 301e83b3 2022-10-16 stsp m->base_obj_id = got_object_id_dup(&delta->base_id);
123 301e83b3 2022-10-16 stsp if (m->base_obj_id == NULL)
124 301e83b3 2022-10-16 stsp return got_error_from_errno("got_object_id_dup");
125 301e83b3 2022-10-16 stsp
126 301e83b3 2022-10-16 stsp return got_pack_add_meta(m, v);
127 301e83b3 2022-10-16 stsp }
128 301e83b3 2022-10-16 stsp
129 301e83b3 2022-10-16 stsp const struct got_error *
130 24b7de1c 2022-12-03 stsp got_pack_search_deltas(struct got_packidx **packidx, struct got_pack **pack,
131 24b7de1c 2022-12-03 stsp struct got_pack_metavec *v, struct got_object_idset *idset,
132 301e83b3 2022-10-16 stsp int ncolored, int nfound, int ntrees, int ncommits,
133 301e83b3 2022-10-16 stsp struct got_repository *repo,
134 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
135 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg)
136 301e83b3 2022-10-16 stsp {
137 301e83b3 2022-10-16 stsp const struct got_error *err = NULL;
138 301e83b3 2022-10-16 stsp struct got_imsg_reused_delta deltas[GOT_IMSG_REUSED_DELTAS_MAX_NDELTAS];
139 301e83b3 2022-10-16 stsp size_t ndeltas, i;
140 301e83b3 2022-10-16 stsp
141 24b7de1c 2022-12-03 stsp *packidx = NULL;
142 24b7de1c 2022-12-03 stsp *pack = NULL;
143 301e83b3 2022-10-16 stsp
144 24b7de1c 2022-12-03 stsp err = got_pack_find_pack_for_reuse(packidx, repo);
145 24b7de1c 2022-12-03 stsp if (err)
146 24b7de1c 2022-12-03 stsp return err;
147 24b7de1c 2022-12-03 stsp
148 24b7de1c 2022-12-03 stsp if (*packidx == NULL)
149 301e83b3 2022-10-16 stsp return NULL;
150 301e83b3 2022-10-16 stsp
151 24b7de1c 2022-12-03 stsp err = got_pack_cache_pack_for_packidx(pack, *packidx, repo);
152 301e83b3 2022-10-16 stsp if (err)
153 24b7de1c 2022-12-03 stsp goto done;
154 301e83b3 2022-10-16 stsp
155 24b7de1c 2022-12-03 stsp if ((*pack)->privsep_child == NULL) {
156 24b7de1c 2022-12-03 stsp err = got_pack_start_privsep_child(*pack, *packidx);
157 301e83b3 2022-10-16 stsp if (err)
158 24b7de1c 2022-12-03 stsp goto done;
159 301e83b3 2022-10-16 stsp }
160 301e83b3 2022-10-16 stsp
161 24b7de1c 2022-12-03 stsp err = got_privsep_send_delta_reuse_req((*pack)->privsep_child->ibuf);
162 301e83b3 2022-10-16 stsp if (err)
163 24b7de1c 2022-12-03 stsp goto done;
164 301e83b3 2022-10-16 stsp
165 24b7de1c 2022-12-03 stsp err = send_idset((*pack)->privsep_child->ibuf, idset);
166 301e83b3 2022-10-16 stsp if (err)
167 24b7de1c 2022-12-03 stsp goto done;
168 301e83b3 2022-10-16 stsp
169 301e83b3 2022-10-16 stsp for (;;) {
170 301e83b3 2022-10-16 stsp int done = 0;
171 301e83b3 2022-10-16 stsp
172 301e83b3 2022-10-16 stsp if (cancel_cb) {
173 301e83b3 2022-10-16 stsp err = (*cancel_cb)(cancel_arg);
174 301e83b3 2022-10-16 stsp if (err)
175 301e83b3 2022-10-16 stsp break;
176 301e83b3 2022-10-16 stsp }
177 301e83b3 2022-10-16 stsp
178 301e83b3 2022-10-16 stsp err = got_privsep_recv_reused_deltas(&done, deltas, &ndeltas,
179 24b7de1c 2022-12-03 stsp (*pack)->privsep_child->ibuf);
180 301e83b3 2022-10-16 stsp if (err || done)
181 301e83b3 2022-10-16 stsp break;
182 301e83b3 2022-10-16 stsp
183 301e83b3 2022-10-16 stsp for (i = 0; i < ndeltas; i++) {
184 301e83b3 2022-10-16 stsp struct got_imsg_reused_delta *delta = &deltas[i];
185 301e83b3 2022-10-16 stsp err = recv_reused_delta(delta, idset, v);
186 301e83b3 2022-10-16 stsp if (err)
187 301e83b3 2022-10-16 stsp goto done;
188 301e83b3 2022-10-16 stsp }
189 301e83b3 2022-10-16 stsp
190 301e83b3 2022-10-16 stsp err = got_pack_report_progress(progress_cb, progress_arg, rl,
191 301e83b3 2022-10-16 stsp ncolored, nfound, ntrees, 0L, ncommits,
192 301e83b3 2022-10-16 stsp got_object_idset_num_elements(idset), v->nmeta, 0);
193 301e83b3 2022-10-16 stsp if (err)
194 301e83b3 2022-10-16 stsp break;
195 301e83b3 2022-10-16 stsp }
196 301e83b3 2022-10-16 stsp done:
197 301e83b3 2022-10-16 stsp return err;
198 301e83b3 2022-10-16 stsp }
199 301e83b3 2022-10-16 stsp
200 301e83b3 2022-10-16 stsp struct recv_painted_commit_arg {
201 301e83b3 2022-10-16 stsp int *ncolored;
202 301e83b3 2022-10-16 stsp int *nqueued;
203 301e83b3 2022-10-16 stsp int *nskip;
204 301e83b3 2022-10-16 stsp struct got_object_id_queue *ids;
205 301e83b3 2022-10-16 stsp struct got_object_idset *keep;
206 301e83b3 2022-10-16 stsp struct got_object_idset *drop;
207 301e83b3 2022-10-16 stsp struct got_object_idset *skip;
208 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb;
209 301e83b3 2022-10-16 stsp void *progress_arg;
210 301e83b3 2022-10-16 stsp struct got_ratelimit *rl;
211 301e83b3 2022-10-16 stsp got_cancel_cb cancel_cb;
212 301e83b3 2022-10-16 stsp void *cancel_arg;
213 301e83b3 2022-10-16 stsp };
214 301e83b3 2022-10-16 stsp
215 301e83b3 2022-10-16 stsp static const struct got_error *
216 301e83b3 2022-10-16 stsp recv_painted_commit(void *arg, struct got_object_id *id, intptr_t color)
217 301e83b3 2022-10-16 stsp {
218 301e83b3 2022-10-16 stsp const struct got_error *err = NULL;
219 301e83b3 2022-10-16 stsp struct recv_painted_commit_arg *a = arg;
220 301e83b3 2022-10-16 stsp struct got_object_qid *qid, *tmp;
221 301e83b3 2022-10-16 stsp
222 301e83b3 2022-10-16 stsp if (a->cancel_cb) {
223 301e83b3 2022-10-16 stsp err = a->cancel_cb(a->cancel_arg);
224 301e83b3 2022-10-16 stsp if (err)
225 301e83b3 2022-10-16 stsp return err;
226 301e83b3 2022-10-16 stsp }
227 301e83b3 2022-10-16 stsp
228 301e83b3 2022-10-16 stsp switch (color) {
229 301e83b3 2022-10-16 stsp case COLOR_KEEP:
230 301e83b3 2022-10-16 stsp err = got_object_idset_add(a->keep, id, NULL);
231 301e83b3 2022-10-16 stsp if (err)
232 301e83b3 2022-10-16 stsp return err;
233 301e83b3 2022-10-16 stsp (*a->ncolored)++;
234 301e83b3 2022-10-16 stsp break;
235 301e83b3 2022-10-16 stsp case COLOR_DROP:
236 301e83b3 2022-10-16 stsp err = got_object_idset_add(a->drop, id, NULL);
237 301e83b3 2022-10-16 stsp if (err)
238 301e83b3 2022-10-16 stsp return err;
239 301e83b3 2022-10-16 stsp (*a->ncolored)++;
240 301e83b3 2022-10-16 stsp break;
241 301e83b3 2022-10-16 stsp case COLOR_SKIP:
242 301e83b3 2022-10-16 stsp err = got_object_idset_add(a->skip, id, NULL);
243 301e83b3 2022-10-16 stsp if (err)
244 301e83b3 2022-10-16 stsp return err;
245 301e83b3 2022-10-16 stsp break;
246 301e83b3 2022-10-16 stsp default:
247 301e83b3 2022-10-16 stsp /* should not happen */
248 301e83b3 2022-10-16 stsp return got_error_fmt(GOT_ERR_NOT_IMPL,
249 301e83b3 2022-10-16 stsp "%s invalid commit color %"PRIdPTR, __func__, color);
250 301e83b3 2022-10-16 stsp }
251 301e83b3 2022-10-16 stsp
252 301e83b3 2022-10-16 stsp STAILQ_FOREACH_SAFE(qid, a->ids, entry, tmp) {
253 301e83b3 2022-10-16 stsp if (got_object_id_cmp(&qid->id, id) != 0)
254 301e83b3 2022-10-16 stsp continue;
255 301e83b3 2022-10-16 stsp STAILQ_REMOVE(a->ids, qid, got_object_qid, entry);
256 301e83b3 2022-10-16 stsp color = (intptr_t)qid->data;
257 301e83b3 2022-10-16 stsp got_object_qid_free(qid);
258 301e83b3 2022-10-16 stsp (*a->nqueued)--;
259 301e83b3 2022-10-16 stsp if (color == COLOR_SKIP)
260 301e83b3 2022-10-16 stsp (*a->nskip)--;
261 301e83b3 2022-10-16 stsp break;
262 301e83b3 2022-10-16 stsp }
263 301e83b3 2022-10-16 stsp
264 301e83b3 2022-10-16 stsp return got_pack_report_progress(a->progress_cb, a->progress_arg, a->rl,
265 301e83b3 2022-10-16 stsp *a->ncolored, 0, 0, 0L, 0, 0, 0, 0);
266 301e83b3 2022-10-16 stsp }
267 301e83b3 2022-10-16 stsp
268 301e83b3 2022-10-16 stsp static const struct got_error *
269 301e83b3 2022-10-16 stsp paint_packed_commits(struct got_pack *pack, struct got_object_id *id,
270 301e83b3 2022-10-16 stsp int idx, intptr_t color, int *ncolored, int *nqueued, int *nskip,
271 301e83b3 2022-10-16 stsp struct got_object_id_queue *ids,
272 301e83b3 2022-10-16 stsp struct got_object_idset *keep, struct got_object_idset *drop,
273 301e83b3 2022-10-16 stsp struct got_object_idset *skip, struct got_repository *repo,
274 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
275 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg)
276 301e83b3 2022-10-16 stsp {
277 301e83b3 2022-10-16 stsp const struct got_error *err = NULL;
278 301e83b3 2022-10-16 stsp struct got_object_id_queue next_ids;
279 301e83b3 2022-10-16 stsp struct got_object_qid *qid, *tmp;
280 301e83b3 2022-10-16 stsp struct recv_painted_commit_arg arg;
281 301e83b3 2022-10-16 stsp
282 301e83b3 2022-10-16 stsp STAILQ_INIT(&next_ids);
283 301e83b3 2022-10-16 stsp
284 301e83b3 2022-10-16 stsp err = got_privsep_send_painting_request(pack->privsep_child->ibuf,
285 301e83b3 2022-10-16 stsp idx, id, color);
286 301e83b3 2022-10-16 stsp if (err)
287 301e83b3 2022-10-16 stsp return err;
288 301e83b3 2022-10-16 stsp
289 301e83b3 2022-10-16 stsp arg.ncolored = ncolored;
290 301e83b3 2022-10-16 stsp arg.nqueued = nqueued;
291 301e83b3 2022-10-16 stsp arg.nskip = nskip;
292 301e83b3 2022-10-16 stsp arg.ids = ids;
293 301e83b3 2022-10-16 stsp arg.keep = keep;
294 301e83b3 2022-10-16 stsp arg.drop = drop;
295 301e83b3 2022-10-16 stsp arg.skip = skip;
296 301e83b3 2022-10-16 stsp arg.progress_cb = progress_cb;
297 301e83b3 2022-10-16 stsp arg.progress_arg = progress_arg;
298 301e83b3 2022-10-16 stsp arg.rl = rl;
299 301e83b3 2022-10-16 stsp arg.cancel_cb = cancel_cb;
300 301e83b3 2022-10-16 stsp arg.cancel_arg = cancel_arg;
301 301e83b3 2022-10-16 stsp err = got_privsep_recv_painted_commits(&next_ids,
302 301e83b3 2022-10-16 stsp recv_painted_commit, &arg, pack->privsep_child->ibuf);
303 301e83b3 2022-10-16 stsp if (err)
304 301e83b3 2022-10-16 stsp return err;
305 301e83b3 2022-10-16 stsp
306 301e83b3 2022-10-16 stsp STAILQ_FOREACH_SAFE(qid, &next_ids, entry, tmp) {
307 301e83b3 2022-10-16 stsp struct got_object_qid *old_id;
308 301e83b3 2022-10-16 stsp intptr_t qcolor, ocolor;
309 301e83b3 2022-10-16 stsp STAILQ_FOREACH(old_id, ids, entry) {
310 301e83b3 2022-10-16 stsp if (got_object_id_cmp(&qid->id, &old_id->id))
311 301e83b3 2022-10-16 stsp continue;
312 301e83b3 2022-10-16 stsp qcolor = (intptr_t)qid->data;
313 301e83b3 2022-10-16 stsp ocolor = (intptr_t)old_id->data;
314 301e83b3 2022-10-16 stsp STAILQ_REMOVE(&next_ids, qid, got_object_qid, entry);
315 301e83b3 2022-10-16 stsp got_object_qid_free(qid);
316 301e83b3 2022-10-16 stsp qid = NULL;
317 301e83b3 2022-10-16 stsp if (qcolor != ocolor) {
318 301e83b3 2022-10-16 stsp got_pack_paint_commit(old_id, qcolor);
319 301e83b3 2022-10-16 stsp if (ocolor == COLOR_SKIP)
320 301e83b3 2022-10-16 stsp (*nskip)--;
321 301e83b3 2022-10-16 stsp else if (qcolor == COLOR_SKIP)
322 301e83b3 2022-10-16 stsp (*nskip)++;
323 301e83b3 2022-10-16 stsp }
324 301e83b3 2022-10-16 stsp break;
325 301e83b3 2022-10-16 stsp }
326 301e83b3 2022-10-16 stsp }
327 301e83b3 2022-10-16 stsp while (!STAILQ_EMPTY(&next_ids)) {
328 301e83b3 2022-10-16 stsp qid = STAILQ_FIRST(&next_ids);
329 301e83b3 2022-10-16 stsp STAILQ_REMOVE_HEAD(&next_ids, entry);
330 301e83b3 2022-10-16 stsp got_pack_paint_commit(qid, color);
331 301e83b3 2022-10-16 stsp STAILQ_INSERT_TAIL(ids, qid, entry);
332 301e83b3 2022-10-16 stsp (*nqueued)++;
333 301e83b3 2022-10-16 stsp if (color == COLOR_SKIP)
334 301e83b3 2022-10-16 stsp (*nskip)++;
335 301e83b3 2022-10-16 stsp }
336 301e83b3 2022-10-16 stsp
337 301e83b3 2022-10-16 stsp return err;
338 301e83b3 2022-10-16 stsp }
339 301e83b3 2022-10-16 stsp
340 301e83b3 2022-10-16 stsp const struct got_error *
341 301e83b3 2022-10-16 stsp got_pack_paint_commits(int *ncolored, struct got_object_id_queue *ids, int nids,
342 301e83b3 2022-10-16 stsp struct got_object_idset *keep, struct got_object_idset *drop,
343 301e83b3 2022-10-16 stsp struct got_object_idset *skip, struct got_repository *repo,
344 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
345 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg)
346 301e83b3 2022-10-16 stsp {
347 301e83b3 2022-10-16 stsp const struct got_error *err = NULL;
348 301e83b3 2022-10-16 stsp struct got_commit_object *commit = NULL;
349 301e83b3 2022-10-16 stsp struct got_packidx *packidx = NULL;
350 301e83b3 2022-10-16 stsp struct got_pack *pack = NULL;
351 301e83b3 2022-10-16 stsp const struct got_object_id_queue *parents;
352 301e83b3 2022-10-16 stsp struct got_object_qid *qid = NULL;
353 301e83b3 2022-10-16 stsp int nqueued = nids, nskip = 0;
354 301e83b3 2022-10-16 stsp int idx;
355 301e83b3 2022-10-16 stsp
356 301e83b3 2022-10-16 stsp while (!STAILQ_EMPTY(ids) && nskip != nqueued) {
357 301e83b3 2022-10-16 stsp intptr_t color;
358 301e83b3 2022-10-16 stsp
359 301e83b3 2022-10-16 stsp if (cancel_cb) {
360 301e83b3 2022-10-16 stsp err = cancel_cb(cancel_arg);
361 301e83b3 2022-10-16 stsp if (err)
362 301e83b3 2022-10-16 stsp break;
363 301e83b3 2022-10-16 stsp }
364 301e83b3 2022-10-16 stsp
365 301e83b3 2022-10-16 stsp qid = STAILQ_FIRST(ids);
366 301e83b3 2022-10-16 stsp STAILQ_REMOVE_HEAD(ids, entry);
367 301e83b3 2022-10-16 stsp nqueued--;
368 301e83b3 2022-10-16 stsp color = (intptr_t)qid->data;
369 301e83b3 2022-10-16 stsp if (color == COLOR_SKIP)
370 301e83b3 2022-10-16 stsp nskip--;
371 301e83b3 2022-10-16 stsp
372 301e83b3 2022-10-16 stsp if (got_object_idset_contains(skip, &qid->id)) {
373 301e83b3 2022-10-16 stsp got_object_qid_free(qid);
374 301e83b3 2022-10-16 stsp qid = NULL;
375 301e83b3 2022-10-16 stsp continue;
376 301e83b3 2022-10-16 stsp }
377 301e83b3 2022-10-16 stsp if (color == COLOR_KEEP &&
378 301e83b3 2022-10-16 stsp got_object_idset_contains(keep, &qid->id)) {
379 301e83b3 2022-10-16 stsp got_object_qid_free(qid);
380 301e83b3 2022-10-16 stsp qid = NULL;
381 301e83b3 2022-10-16 stsp continue;
382 301e83b3 2022-10-16 stsp }
383 301e83b3 2022-10-16 stsp if (color == COLOR_DROP &&
384 301e83b3 2022-10-16 stsp got_object_idset_contains(drop, &qid->id)) {
385 301e83b3 2022-10-16 stsp got_object_qid_free(qid);
386 301e83b3 2022-10-16 stsp qid = NULL;
387 301e83b3 2022-10-16 stsp continue;
388 301e83b3 2022-10-16 stsp }
389 301e83b3 2022-10-16 stsp
390 301e83b3 2022-10-16 stsp /* Pinned pack may have moved to different cache slot. */
391 301e83b3 2022-10-16 stsp pack = got_repo_get_pinned_pack(repo);
392 301e83b3 2022-10-16 stsp
393 301e83b3 2022-10-16 stsp if (packidx && pack) {
394 301e83b3 2022-10-16 stsp idx = got_packidx_get_object_idx(packidx, &qid->id);
395 301e83b3 2022-10-16 stsp if (idx != -1) {
396 301e83b3 2022-10-16 stsp err = paint_packed_commits(pack, &qid->id,
397 301e83b3 2022-10-16 stsp idx, color, ncolored, &nqueued, &nskip,
398 301e83b3 2022-10-16 stsp ids, keep, drop, skip, repo,
399 301e83b3 2022-10-16 stsp progress_cb, progress_arg, rl,
400 301e83b3 2022-10-16 stsp cancel_cb, cancel_arg);
401 301e83b3 2022-10-16 stsp if (err)
402 301e83b3 2022-10-16 stsp break;
403 301e83b3 2022-10-16 stsp got_object_qid_free(qid);
404 301e83b3 2022-10-16 stsp qid = NULL;
405 301e83b3 2022-10-16 stsp continue;
406 301e83b3 2022-10-16 stsp }
407 301e83b3 2022-10-16 stsp }
408 301e83b3 2022-10-16 stsp
409 301e83b3 2022-10-16 stsp switch (color) {
410 301e83b3 2022-10-16 stsp case COLOR_KEEP:
411 301e83b3 2022-10-16 stsp if (got_object_idset_contains(drop, &qid->id)) {
412 301e83b3 2022-10-16 stsp err = got_pack_paint_commit(qid, COLOR_SKIP);
413 301e83b3 2022-10-16 stsp if (err)
414 301e83b3 2022-10-16 stsp goto done;
415 301e83b3 2022-10-16 stsp } else
416 301e83b3 2022-10-16 stsp (*ncolored)++;
417 301e83b3 2022-10-16 stsp err = got_object_idset_add(keep, &qid->id, NULL);
418 301e83b3 2022-10-16 stsp if (err)
419 301e83b3 2022-10-16 stsp goto done;
420 301e83b3 2022-10-16 stsp break;
421 301e83b3 2022-10-16 stsp case COLOR_DROP:
422 301e83b3 2022-10-16 stsp if (got_object_idset_contains(keep, &qid->id)) {
423 301e83b3 2022-10-16 stsp err = got_pack_paint_commit(qid, COLOR_SKIP);
424 301e83b3 2022-10-16 stsp if (err)
425 301e83b3 2022-10-16 stsp goto done;
426 301e83b3 2022-10-16 stsp } else
427 301e83b3 2022-10-16 stsp (*ncolored)++;
428 301e83b3 2022-10-16 stsp err = got_object_idset_add(drop, &qid->id, NULL);
429 301e83b3 2022-10-16 stsp if (err)
430 301e83b3 2022-10-16 stsp goto done;
431 301e83b3 2022-10-16 stsp break;
432 301e83b3 2022-10-16 stsp case COLOR_SKIP:
433 301e83b3 2022-10-16 stsp if (!got_object_idset_contains(skip, &qid->id)) {
434 301e83b3 2022-10-16 stsp err = got_object_idset_add(skip, &qid->id,
435 301e83b3 2022-10-16 stsp NULL);
436 301e83b3 2022-10-16 stsp if (err)
437 301e83b3 2022-10-16 stsp goto done;
438 301e83b3 2022-10-16 stsp }
439 301e83b3 2022-10-16 stsp break;
440 301e83b3 2022-10-16 stsp default:
441 301e83b3 2022-10-16 stsp /* should not happen */
442 301e83b3 2022-10-16 stsp err = got_error_fmt(GOT_ERR_NOT_IMPL,
443 301e83b3 2022-10-16 stsp "%s invalid commit color %"PRIdPTR, __func__,
444 301e83b3 2022-10-16 stsp color);
445 301e83b3 2022-10-16 stsp goto done;
446 301e83b3 2022-10-16 stsp }
447 301e83b3 2022-10-16 stsp
448 301e83b3 2022-10-16 stsp err = got_pack_report_progress(progress_cb, progress_arg, rl,
449 301e83b3 2022-10-16 stsp *ncolored, 0, 0, 0L, 0, 0, 0, 0);
450 301e83b3 2022-10-16 stsp if (err)
451 301e83b3 2022-10-16 stsp break;
452 301e83b3 2022-10-16 stsp
453 301e83b3 2022-10-16 stsp err = got_object_open_as_commit(&commit, repo, &qid->id);
454 301e83b3 2022-10-16 stsp if (err)
455 301e83b3 2022-10-16 stsp break;
456 301e83b3 2022-10-16 stsp
457 301e83b3 2022-10-16 stsp parents = got_object_commit_get_parent_ids(commit);
458 301e83b3 2022-10-16 stsp if (parents) {
459 301e83b3 2022-10-16 stsp struct got_object_qid *pid;
460 301e83b3 2022-10-16 stsp color = (intptr_t)qid->data;
461 301e83b3 2022-10-16 stsp STAILQ_FOREACH(pid, parents, entry) {
462 301e83b3 2022-10-16 stsp err = got_pack_queue_commit_id(ids, &pid->id,
463 301e83b3 2022-10-16 stsp color, repo);
464 301e83b3 2022-10-16 stsp if (err)
465 301e83b3 2022-10-16 stsp break;
466 301e83b3 2022-10-16 stsp nqueued++;
467 301e83b3 2022-10-16 stsp if (color == COLOR_SKIP)
468 301e83b3 2022-10-16 stsp nskip++;
469 301e83b3 2022-10-16 stsp }
470 301e83b3 2022-10-16 stsp }
471 301e83b3 2022-10-16 stsp
472 301e83b3 2022-10-16 stsp if (pack == NULL && (commit->flags & GOT_COMMIT_FLAG_PACKED)) {
473 301e83b3 2022-10-16 stsp if (packidx == NULL) {
474 301e83b3 2022-10-16 stsp err = got_pack_find_pack_for_commit_painting(
475 301e83b3 2022-10-16 stsp &packidx, ids, nqueued, repo);
476 301e83b3 2022-10-16 stsp if (err)
477 301e83b3 2022-10-16 stsp goto done;
478 301e83b3 2022-10-16 stsp }
479 301e83b3 2022-10-16 stsp if (packidx != NULL) {
480 301e83b3 2022-10-16 stsp err = got_pack_cache_pack_for_packidx(&pack,
481 301e83b3 2022-10-16 stsp packidx, repo);
482 301e83b3 2022-10-16 stsp if (err)
483 301e83b3 2022-10-16 stsp goto done;
484 301e83b3 2022-10-16 stsp if (pack->privsep_child == NULL) {
485 301e83b3 2022-10-16 stsp err = got_pack_start_privsep_child(
486 301e83b3 2022-10-16 stsp pack, packidx);
487 301e83b3 2022-10-16 stsp if (err)
488 301e83b3 2022-10-16 stsp goto done;
489 301e83b3 2022-10-16 stsp }
490 301e83b3 2022-10-16 stsp err = got_privsep_init_commit_painting(
491 301e83b3 2022-10-16 stsp pack->privsep_child->ibuf);
492 301e83b3 2022-10-16 stsp if (err)
493 301e83b3 2022-10-16 stsp goto done;
494 301e83b3 2022-10-16 stsp err = send_idset(pack->privsep_child->ibuf,
495 301e83b3 2022-10-16 stsp keep);
496 301e83b3 2022-10-16 stsp if (err)
497 301e83b3 2022-10-16 stsp goto done;
498 301e83b3 2022-10-16 stsp err = send_idset(pack->privsep_child->ibuf, drop);
499 301e83b3 2022-10-16 stsp if (err)
500 301e83b3 2022-10-16 stsp goto done;
501 301e83b3 2022-10-16 stsp err = send_idset(pack->privsep_child->ibuf, skip);
502 301e83b3 2022-10-16 stsp if (err)
503 301e83b3 2022-10-16 stsp goto done;
504 301e83b3 2022-10-16 stsp err = got_repo_pin_pack(repo, packidx, pack);
505 301e83b3 2022-10-16 stsp if (err)
506 301e83b3 2022-10-16 stsp goto done;
507 301e83b3 2022-10-16 stsp }
508 301e83b3 2022-10-16 stsp }
509 301e83b3 2022-10-16 stsp
510 301e83b3 2022-10-16 stsp got_object_commit_close(commit);
511 301e83b3 2022-10-16 stsp commit = NULL;
512 301e83b3 2022-10-16 stsp
513 301e83b3 2022-10-16 stsp got_object_qid_free(qid);
514 301e83b3 2022-10-16 stsp qid = NULL;
515 301e83b3 2022-10-16 stsp }
516 301e83b3 2022-10-16 stsp done:
517 301e83b3 2022-10-16 stsp if (pack) {
518 301e83b3 2022-10-16 stsp const struct got_error *pack_err;
519 301e83b3 2022-10-16 stsp pack_err = got_privsep_send_painting_commits_done(
520 301e83b3 2022-10-16 stsp pack->privsep_child->ibuf);
521 301e83b3 2022-10-16 stsp if (err == NULL)
522 301e83b3 2022-10-16 stsp err = pack_err;
523 301e83b3 2022-10-16 stsp }
524 301e83b3 2022-10-16 stsp if (commit)
525 301e83b3 2022-10-16 stsp got_object_commit_close(commit);
526 301e83b3 2022-10-16 stsp got_object_qid_free(qid);
527 301e83b3 2022-10-16 stsp got_repo_unpin_pack(repo);
528 301e83b3 2022-10-16 stsp return err;
529 301e83b3 2022-10-16 stsp }
530 301e83b3 2022-10-16 stsp
531 301e83b3 2022-10-16 stsp struct load_packed_obj_arg {
532 301e83b3 2022-10-16 stsp /* output parameters: */
533 301e83b3 2022-10-16 stsp struct got_object_id *id;
534 301e83b3 2022-10-16 stsp char *dpath;
535 301e83b3 2022-10-16 stsp time_t mtime;
536 301e83b3 2022-10-16 stsp
537 301e83b3 2022-10-16 stsp /* input parameters: */
538 301e83b3 2022-10-16 stsp uint32_t seed;
539 301e83b3 2022-10-16 stsp int want_meta;
540 301e83b3 2022-10-16 stsp struct got_object_idset *idset;
541 301e83b3 2022-10-16 stsp struct got_object_idset *idset_exclude;
542 301e83b3 2022-10-16 stsp int loose_obj_only;
543 301e83b3 2022-10-16 stsp int *ncolored;
544 301e83b3 2022-10-16 stsp int *nfound;
545 301e83b3 2022-10-16 stsp int *ntrees;
546 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb;
547 301e83b3 2022-10-16 stsp void *progress_arg;
548 301e83b3 2022-10-16 stsp struct got_ratelimit *rl;
549 301e83b3 2022-10-16 stsp got_cancel_cb cancel_cb;
550 301e83b3 2022-10-16 stsp void *cancel_arg;
551 301e83b3 2022-10-16 stsp };
552 301e83b3 2022-10-16 stsp
553 301e83b3 2022-10-16 stsp static const struct got_error *
554 301e83b3 2022-10-16 stsp load_packed_commit_id(void *arg, time_t mtime, struct got_object_id *id,
555 301e83b3 2022-10-16 stsp struct got_repository *repo)
556 301e83b3 2022-10-16 stsp {
557 301e83b3 2022-10-16 stsp struct load_packed_obj_arg *a = arg;
558 301e83b3 2022-10-16 stsp
559 301e83b3 2022-10-16 stsp if (got_object_idset_contains(a->idset, id) ||
560 301e83b3 2022-10-16 stsp got_object_idset_contains(a->idset_exclude, id))
561 301e83b3 2022-10-16 stsp return NULL;
562 301e83b3 2022-10-16 stsp
563 301e83b3 2022-10-16 stsp return got_pack_add_object(a->want_meta,
564 301e83b3 2022-10-16 stsp a->want_meta ? a->idset : a->idset_exclude,
565 301e83b3 2022-10-16 stsp id, "", GOT_OBJ_TYPE_COMMIT, mtime, a->seed, a->loose_obj_only,
566 301e83b3 2022-10-16 stsp repo, a->ncolored, a->nfound, a->ntrees,
567 301e83b3 2022-10-16 stsp a->progress_cb, a->progress_arg, a->rl);
568 301e83b3 2022-10-16 stsp }
569 301e83b3 2022-10-16 stsp
570 301e83b3 2022-10-16 stsp static const struct got_error *
571 301e83b3 2022-10-16 stsp load_packed_tree_ids(void *arg, struct got_tree_object *tree, time_t mtime,
572 301e83b3 2022-10-16 stsp struct got_object_id *id, const char *dpath, struct got_repository *repo)
573 301e83b3 2022-10-16 stsp {
574 301e83b3 2022-10-16 stsp const struct got_error *err;
575 301e83b3 2022-10-16 stsp struct load_packed_obj_arg *a = arg;
576 301e83b3 2022-10-16 stsp const char *relpath;
577 301e83b3 2022-10-16 stsp
578 301e83b3 2022-10-16 stsp /*
579 301e83b3 2022-10-16 stsp * When we receive a tree's ID and path but not the tree itself,
580 301e83b3 2022-10-16 stsp * this tree object was not found in the pack file. This is the
581 301e83b3 2022-10-16 stsp * last time we are being called for this optimized traversal.
582 301e83b3 2022-10-16 stsp * Return from here and switch to loading objects the slow way.
583 301e83b3 2022-10-16 stsp */
584 301e83b3 2022-10-16 stsp if (tree == NULL) {
585 301e83b3 2022-10-16 stsp free(a->id);
586 301e83b3 2022-10-16 stsp a->id = got_object_id_dup(id);
587 301e83b3 2022-10-16 stsp if (a->id == NULL) {
588 301e83b3 2022-10-16 stsp err = got_error_from_errno("got_object_id_dup");
589 301e83b3 2022-10-16 stsp free(a->dpath);
590 301e83b3 2022-10-16 stsp a->dpath = NULL;
591 301e83b3 2022-10-16 stsp return err;
592 301e83b3 2022-10-16 stsp }
593 301e83b3 2022-10-16 stsp
594 301e83b3 2022-10-16 stsp free(a->dpath);
595 301e83b3 2022-10-16 stsp a->dpath = strdup(dpath);
596 301e83b3 2022-10-16 stsp if (a->dpath == NULL) {
597 301e83b3 2022-10-16 stsp err = got_error_from_errno("strdup");
598 301e83b3 2022-10-16 stsp free(a->id);
599 301e83b3 2022-10-16 stsp a->id = NULL;
600 301e83b3 2022-10-16 stsp return err;
601 301e83b3 2022-10-16 stsp }
602 301e83b3 2022-10-16 stsp
603 301e83b3 2022-10-16 stsp a->mtime = mtime;
604 301e83b3 2022-10-16 stsp return NULL;
605 301e83b3 2022-10-16 stsp }
606 301e83b3 2022-10-16 stsp
607 301e83b3 2022-10-16 stsp if (got_object_idset_contains(a->idset, id) ||
608 301e83b3 2022-10-16 stsp got_object_idset_contains(a->idset_exclude, id))
609 301e83b3 2022-10-16 stsp return NULL;
610 301e83b3 2022-10-16 stsp
611 301e83b3 2022-10-16 stsp relpath = dpath;
612 301e83b3 2022-10-16 stsp while (relpath[0] == '/')
613 301e83b3 2022-10-16 stsp relpath++;
614 301e83b3 2022-10-16 stsp
615 301e83b3 2022-10-16 stsp err = got_pack_add_object(a->want_meta,
616 301e83b3 2022-10-16 stsp a->want_meta ? a->idset : a->idset_exclude,
617 301e83b3 2022-10-16 stsp id, relpath, GOT_OBJ_TYPE_TREE, mtime, a->seed,
618 301e83b3 2022-10-16 stsp a->loose_obj_only, repo, a->ncolored, a->nfound, a->ntrees,
619 301e83b3 2022-10-16 stsp a->progress_cb, a->progress_arg, a->rl);
620 301e83b3 2022-10-16 stsp if (err)
621 301e83b3 2022-10-16 stsp return err;
622 301e83b3 2022-10-16 stsp
623 301e83b3 2022-10-16 stsp return got_pack_load_tree_entries(NULL, a->want_meta, a->idset,
624 301e83b3 2022-10-16 stsp a->idset_exclude, tree, dpath, mtime, a->seed, repo,
625 301e83b3 2022-10-16 stsp a->loose_obj_only, a->ncolored, a->nfound, a->ntrees,
626 301e83b3 2022-10-16 stsp a->progress_cb, a->progress_arg, a->rl,
627 301e83b3 2022-10-16 stsp a->cancel_cb, a->cancel_arg);
628 301e83b3 2022-10-16 stsp }
629 301e83b3 2022-10-16 stsp
630 301e83b3 2022-10-16 stsp const struct got_error *
631 301e83b3 2022-10-16 stsp got_pack_load_packed_object_ids(int *found_all_objects,
632 301e83b3 2022-10-16 stsp struct got_object_id **ours, int nours,
633 301e83b3 2022-10-16 stsp struct got_object_id **theirs, int ntheirs,
634 301e83b3 2022-10-16 stsp int want_meta, uint32_t seed, struct got_object_idset *idset,
635 301e83b3 2022-10-16 stsp struct got_object_idset *idset_exclude, int loose_obj_only,
636 301e83b3 2022-10-16 stsp struct got_repository *repo, struct got_packidx *packidx,
637 301e83b3 2022-10-16 stsp int *ncolored, int *nfound, int *ntrees,
638 301e83b3 2022-10-16 stsp got_pack_progress_cb progress_cb, void *progress_arg,
639 301e83b3 2022-10-16 stsp struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg)
640 301e83b3 2022-10-16 stsp {
641 301e83b3 2022-10-16 stsp const struct got_error *err = NULL;
642 301e83b3 2022-10-16 stsp struct load_packed_obj_arg lpa;
643 301e83b3 2022-10-16 stsp
644 301e83b3 2022-10-16 stsp memset(&lpa, 0, sizeof(lpa));
645 301e83b3 2022-10-16 stsp lpa.seed = seed;
646 301e83b3 2022-10-16 stsp lpa.want_meta = want_meta;
647 301e83b3 2022-10-16 stsp lpa.idset = idset;
648 301e83b3 2022-10-16 stsp lpa.idset_exclude = idset_exclude;
649 301e83b3 2022-10-16 stsp lpa.loose_obj_only = loose_obj_only;
650 301e83b3 2022-10-16 stsp lpa.ncolored = ncolored;
651 301e83b3 2022-10-16 stsp lpa.nfound = nfound;
652 301e83b3 2022-10-16 stsp lpa.ntrees = ntrees;
653 301e83b3 2022-10-16 stsp lpa.progress_cb = progress_cb;
654 301e83b3 2022-10-16 stsp lpa.progress_arg = progress_arg;
655 301e83b3 2022-10-16 stsp lpa.rl = rl;
656 301e83b3 2022-10-16 stsp lpa.cancel_cb = cancel_cb;
657 301e83b3 2022-10-16 stsp lpa.cancel_arg = cancel_arg;
658 301e83b3 2022-10-16 stsp
659 301e83b3 2022-10-16 stsp /* Attempt to load objects via got-read-pack, as far as possible. */
660 301e83b3 2022-10-16 stsp err = got_object_enumerate(found_all_objects, load_packed_commit_id,
661 301e83b3 2022-10-16 stsp load_packed_tree_ids, &lpa, ours, nours, theirs, ntheirs,
662 301e83b3 2022-10-16 stsp packidx, repo);
663 301e83b3 2022-10-16 stsp if (err)
664 301e83b3 2022-10-16 stsp return err;
665 301e83b3 2022-10-16 stsp
666 301e83b3 2022-10-16 stsp if (lpa.id == NULL)
667 301e83b3 2022-10-16 stsp return NULL;
668 301e83b3 2022-10-16 stsp
669 301e83b3 2022-10-16 stsp /*
670 301e83b3 2022-10-16 stsp * An incomplete tree hierarchy was present in the pack file
671 301e83b3 2022-10-16 stsp * and caused loading to be aborted.
672 301e83b3 2022-10-16 stsp * Continue loading trees the slow way.
673 301e83b3 2022-10-16 stsp */
674 301e83b3 2022-10-16 stsp err = got_pack_load_tree(want_meta, idset, idset_exclude,
675 301e83b3 2022-10-16 stsp lpa.id, lpa.dpath, lpa.mtime, seed, repo, loose_obj_only,
676 301e83b3 2022-10-16 stsp ncolored, nfound, ntrees, progress_cb, progress_arg, rl,
677 301e83b3 2022-10-16 stsp cancel_cb, cancel_arg);
678 301e83b3 2022-10-16 stsp free(lpa.id);
679 301e83b3 2022-10-16 stsp free(lpa.dpath);
680 301e83b3 2022-10-16 stsp return err;
681 301e83b3 2022-10-16 stsp }