3 test_description='test git wire-protocol version 2'
9 # Test protocol v2 with 'git://' transport
11 . "$TEST_DIRECTORY"/lib-git-daemon.sh
12 start_git_daemon --export-all --enable=receive-pack
13 daemon_parent=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent
15 test_expect_success 'create repo to be served by git-daemon' '
16 git init "$daemon_parent" &&
17 test_commit -C "$daemon_parent" one
20 test_expect_success 'list refs with git:// using protocol v2' '
21 GIT_TRACE_PACKET=1 git -c protocol.version=2 \
22 ls-remote --symref "$GIT_DAEMON_URL/parent" >actual 2>log &&
24 # Client requested to use protocol v2
25 grep "git> .*\\\0\\\0version=2\\\0$" log &&
26 # Server responded using protocol v2
27 grep "git< version 2" log &&
29 git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
30 test_cmp actual expect
33 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
34 GIT_TRACE_PACKET=1 git -c protocol.version=2 \
35 ls-remote "$GIT_DAEMON_URL/parent" master 2>log &&
37 grep "ref-pattern master" log &&
38 ! grep "refs/tags/" log
43 # Test protocol v2 with 'file://' transport
45 test_expect_success 'create repo to be served by file:// transport' '
46 git init file_parent &&
47 test_commit -C file_parent one
50 test_expect_success 'list refs with file:// using protocol v2' '
51 GIT_TRACE_PACKET=1 git -c protocol.version=2 \
52 ls-remote --symref "file://$(pwd)/file_parent" >actual 2>log &&
54 # Server responded using protocol v2
55 grep "git< version 2" log &&
57 git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
58 test_cmp actual expect
61 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
62 GIT_TRACE_PACKET=1 git -c protocol.version=2 \
63 ls-remote "file://$(pwd)/file_parent" master 2>log &&
65 grep "ref-pattern master" log &&
66 ! grep "refs/tags/" log