git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] object-store.h: teach for_each_packed_object to ignore kept packs

From
Taylor Blau <me@ttaylorr.com>
Date
Aug 30, 2021, 02:48 UTC
Message-ID
<30df4374db583796389c64461c93730eb0a5aa89.1630291682.git.me@ttaylorr.com>
In-Reply-To
<cover.1630291682.git.me@ttaylorr.com>

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>
---
 object-store.h | 6 ++++++
 packfile.c     | 6 ++++++
 2 files changed, 12 insertions(+)
diff --git a/object-store.h b/object-store.h
index d24915ced1..b4dc6668aa 100644
--- a/object-store.h
+++ b/object-store.h
@@ -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),
 };
 
 /*
diff --git a/packfile.c b/packfile.c
index 9ef6d98292..4d0d625238 100644
--- a/packfile.c
+++ b/packfile.c
@@ -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;
-- 
2.33.0.96.g73915697e6
Previous: Taylor BlauNext: Taylor Blau
Message 2 of 9 in “pack-objects: simplify add_objects_in_unpacked_packs()”
  1. 0/3 pack-objects: simplify add_objects_in_unpacked_packs()Taylor Blau, Aug 30, 2021
  2. 1/3 object-store.h: teach for_each_packed_object to ignore kept packsTaylor Blau, Aug 30, 2021
  3. 2/3 builtin/pack-objects.c: simplify add_objects_in_unpacked_packs()Taylor Blau, Aug 30, 2021
  4. Jeff KingSep 2, 2021
  5. Taylor BlauSep 3, 2021
  6. 3/3 builtin/pack-objects.c: remove duplicate hash lookupTaylor Blau, Aug 30, 2021
  7. Junio C HamanoAug 30, 2021
  8. Jeff KingAug 30, 2021
  9. Taylor BlauAug 30, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.