WIP: grep --substitute <substitution> <pattern>
[git/dscho.git] / t / t5703-daemon.sh
blob211ff84a1d42fc75def2fec93035c58f85f08770
1 #!/bin/sh
3 test_description='git daemon and cloning via git:// protocol'
4 . ./test-lib.sh
6 test -z "$GIT_DAEMON_TEST_PORT" && {
7 say "Skipping git-daemon tests."
8 say "Set GIT_DAEMON_TEST_PORT to a port if you want to test it."
9 test_done
10 exit
13 test_expect_success 'setup' '
15 mkdir first &&
16 (cd first &&
17 git init &&
18 echo biomimicry > ted &&
19 git add ted &&
20 test_tick &&
21 git commit -m initial &&
22 git gc)
26 PORT=$GIT_DAEMON_TEST_PORT
28 stop_daemon () {
29 echo "kill $DAEMON_PID"
30 kill "$DAEMON_PID"
33 start_daemon () {
34 trap stop_daemon 0
35 git daemon --base-path="$(pwd)" \
36 --port="$PORT" \
37 --detach \
38 --pid-file=pid-file \
39 -- "$(pwd)/first"
40 DAEMON_PID=$(cat pid-file)
43 test_expect_success 'daemon' '
45 start_daemon &&
46 test -f pid-file
50 test_expect_success 'clone fails without export-ok' '
52 ! git clone git://127.0.0.1:"$PORT"/first second
56 test_expect_success 'clone succeeds with export-ok' '
58 : > first/.git/git-daemon-export-ok &&
59 git clone git://127.0.0.1:"$PORT"/first second &&
60 for f in refs/heads/master objects/pack/*.pack
62 cmp first/.git/$f second/.git/$f || break
63 done
67 test_expect_success 'stop daemon' stop_daemon
69 test_done