test-lib-functions: move function to lib-bitmap.sh

Move a function added to test-lib-functions.sh in ea047a8eb4f (t5310: factor out bitmap traversal comparison, 2020-02-14) into a new lib-bitmap.sh. The test-lib-functions.sh file should be for functions that are widely used across the test suite, if something's only used by a few tests it makes more sense to have it in a lib-*.sh file. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Feb 9, 2021 at 22:41 UTC ddfe900612119e4e8c21c812a0ced4a72e5d66b7
4 files changed +29 -27
t/lib-bitmap.sh new
+26
@@ -0,0 +1,26 @@
1 +# Compare a file containing rev-list bitmap traversal output to its non-bitmap
2 +# counterpart. You can't just use test_cmp for this, because the two produce
3 +# subtly different output:
4 +#
5 +# - regular output is in traversal order, whereas bitmap is split by type,
6 +# with non-packed objects at the end
7 +#
8 +# - regular output has a space and the pathname appended to non-commit
9 +# objects; bitmap output omits this
10 +#
11 +# This function normalizes and compares the two. The second file should
12 +# always be the bitmap output.
13 +test_bitmap_traversal () {
14 + if test "$1" = "--no-confirm-bitmaps"
15 + then
16 + shift
17 + elif cmp "$1" "$2"
18 + then
19 + echo >&2 "identical raw outputs; are you sure bitmaps were used?"
20 + return 1
21 + fi &&
22 + cut -d' ' -f1 "$1" | sort >"$1.normalized" &&
23 + sort "$2" >"$2.normalized" &&
24 + test_cmp "$1.normalized" "$2.normalized" &&
25 + rm -f "$1.normalized" "$2.normalized"
26 +}
t/t5310-pack-bitmaps.sh
+2
@@ -5,6 +5,8 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7 . ./test-lib.sh
8 +. "$TEST_DIRECTORY"/lib-bundle.sh
9 +. "$TEST_DIRECTORY"/lib-bitmap.sh
10
11 objpath () {
12 echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"
t/t6113-rev-list-bitmap-filters.sh
+1
@@ -2,6 +2,7 @@
2
3 test_description='rev-list combining bitmaps and filters'
4 . ./test-lib.sh
5 +. "$TEST_DIRECTORY"/lib-bitmap.sh
6
7 test_expect_success 'set up bitmapped repo' '
8 # one commit will have bitmaps, the other will not
t/test-lib-functions.sh
-27
@@ -1602,33 +1602,6 @@ test_set_port () {
1602 eval $var=$port
1603 }
1604
1605 -# Compare a file containing rev-list bitmap traversal output to its non-bitmap
1606 -# counterpart. You can't just use test_cmp for this, because the two produce
1607 -# subtly different output:
1608 -#
1609 -# - regular output is in traversal order, whereas bitmap is split by type,
1610 -# with non-packed objects at the end
1611 -#
1612 -# - regular output has a space and the pathname appended to non-commit
1613 -# objects; bitmap output omits this
1614 -#
1615 -# This function normalizes and compares the two. The second file should
1616 -# always be the bitmap output.
1617 -test_bitmap_traversal () {
1618 - if test "$1" = "--no-confirm-bitmaps"
1619 - then
1620 - shift
1621 - elif cmp "$1" "$2"
1622 - then
1623 - echo >&2 "identical raw outputs; are you sure bitmaps were used?"
1624 - return 1
1625 - fi &&
1626 - cut -d' ' -f1 "$1" | sort >"$1.normalized" &&
1627 - sort "$2" >"$2.normalized" &&
1628 - test_cmp "$1.normalized" "$2.normalized" &&
1629 - rm -f "$1.normalized" "$2.normalized"
1630 -}
1631 -
1605 # Tests for the hidden file attribute on Windows
1606 test_path_is_hidden () {
1607 test_have_prereq MINGW ||