Files
git/t/lib-git-daemon.sh
Clemens Buchacher 4c96c7aab7 git-daemon wrapper to wait until daemon is ready
The shell script which is currently used to parse git daemon output does
not seem to work reliably. In order to work around such issues,
re-implement the same procedure in C and write the daemon pid to a file.

This means that we can no longer wait on the daemon process, since it is
no longer a direct child of the shell process.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-19 07:55:13 -07:00

48 lines
1022 B
Bash

#!/bin/sh
if test -z "$GIT_TEST_GIT_DAEMON"
then
skip_all="git-daemon testing disabled (define GIT_TEST_GIT_DAEMON to enable)"
test_done
fi
LIB_GIT_DAEMON_PORT=${LIB_GIT_DAEMON_PORT-'8121'}
GIT_DAEMON_PID=
GIT_DAEMON_DOCUMENT_ROOT_PATH="$PWD"/repo
GIT_DAEMON_URL=git://127.0.0.1:$LIB_GIT_DAEMON_PORT
start_git_daemon() {
if test -n "$GIT_DAEMON_PID"
then
error "start_git_daemon already called"
fi
mkdir -p "$GIT_DAEMON_DOCUMENT_ROOT_PATH"
trap 'code=$?; stop_git_daemon; (exit $code); die' EXIT
say >&3 "Starting git daemon ..."
test-git-daemon --listen=127.0.0.1 --port="$LIB_GIT_DAEMON_PORT" \
--reuseaddr --verbose \
--base-path="$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
"$@" "$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
>&3 2>&4 ||
error "git daemon failed to start"
GIT_DAEMON_PID=$(cat git-daemon.pid)
}
stop_git_daemon() {
if test -z "$GIT_DAEMON_PID"
then
return
fi
trap 'die' EXIT
# kill git-daemon child of git
say >&3 "Stopping git daemon ..."
kill "$GIT_DAEMON_PID"
GIT_DAEMON_PID=
}