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

[PATCH v2 08/10] pack-bitmap: introduce function to check whether a pack is bitmapped

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 27, 2025, 09:44 UTC
Message-ID
<20250327-pks-cat-file-object-type-filter-v2-8-4bbc7085d7c5@pks.im>
In-Reply-To
<20250327-pks-cat-file-object-type-filter-v2-0-4bbc7085d7c5@pks.im>

Introduce a function that allows us to verify whether a pack is bitmapped or not. This functionality will be used in a subsequent commit.

Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 pack-bitmap.c | 15 +++++++++++++++
 pack-bitmap.h |  7 +++++++
 2 files changed, 22 insertions(+)
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 6adb8aaa1c2..edc8f42122d 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -745,6 +745,21 @@ struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx)
 	return NULL;
 }
 
+int bitmap_index_contains_pack(struct bitmap_index *bitmap, struct packed_git *pack)
+{
+	for (; bitmap; bitmap = bitmap->base) {
+		if (bitmap_is_midx(bitmap)) {
+			for (size_t i = 0; i < bitmap->midx->num_packs; i++)
+				if (bitmap->midx->packs[i] == pack)
+					return 1;
+		} else if (bitmap->pack == pack) {
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
 struct include_data {
 	struct bitmap_index *bitmap_git;
 	struct bitmap *base;
diff --git a/pack-bitmap.h b/pack-bitmap.h
index 079bae32466..55df1b3af5a 100644
--- a/pack-bitmap.h
+++ b/pack-bitmap.h
@@ -67,6 +67,13 @@ struct bitmapped_pack {
 
 struct bitmap_index *prepare_bitmap_git(struct repository *r);
 struct bitmap_index *prepare_midx_bitmap_git(struct multi_pack_index *midx);
+
+/*
+ * Given a bitmap index, determine whether it contains the pack either directly
+ * or via the multi-pack-index.
+ */
+int bitmap_index_contains_pack(struct bitmap_index *bitmap, struct packed_git *pack);
+
 void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
 			      uint32_t *trees, uint32_t *blobs, uint32_t *tags);
 void traverse_bitmap_commit_list(struct bitmap_index *,
-- 
2.49.0.472.ge94155a9ec.dirty
Previous: Patrick SteinhardtNext: Toon Claes
Message 21 of 28 in “builtin/cat-file: allow filtering objects in batch mode”
  1. 00/10 builtin/cat-file: allow filtering objects in batch modePatrick Steinhardt, Mar 27, 2025
  2. 01/10 builtin/cat-file: rename variable that tracks usagePatrick Steinhardt, Mar 27, 2025
  3. Karthik NayakApr 1, 2025
  4. Patrick SteinhardtApr 2, 2025
  5. Junio C HamanoApr 7, 2025
  6. 02/10 builtin/cat-file: wire up an option to filter objectsPatrick Steinhardt, Mar 27, 2025
  7. Toon ClaesApr 1, 2025
  8. Patrick SteinhardtApr 2, 2025
  9. Karthik NayakApr 1, 2025
  10. Patrick SteinhardtApr 2, 2025
  11. 04/10 builtin/cat-file: support "blob:limit=" objects filterPatrick Steinhardt, Mar 27, 2025
  12. 03/10 builtin/cat-file: support "blob:none" objects filterPatrick Steinhardt, Mar 27, 2025
  13. Karthik NayakApr 1, 2025
  14. Karthik NayakApr 1, 2025
  15. Patrick SteinhardtApr 2, 2025
  16. 05/10 builtin/cat-file: support "object:type=" objects filterPatrick Steinhardt, Mar 27, 2025
  17. 06/10 pack-bitmap: allow passing payloads to `show_reachable_fn()`Patrick Steinhardt, Mar 27, 2025
  18. Toon ClaesApr 1, 2025
  19. Patrick SteinhardtApr 2, 2025
  20. 07/10 pack-bitmap: add function to iterate over filtered bitmapped objectsPatrick Steinhardt, Mar 27, 2025
  21. 08/10 pack-bitmap: introduce function to check whether a pack is bitmappedPatrick Steinhardt, Mar 27, 2025
  22. Toon ClaesApr 1, 2025
  23. Patrick SteinhardtApr 2, 2025
  24. 10/10 builtin/cat-file: use bitmaps to efficiently filter by object typePatrick Steinhardt, Mar 27, 2025
  25. 09/10 builtin/cat-file: deduplicate logic to iterate over all objectsPatrick Steinhardt, Mar 27, 2025
  26. Toon ClaesApr 1, 2025
  27. Patrick SteinhardtApr 2, 2025
  28. Toon ClaesApr 3, 2025

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.