Skip to content

Commit 1dc4f1e

Browse files
ttaylorrgitster
authored andcommitted
midx.c: consider annotated tags during bitmap selection
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a8437f3 commit 1dc4f1e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

midx.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,13 +980,17 @@ static int add_ref_to_pending(const char *refname,
980980
int flag, void *cb_data)
981981
{
982982
struct rev_info *revs = (struct rev_info*)cb_data;
983+
struct object_id peeled;
983984
struct object *object;
984985

985986
if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
986987
warning("symbolic ref is dangling: %s", refname);
987988
return 0;
988989
}
989990

991+
if (!peel_iterated_oid(oid, &peeled))
992+
oid = &peeled;
993+
990994
object = parse_object_or_die(oid, refname);
991995
if (object->type != OBJ_COMMIT)
992996
return 0;

t/t5326-multi-pack-bitmaps.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,28 @@ test_expect_success 'preferred pack change with existing MIDX bitmap' '
410410
)
411411
'
412412

413+
test_expect_success 'tagged commits are selected for bitmapping' '
414+
rm -fr repo &&
415+
git init repo &&
416+
test_when_finished "rm -fr repo" &&
417+
(
418+
cd repo &&
419+
420+
test_commit --annotate base &&
421+
git repack -d &&
422+
423+
# Remove refs/heads/main which points at the commit directly,
424+
# leaving only a reference to the annotated tag.
425+
git branch -M main &&
426+
git checkout base &&
427+
git branch -d main &&
428+
429+
git multi-pack-index write --bitmap &&
430+
431+
git rev-parse HEAD >want &&
432+
test-tool bitmap list-commits >actual &&
433+
grep $(cat want) actual
434+
)
435+
'
436+
413437
test_done

0 commit comments

Comments
 (0)