Skip to content

Commit 02a32db

Browse files
bk2204gitster
authored andcommitted
t: allow testing different hash algorithms via environment
To allow developers to run the testsuite with a different algorithm than the default, provide an environment variable, GIT_TEST_DEFAULT_HASH, to specify the algorithm to use. Compute the fixed constants using test_oid. Move the constant initialization down below the point where test-lib-functions.sh is loaded so the functions are defined. Signed-off-by: brian m. carlson <[email protected]> Reviewed-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ceaa4b3 commit 02a32db

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

t/test-lib-functions.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,9 +1417,7 @@ test_set_hash () {
14171417

14181418
# Detect the hash algorithm in use.
14191419
test_detect_hash () {
1420-
# Currently we only support SHA-1, but in the future this function will
1421-
# actually detect the algorithm in use.
1422-
test_hash_algo='sha1'
1420+
test_hash_algo="${GIT_TEST_DEFAULT_HASH:-sha1}"
14231421
}
14241422

14251423
# Load common hash metadata and common placeholder object IDs for use with

t/test-lib.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
452452
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
453453
export EDITOR
454454

455+
GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-sha1}"
456+
export GIT_DEFAULT_HASH
457+
455458
# Tests using GIT_TRACE typically don't want <timestamp> <file>:<line> output
456459
GIT_TRACE_BARE=1
457460
export GIT_TRACE_BARE

0 commit comments

Comments
 (0)