t: introduce GIT_TEST_DEFAULT_REF_FORMAT envvar

Introduce a new GIT_TEST_DEFAULT_REF_FORMAT environment variable that lets developers run the test suite with a different default ref format without impacting the ref format used by non-test Git invocations. This is modeled after GIT_TEST_DEFAULT_OBJECT_FORMAT, which does the same thing for the repository's object format. Adapt the setup of the `REFFILES` test prerequisite to be conditionally set based on the default ref format. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Dec 29, 2023 at 08:26 UTC 58aaf59133b4167aefaab6083e80deb369894f79
3 files changed +18 -1
t/README
+3
@@ -479,6 +479,9 @@ GIT_TEST_DEFAULT_HASH=<hash-algo> specifies which hash algorithm to
479 use in the test scripts. Recognized values for <hash-algo> are "sha1"
480 and "sha256".
481
482 +GIT_TEST_DEFAULT_REF_FORMAT=<format> specifies which ref storage format
483 +to use in the test scripts. Recognized values for <format> are "files".
484 +
485 GIT_TEST_NO_WRITE_REV_INDEX=<boolean>, when true disables the
486 'pack.writeReverseIndex' setting.
487
t/test-lib-functions.sh
+5
@@ -1659,6 +1659,11 @@ test_detect_hash () {
1659 test_hash_algo="${GIT_TEST_DEFAULT_HASH:-sha1}"
1660 }
1661
1662 +# Detect the hash algorithm in use.
1663 +test_detect_ref_format () {
1664 + echo "${GIT_TEST_DEFAULT_REF_FORMAT:-files}"
1665 +}
1666 +
1667 # Load common hash metadata and common placeholder object IDs for use with
1668 # test_oid.
1669 test_oid_init () {
t/test-lib.sh
+10 -1
@@ -542,6 +542,8 @@ export EDITOR
542
543 GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-sha1}"
544 export GIT_DEFAULT_HASH
545 +GIT_DEFAULT_REF_FORMAT="${GIT_TEST_DEFAULT_REF_FORMAT:-files}"
546 +export GIT_DEFAULT_REF_FORMAT
547 GIT_TEST_MERGE_ALGORITHM="${GIT_TEST_MERGE_ALGORITHM:-ort}"
548 export GIT_TEST_MERGE_ALGORITHM
549
@@ -1745,7 +1747,14 @@ parisc* | hppa*)
1747 ;;
1748 esac
1749
1748 -test_set_prereq REFFILES
1750 +case "$GIT_DEFAULT_REF_FORMAT" in
1751 +files)
1752 + test_set_prereq REFFILES;;
1753 +*)
1754 + echo 2>&1 "error: unknown ref format $GIT_DEFAULT_REF_FORMAT"
1755 + exit 1
1756 + ;;
1757 +esac
1758
1759 ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
1760 test -z "$NO_CURL" && test_set_prereq LIBCURL