Skip to content

Commit 58aaf59

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa19619 commit 58aaf59

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

t/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ GIT_TEST_DEFAULT_HASH=<hash-algo> specifies which hash algorithm to
479479
use in the test scripts. Recognized values for <hash-algo> are "sha1"
480480
and "sha256".
481481

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+
482485
GIT_TEST_NO_WRITE_REV_INDEX=<boolean>, when true disables the
483486
'pack.writeReverseIndex' setting.
484487

t/test-lib-functions.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,11 @@ test_detect_hash () {
16591659
test_hash_algo="${GIT_TEST_DEFAULT_HASH:-sha1}"
16601660
}
16611661

1662+
# Detect the hash algorithm in use.
1663+
test_detect_ref_format () {
1664+
echo "${GIT_TEST_DEFAULT_REF_FORMAT:-files}"
1665+
}
1666+
16621667
# Load common hash metadata and common placeholder object IDs for use with
16631668
# test_oid.
16641669
test_oid_init () {

t/test-lib.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ export EDITOR
542542

543543
GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-sha1}"
544544
export GIT_DEFAULT_HASH
545+
GIT_DEFAULT_REF_FORMAT="${GIT_TEST_DEFAULT_REF_FORMAT:-files}"
546+
export GIT_DEFAULT_REF_FORMAT
545547
GIT_TEST_MERGE_ALGORITHM="${GIT_TEST_MERGE_ALGORITHM:-ort}"
546548
export GIT_TEST_MERGE_ALGORITHM
547549

@@ -1745,7 +1747,14 @@ parisc* | hppa*)
17451747
;;
17461748
esac
17471749

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
17491758

17501759
( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
17511760
test -z "$NO_CURL" && test_set_prereq LIBCURL

0 commit comments

Comments
 (0)