aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Lippincott <spectral@google.com>2025-07-15 18:57:54 +0000
committerJunio C Hamano <gitster@pobox.com>2025-07-15 14:31:09 -0700
commitd79f8c6865862c9a48c095493735923800bcf34b (patch)
treefee45b5332d249aad4219a806a67b431c678770c
parentMerge branch 'bc/use-sha256-by-default-in-3.0' into kl/test-installed-fix (diff)
downloadgit-d79f8c6865862c9a48c095493735923800bcf34b.tar.gz
git-d79f8c6865862c9a48c095493735923800bcf34b.zip
test-lib: respect GIT_TEST_INSTALLED when querying default hash
$GIT_TEST_INSTALLED can be set to use an "installed" git instead of the one from $GIT_BUILD_DIR. This is used by my company's internal test infrastructure, and not using $GIT_TEST_INSTALLED when querying the default hash meant that the tests were failing because the hash was effectively set to the empty string (since git didn't execute). In the two places we attempt to detect/execute git itself prior to overriding everything and putting it in $PATH, use identical logic for identifying the git binary to execute. This also has the effect of including the $X suffix when querying the default hash, but that's not strictly necessary. You don't need to specify .exe when running a binary on Windows, just when testing whether it exists or not. Signed-off-by: Kyle Lippincott <spectral@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--t/test-lib.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 315543f293..d8e0e03552 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -134,7 +134,8 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
################################################################
# It appears that people try to run tests without building...
-"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null
+GIT_BINARY="${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X"
+"$GIT_BINARY" >/dev/null
if test $? != 1
then
if test -n "$GIT_TEST_INSTALLED"
@@ -536,7 +537,7 @@ export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
export EDITOR
-GIT_TEST_BUILTIN_HASH=$("$GIT_BUILD_DIR/git" version --build-options | sed -ne 's/^default-hash: //p')
+GIT_TEST_BUILTIN_HASH=$("$GIT_BINARY" version --build-options | sed -ne 's/^default-hash: //p')
GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-$GIT_TEST_BUILTIN_HASH}"
export GIT_DEFAULT_HASH
GIT_DEFAULT_REF_FORMAT="${GIT_TEST_DEFAULT_REF_FORMAT:-files}"