reset: support "--mixed --intent-to-add" mode
[gitweb.git] / t / lib-git-daemon.sh
index ef2d01f36939199f9720faad06d2b3a01c7cd7f5..394b06b32f838463221e9c2f49380fd9eb08bb9d 100644 (file)
@@ -1,4 +1,20 @@
-#!/bin/sh
+# Shell library to run git-daemon in tests.  Ends the test early if
+# GIT_TEST_GIT_DAEMON is not set.
+#
+# Usage:
+#
+#      . ./test-lib.sh
+#      . "$TEST_DIRECTORY"/lib-git-daemon.sh
+#      start_git_daemon
+#
+#      test_expect_success '...' '
+#              ...
+#      '
+#
+#      test_expect_success ...
+#
+#      stop_git_daemon
+#      test_done
 
 if test -z "$GIT_TEST_GIT_DAEMON"
 then
@@ -31,19 +47,19 @@ start_git_daemon() {
                >&3 2>git_daemon_output &
        GIT_DAEMON_PID=$!
        {
-               read line
+               read line <&7
                echo >&4 "$line"
-               cat >&4 &
+               cat <&7 >&4 &
+       } 7<git_daemon_output &&
 
-               # Check expected output
-               if test x"$(expr "$line" : "\[[0-9]*\] \(.*\)")" != x"Ready to rumble"
-               then
-                       kill "$GIT_DAEMON_PID"
-                       wait "$GIT_DAEMON_PID"
-                       trap 'die' EXIT
-                       error "git daemon failed to start"
-               fi
-       } <git_daemon_output
+       # Check expected output
+       if test x"$(expr "$line" : "\[[0-9]*\] \(.*\)")" != x"Ready to rumble"
+       then
+               kill "$GIT_DAEMON_PID"
+               wait "$GIT_DAEMON_PID"
+               trap 'die' EXIT
+               error "git daemon failed to start"
+       fi
 }
 
 stop_git_daemon() {