Skip to content

Commit ea047a8

Browse files
peffgitster
authored andcommitted
t5310: factor out bitmap traversal comparison
We check the results of "rev-list --use-bitmap-index" by comparing it to the same traversal without the bitmap option. However, this is a little tricky to do because of some output differences (see the included comment for details). Let's pull this out into a helper function, since we'll be adding some similar tests. While we're at it, let's also try to confirm that the bitmap output did indeed use bitmaps. Since the code internally falls back to the non-bitmap path in some cases, the tests are at risk of becoming trivial noops. This is a bit fragile, as not all outputs will differ (e.g., looking at only the commits from a fully-bitmapped pack will end up exactly the same as the normal traversal order, since it also matches the pack order). So we'll provide an escape hatch by which tests can disable this check (which should only be used after manually confirming that bitmaps kicked in). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 608d9c9 commit ea047a8

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

t/t5310-pack-bitmaps.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,9 @@ rev_list_tests() {
8181
'
8282

8383
test_expect_success "enumerate --objects ($state)" '
84-
git rev-list --objects --use-bitmap-index HEAD >tmp &&
85-
cut -d" " -f1 <tmp >tmp2 &&
86-
sort <tmp2 >actual &&
87-
git rev-list --objects HEAD >tmp &&
88-
cut -d" " -f1 <tmp >tmp2 &&
89-
sort <tmp2 >expect &&
90-
test_cmp expect actual
84+
git rev-list --objects --use-bitmap-index HEAD >actual &&
85+
git rev-list --objects HEAD >expect &&
86+
test_bitmap_traversal expect actual
9187
'
9288

9389
test_expect_success "bitmap --objects handles non-commit objects ($state)" '

t/test-lib-functions.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,3 +1516,30 @@ test_set_port () {
15161516
port=$(($port + ${GIT_TEST_STRESS_JOB_NR:-0}))
15171517
eval $var=$port
15181518
}
1519+
1520+
# Compare a file containing rev-list bitmap traversal output to its non-bitmap
1521+
# counterpart. You can't just use test_cmp for this, because the two produce
1522+
# subtly different output:
1523+
#
1524+
# - regular output is in traversal order, whereas bitmap is split by type,
1525+
# with non-packed objects at the end
1526+
#
1527+
# - regular output has a space and the pathname appended to non-commit
1528+
# objects; bitmap output omits this
1529+
#
1530+
# This function normalizes and compares the two. The second file should
1531+
# always be the bitmap output.
1532+
test_bitmap_traversal () {
1533+
if test "$1" = "--no-confirm-bitmaps"
1534+
then
1535+
shift
1536+
elif cmp "$1" "$2"
1537+
then
1538+
echo >&2 "identical raw outputs; are you sure bitmaps were used?"
1539+
return 1
1540+
fi &&
1541+
cut -d' ' -f1 "$1" | sort >"$1.normalized" &&
1542+
sort "$2" >"$2.normalized" &&
1543+
test_cmp "$1.normalized" "$2.normalized" &&
1544+
rm -f "$1.normalized" "$2.normalized"
1545+
}

0 commit comments

Comments
 (0)