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
41 test_expect_success 'clone with git:// using protocol v2' '
42 GIT_TRACE_PACKET=1 git -c protocol.version=2 \
43 clone "$GIT_DAEMON_URL/parent" daemon_child 2>log &&
45 git -C daemon_child log -1 --format=%s >actual &&
46 git -C "$daemon_parent" log -1 --format=%s >expect &&
47 test_cmp expect actual &&
49 # Client requested to use protocol v2
50 grep "clone> .*\\\0\\\0version=2\\\0$" log &&
51 # Server responded using protocol v2
52 grep "clone< version 2" log
55 test_expect_success 'fetch with git:// using protocol v2' '
56 test_commit -C "$daemon_parent" two &&
58 GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=2 \
61 git -C daemon_child log -1 --format=%s origin/master >actual &&
62 git -C "$daemon_parent" log -1 --format=%s >expect &&
63 test_cmp expect actual &&
65 # Client requested to use protocol v2
66 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
67 # Server responded using protocol v2
68 grep "fetch< version 2" log
71 test_expect_success 'pull with git:// using protocol v2' '
72 GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=2 \
75 git -C daemon_child log -1 --format=%s >actual &&
76 git -C "$daemon_parent" log -1 --format=%s >expect &&
77 test_cmp expect actual &&
79 # Client requested to use protocol v2
80 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
81 # Server responded using protocol v2
82 grep "fetch< version 2" log
87 # Test protocol v2 with 'file://' transport
89 test_expect_success 'create repo to be served by file:// transport' '
90 git init file_parent &&
91 test_commit -C file_parent one
94 test_expect_success 'list refs with file:// using protocol v2' '
95 GIT_TRACE_PACKET=1 git -c protocol.version=2 \
96 ls-remote --symref "file://$(pwd)/file_parent" >actual 2>log &&
98 # Server responded using protocol v2
99 grep "git< version 2" log &&
101 git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
102 test_cmp actual expect
105 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
106 GIT_TRACE_PACKET=1 git -c protocol.version=2 \
107 ls-remote "file://$(pwd)/file_parent" master 2>log &&
109 grep "ref-pattern master" log &&
110 ! grep "refs/tags/" log
113 test_expect_success 'clone with file:// using protocol v2' '
114 GIT_TRACE_PACKET=1 git -c protocol.version=2 \
115 clone "file://$(pwd)/file_parent" file_child 2>log &&
117 git -C file_child log -1 --format=%s >actual &&
118 git -C file_parent log -1 --format=%s >expect &&
119 test_cmp expect actual &&
121 # Server responded using protocol v2
122 grep "clone< version 2" log
125 test_expect_success 'fetch with file:// using protocol v2' '
126 test_commit -C file_parent two &&
128 GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=2 \
129 fetch origin 2>log &&
131 git -C file_child log -1 --format=%s origin/master >actual &&
132 git -C file_parent log -1 --format=%s >expect &&
133 test_cmp expect actual &&
135 # Server responded using protocol v2
136 grep "fetch< version 2" log
139 test_expect_success 'ref advertisment is filtered during fetch using protocol v2' '
140 test_commit -C file_parent three &&
142 GIT_TRACE_PACKET=1 git -C file_child -c protocol.version=2 \
143 fetch origin master 2>log &&
145 git -C file_child log -1 --format=%s origin/master >actual &&
146 git -C file_parent log -1 --format=%s >expect &&
147 test_cmp expect actual &&
149 grep "ref-pattern master" log &&
150 ! grep "refs/tags/" log