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

[PATCH 2/4] midx.c: consider annotated tags during bitmap selection

From
Taylor Blau <me@ttaylorr.com>
Date
Oct 12, 2022, 22:01 UTC
Message-ID
<b646c9d841aee066c57562a439ac59da47220a93.1665612094.git.me@ttaylorr.com>
In-Reply-To
<cover.1665612094.git.me@ttaylorr.com>

When generating a multi-pack bitmap without a `--refs-snapshot` (e.g., by running `git multi-pack-index write --bitmap` directly), we determine the set of bitmap-able commits by enumerating each reference, and adding the referrent as the tip of a reachability traversal when it appears somewhere in the MIDX. (Any commit we encounter during the reachability traversal then becomes a candidate for bitmap selection).

But we incorrectly avoid peeling the object at the tip of each reference. So if we see some reference that points at an annotated tag (which in turn points through zero or more additional annotated tags at a commit), that we will not add it as a tip for the reachability traversal. This means that if some commit C is only referenced through one or more annotated tag(s), then C won't become a bitmap candidate.

Correct this by peeling the reference tips as we enumerate them to ensure that we consider commits which are the targets of annotated tags, in addition to commits which are referenced directly.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 midx.c                        |  4 ++++
 t/t5326-multi-pack-bitmaps.sh | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
diff --git a/midx.c b/midx.c
index a9df753220..d41dfd8174 100644
--- a/midx.c
+++ b/midx.c
@@ -980,6 +980,7 @@ static int add_ref_to_pending(const char *refname,
 			      int flag, void *cb_data)
 {
 	struct rev_info *revs = (struct rev_info*)cb_data;
+	struct object_id peeled;
 	struct object *object;
 
 	if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
@@ -987,6 +988,9 @@ static int add_ref_to_pending(const char *refname,
 		return 0;
 	}
 
+	if (!peel_iterated_oid(oid, &peeled))
+		oid = &peeled;
+
 	object = parse_object_or_die(oid, refname);
 	if (object->type != OBJ_COMMIT)
 		return 0;
diff --git a/t/t5326-multi-pack-bitmaps.sh b/t/t5326-multi-pack-bitmaps.sh
index ad6eea5fa0..0882cbb6e4 100755
--- a/t/t5326-multi-pack-bitmaps.sh
+++ b/t/t5326-multi-pack-bitmaps.sh
@@ -410,4 +410,28 @@ test_expect_success 'preferred pack change with existing MIDX bitmap' '
 	)
 '
 
+test_expect_success 'tagged commits are selected for bitmapping' '
+	rm -fr repo &&
+	git init repo &&
+	test_when_finished "rm -fr repo" &&
+	(
+		cd repo &&
+
+		test_commit --annotate base &&
+		git repack -d &&
+
+		# Remove refs/heads/main which points at the commit directly,
+		# leaving only a reference to the annotated tag.
+		git branch -M main &&
+		git checkout base &&
+		git branch -d main &&
+
+		git multi-pack-index write --bitmap &&
+
+		git rev-parse HEAD >want &&
+		test-tool bitmap list-commits >actual &&
+		grep $(cat want) actual
+	)
+'
+
 test_done
-- 
2.38.0.16.g393fd4c6db
Previous: Taylor BlauNext: Taylor Blau
Message 3 of 7 in “midx: trace2 regions and grab-bag patches”
  1. 0/4 midx: trace2 regions and grab-bag patchesTaylor Blau, Oct 12, 2022
  2. 1/4 midx.c: fix whitespace typoTaylor Blau, Oct 12, 2022
  3. 2/4 midx.c: consider annotated tags during bitmap selectionTaylor Blau, Oct 12, 2022
  4. 3/4 midx.c: instrument MIDX and bitmap generation with trace2 regionsTaylor Blau, Oct 12, 2022
  5. 4/4 pack-bitmap-write.c: instrument number of reused bitmapsTaylor Blau, Oct 12, 2022
  6. Derrick StoleeOct 13, 2022
  7. Junio C HamanoOct 13, 2022

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.