Skip to content

Commit 4dd0942

Browse files
committed
Run git-daemon indirectly again but check for instances
1 parent 4aa197b commit 4dd0942

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/helpers.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,17 @@ function small-repo-in-sandbox() {
6060
}
6161

6262
function launch-git-daemon() {
63-
local port=9418 exec_path
63+
local port=9418
6464
if nc -z localhost "$port"; then
6565
echo "Port $port should not have been open before this test's run of the git daemon!" >&2
6666
return 1
6767
fi
68-
exec_path="$(git --exec-path)"
69-
# TODO: Maybe dynamically set the `GIT_CONFIG_*` vars, to accommodate preexisting ones.
70-
GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=uploadpack.allowRefInWant GIT_CONFIG_VALUE_0=true \
71-
"$exec_path/git-daemon" --verbose --base-path=. --export-all --user-path &>/dev/null &
68+
if pgrep git-daemon; then
69+
# TODO: This may be over-broad, as we only need port 9418 (on whatever of 127.0.0.1 and ::1 exist).
70+
echo 'An instance of git-daemon seems to be running already!' >&2
71+
return 1
72+
fi
73+
git -c uploadpack.allowRefInWant=true daemon --verbose --base-path=. --export-all --user-path &>/dev/null &
7274
daemon_pid=$!
7375
while ! nc -z localhost "$port"; do
7476
sleep 0.1

0 commit comments

Comments
 (0)