diff --git a/tests/helpers.sh b/tests/helpers.sh index d1be756dac5..95fb18e1fe2 100644 --- a/tests/helpers.sh +++ b/tests/helpers.sh @@ -60,15 +60,17 @@ function small-repo-in-sandbox() { } function launch-git-daemon() { - local port=9418 exec_path + local port=9418 if nc -z localhost "$port"; then echo "Port $port should not have been open before this test's run of the git daemon!" >&2 return 1 fi - exec_path="$(git --exec-path)" - # TODO: Maybe dynamically set the `GIT_CONFIG_*` vars, to accommodate preexisting ones. - GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=uploadpack.allowRefInWant GIT_CONFIG_VALUE_0=true \ - "$exec_path/git-daemon" --verbose --base-path=. --export-all --user-path &>/dev/null & + if pgrep git-daemon; then + # TODO: This may be over-broad, as we only need port 9418 (on whatever of 127.0.0.1 and ::1 exist). + echo 'An instance of git-daemon seems to be running already!' >&2 + return 1 + fi + git -c uploadpack.allowRefInWant=true daemon --verbose --base-path=. --export-all --user-path &>/dev/null & daemon_pid=$! while ! nc -z localhost "$port"; do sleep 0.1