object-store.h: teach for_each_packed_object to ignore kept packs
The next patch will reimplement a function that wants to iterate over packed objects while ignoring packs which are marked as kept (either in-core or on-disk). Teach for_each_packed_object() to ignore all objects from those packs by adding a new flag for each of the "kept" states that a pack can be in. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Aug 29, 2021 at 22:48 UTC
a241878ac7b67b1894c14d3c3e33ed13f11ae253
2 files changed
+12
object-store.h
+6
@@ -455,6 +455,12 @@ enum for_each_object_flags {
455
* Visit objects within a pack in packfile order rather than .idx order
456
*/
457
FOR_EACH_OBJECT_PACK_ORDER = (1<<2),
458
+
459
+ /* Only iterate over packs that are not marked as kept in-core. */
460
+ FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS = (1<<3),
461
+
462
+ /* Only iterate over packs that do not have .keep files. */
463
+ FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),
464
};
465
466
/*
packfile.c
+6
@@ -2205,6 +2205,12 @@ int for_each_packed_object(each_packed_object_fn cb, void *data,
2205
if ((flags & FOR_EACH_OBJECT_PROMISOR_ONLY) &&
2206
!p->pack_promisor)
2207
continue;
2208
+ if ((flags & FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
2209
+ p->pack_keep_in_core)
2210
+ continue;
2211
+ if ((flags & FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
2212
+ p->pack_keep)
2213
+ continue;
2214
if (open_pack_index(p)) {
2215
pack_errors = 1;
2216
continue;