Skip to content

Commit 691b34e

Browse files
bk2204gitster
authored andcommitted
Allow specifying compatibility hash
We want to specify a compatibility hash for testing interactions for SHA-256 repositories where we have SHA-1 compatibility enabled. Allow the user to specify this scenario in the test suite by setting GIT_TEST_DEFAULT_HASH to "sha256:sha1". Note that this will get passed into GIT_DEFAULT_HASH, which Git itself does not presently support. However, we will support this in a future commit. Since we'll now want to know the value for a specific version, let's add the ability to specify either the storage hash (in this case, SHA-256) or the compatibility hash (SHA-1). We use a different value for the compatibility hash that will be enabled for all repositories (test_repo_compat_hash_algo) versus the one that is used individually in some tests (test_compat_hash_algo), since we want to still run those individual tests without requiring that the testsuite be run fully in a compatibility mode. Finally, in this scenario, we can no longer rely on having broken objects work since we lack compatibility mappings to rewrite objects in the repository. Add a prerequisite, BROKEN_OBJECTS, that checks to see if creating deliberately broken objects is possible, so that we can disable these tests if not. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent fa9903f commit 691b34e

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

t/test-lib-functions.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,11 +1708,16 @@ test_set_hash () {
17081708
# Detect the hash algorithm in use.
17091709
test_detect_hash () {
17101710
case "${GIT_TEST_DEFAULT_HASH:-$GIT_TEST_BUILTIN_HASH}" in
1711-
"sha256")
1711+
*:*)
1712+
test_hash_algo="${GIT_TEST_DEFAULT_HASH%%:*}"
1713+
test_compat_hash_algo="${GIT_TEST_DEFAULT_HASH##*:}"
1714+
test_repo_compat_hash_algo="$test_compat_hash_algo"
1715+
;;
1716+
sha256)
17121717
test_hash_algo=sha256
17131718
test_compat_hash_algo=sha1
17141719
;;
1715-
*)
1720+
sha1)
17161721
test_hash_algo=sha1
17171722
test_compat_hash_algo=sha256
17181723
;;

t/test-lib.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,13 @@ test_lazy_prereq DEFAULT_HASH_ALGORITHM '
19171917
test_lazy_prereq DEFAULT_REPO_FORMAT '
19181918
test_have_prereq SHA1,REFFILES
19191919
'
1920+
# BROKEN_OBJECTS is a test if we can write deliberately broken objects and
1921+
# expect them to work. When running using SHA-256 mode with SHA-1
1922+
# compatibility, we cannot write such objects because there's no SHA-1
1923+
# compatibility value for a nonexistent object.
1924+
test_lazy_prereq BROKEN_OBJECTS '
1925+
test -z "$test_repo_compat_hash_algo"
1926+
'
19201927

19211928
# Ensure that no test accidentally triggers a Git command
19221929
# that runs the actual maintenance scheduler, affecting a user's

0 commit comments

Comments
 (0)