262
const struct object_id *,
263
struct object_info *, unsigned flags);
264
265
+/*
266
+ * Iterate over the files in the loose-object parts of the object
267
+ * directory "path", triggering the following callbacks:
268
+ *
269
+ * - loose_object is called for each loose object we find.
270
+ *
271
+ * - loose_cruft is called for any files that do not appear to be
272
+ * loose objects. Note that we only look in the loose object
273
+ * directories "objects/[0-9a-f]{2}/", so we will not report
274
+ * "objects/foobar" as cruft.
275
+ *
276
+ * - loose_subdir is called for each top-level hashed subdirectory
277
+ * of the object directory (e.g., "$OBJDIR/f0"). It is called
278
+ * after the objects in the directory are processed.
279
+ *
280
+ * Any callback that is NULL will be ignored. Callbacks returning non-zero
281
+ * will end the iteration.
282
+ *
283
+ * In the "buf" variant, "path" is a strbuf which will also be used as a
284
+ * scratch buffer, but restored to its original contents before
285
+ * the function returns.
286
+ */
287
+typedef int each_loose_object_fn(const struct object_id *oid,
288
+ const char *path,
289
+ void *data);
290
+typedef int each_loose_cruft_fn(const char *basename,
291
+ const char *path,
292
+ void *data);
293
+typedef int each_loose_subdir_fn(unsigned int nr,
294
+ const char *path,
295
+ void *data);
296
+int for_each_file_in_obj_subdir(unsigned int subdir_nr,
297
+ struct strbuf *path,
298
+ each_loose_object_fn obj_cb,
299
+ each_loose_cruft_fn cruft_cb,
300
+ each_loose_subdir_fn subdir_cb,
301
+ void *data);
302
+int for_each_loose_file_in_objdir(const char *path,
303
+ each_loose_object_fn obj_cb,
304
+ each_loose_cruft_fn cruft_cb,
305
+ each_loose_subdir_fn subdir_cb,
306
+ void *data);
307
+int for_each_loose_file_in_objdir_buf(struct strbuf *path,
308
+ each_loose_object_fn obj_cb,
309
+ each_loose_cruft_fn cruft_cb,
310
+ each_loose_subdir_fn subdir_cb,
311
+ void *data);
312
+
313
+/* Flags for for_each_*_object() below. */
314
+enum for_each_object_flags {
315
+ /* Iterate only over local objects, not alternates. */
316
+ FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0),
317
+
318
+ /* Only iterate over packs obtained from the promisor remote. */
319
+ FOR_EACH_OBJECT_PROMISOR_ONLY = (1<<1),
320
+
321
+ /*
322
+ * Visit objects within a pack in packfile order rather than .idx order
323
+ */
324
+ FOR_EACH_OBJECT_PACK_ORDER = (1<<2),
325
+};
326
+
327
+/*
328
+ * Iterate over all accessible loose objects without respect to
329
+ * reachability. By default, this includes both local and alternate objects.
330
+ * The order in which objects are visited is unspecified.
331
+ *
332
+ * Any flags specific to packs are ignored.
333
+ */
334
+int for_each_loose_object(each_loose_object_fn, void *,
335
+ enum for_each_object_flags flags);
336
+
337
+/*
338
+ * Iterate over all accessible packed objects without respect to reachability.
339
+ * By default, this includes both local and alternate packs.
340
+ *
341
+ * Note that some objects may appear twice if they are found in multiple packs.
342
+ * Each pack is visited in an unspecified order. By default, objects within a
343
+ * pack are visited in pack-idx order (i.e., sorted by oid).
344
+ */
345
+typedef int each_packed_object_fn(const struct object_id *oid,
346
+ struct packed_git *pack,
347
+ uint32_t pos,
348
+ void *data);
349
+int for_each_object_in_pack(struct packed_git *p,
350
+ each_packed_object_fn, void *data,
351
+ enum for_each_object_flags flags);
352
+int for_each_packed_object(each_packed_object_fn, void *,
353
+ enum for_each_object_flags flags);
354
+
355
#endif /* OBJECT_STORE_H */