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

[PATCH v3 1/4] odb/source-packed: extract logic to skip certain packs

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 25, 2026, 09:57 UTC
Message-ID
<20260625-pks-connected-generic-promisor-checks-v3-1-7308f3b9dc44@pks.im>
In-Reply-To
<20260625-pks-connected-generic-promisor-checks-v3-0-7308f3b9dc44@pks.im>

The caller can pass flags that allow them to filter out specific kinds of objects when iterating objects via `odb_for_each_object()`. This only works for "normal" iteration though, as we `BUG()` when the user passes flags and specifies an object prefix.

This limitation will be lifted in the next commit. Prepare for this by extracting the logic that skips certain kinds of packs so that we can easily reuse it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 odb/source-packed.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/odb/source-packed.c b/odb/source-packed.c
index 42c28fba0e..3afc4bf01f 100644
--- a/odb/source-packed.c
+++ b/odb/source-packed.c
@@ -126,6 +126,22 @@ static int match_hash(unsigned len, const unsigned char *a, const unsigned char
 	return 1;
 }
 
+static bool should_exclude_pack(struct packed_git *p, enum odb_for_each_object_flags flags)
+{
+	if ((flags & ODB_FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
+		return true;
+	if ((flags & ODB_FOR_EACH_OBJECT_PROMISOR_ONLY) &&
+	    !p->pack_promisor)
+		return true;
+	if ((flags & ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
+	    p->pack_keep_in_core)
+		return true;
+	if ((flags & ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
+	    p->pack_keep)
+		return true;
+	return false;
+}
+
 static int for_each_prefixed_object_in_midx(
 	struct odb_source_packed *store,
 	struct multi_pack_index *m,
@@ -306,17 +322,9 @@ static int odb_source_packed_for_each_object(struct odb_source *source,
 	for (e = packfile_store_get_packs(packed); e; e = e->next) {
 		struct packed_git *p = e->pack;
 
-		if ((opts->flags & ODB_FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
-			continue;
-		if ((opts->flags & ODB_FOR_EACH_OBJECT_PROMISOR_ONLY) &&
-		    !p->pack_promisor)
-			continue;
-		if ((opts->flags & ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS) &&
-		    p->pack_keep_in_core)
-			continue;
-		if ((opts->flags & ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS) &&
-		    p->pack_keep)
+		if (should_exclude_pack(p, opts->flags))
 			continue;
+
 		if (open_pack_index(p)) {
 			pack_errors = 1;
 			continue;
-- 
2.55.0.rc1.745.g43192e7977.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 20 of 25 in “connected: search promisor objects generically”
  1. 0/3 connected: search promisor objects genericallyPatrick Steinhardt, Jun 22, 2026
  2. 1/3 odb/source-packed: extract logic to skip certain packsPatrick Steinhardt, Jun 22, 2026
  3. Junio C HamanoJun 22, 2026
  4. 2/3 odb/source-packed: support flags when iterating an object prefixPatrick Steinhardt, Jun 22, 2026
  5. 3/3 connected: search promisor objects genericallyPatrick Steinhardt, Jun 22, 2026
  6. Junio C HamanoJun 22, 2026
  7. Patrick SteinhardtJun 24, 2026
  8. Christian CouderJun 23, 2026
  9. Patrick SteinhardtJun 24, 2026
  10. 0/4 connected: search promisor objects genericallyPatrick Steinhardt, Jun 24, 2026
  11. 1/4 odb/source-packed: extract logic to skip certain packsPatrick Steinhardt, Jun 24, 2026
  12. 2/4 odb/source-packed: support flags when iterating an object prefixPatrick Steinhardt, Jun 24, 2026
  13. Christian CouderJun 24, 2026
  14. Patrick SteinhardtJun 25, 2026
  15. 3/4 connected: split out promisor-based connectivity checkPatrick Steinhardt, Jun 24, 2026
  16. 4/4 connected: search promisor objects genericallyPatrick Steinhardt, Jun 24, 2026
  17. Junio C HamanoJun 24, 2026
  18. Patrick SteinhardtJun 25, 2026
  19. 0/4 connected: search promisor objects genericallyPatrick Steinhardt, Jun 25, 2026
  20. 1/4 odb/source-packed: extract logic to skip certain packsPatrick Steinhardt, Jun 25, 2026
  21. 2/4 odb/source-packed: support flags when iterating an object prefixPatrick Steinhardt, Jun 25, 2026
  22. 3/4 connected: split out promisor-based connectivity checkPatrick Steinhardt, Jun 25, 2026
  23. 4/4 connected: search promisor objects genericallyPatrick Steinhardt, Jun 25, 2026
  24. Junio C HamanoJun 25, 2026
  25. Christian CouderJun 26, 2026

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.