]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-store.h: teach for_each_packed_object to ignore kept packs
authorTaylor Blau <me@ttaylorr.com>
Mon, 30 Aug 2021 02:48:52 +0000 (22:48 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Aug 2021 06:23:39 +0000 (23:23 -0700)
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>
object-store.h
packfile.c

index d24915ced1b2dd2aedb8300741d83372d9ea53a0..b4dc6668aa281d64774998a70c02ee02da8b6696 100644 (file)
@@ -455,6 +455,12 @@ enum for_each_object_flags {
         * Visit objects within a pack in packfile order rather than .idx order
         */
        FOR_EACH_OBJECT_PACK_ORDER = (1<<2),
+
+       /* Only iterate over packs that are not marked as kept in-core. */
+       FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS = (1<<3),
+
+       /* Only iterate over packs that do not have .keep files. */
+       FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),
 };
 
 /*
index 9ef6d98292808718dfadc3b9efec0fb0dc2275f5..4d0d625238e934fa7e627840dca4e9a2809acacb 100644 (file)
@@ -2205,6 +2205,12 @@ int for_each_packed_object(each_packed_object_fn cb, void *data,
                if ((flags & FOR_EACH_OBJECT_PROMISOR_ONLY) &&
                    !p->pack_promisor)
                        continue;
+               if ((flags & FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
+                   p->pack_keep_in_core)
+                       continue;
+               if ((flags & FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
+                   p->pack_keep)
+                       continue;
                if (open_pack_index(p)) {
                        pack_errors = 1;
                        continue;