Skip to content

Commit

Permalink
Run git-daemon indirectly again but check for instances
Browse files Browse the repository at this point in the history
  • Loading branch information
EliahKagan committed Dec 17, 2024
1 parent 4aa197b commit 4dd0942
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4dd0942

Please sign in to comment.