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 test_when_finished "rm -f log" &&
23 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
24 ls-remote --symref "$GIT_DAEMON_URL/parent" >actual &&
26 # Client requested to use protocol v2
27 grep "git> .*\\\0\\\0version=2\\\0$" log &&
28 # Server responded using protocol v2
29 grep "git< version 2" log &&
31 git ls-remote --symref "$GIT_DAEMON_URL/parent" >expect &&
32 test_cmp actual expect
35 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
36 test_when_finished "rm -f log" &&
38 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
39 ls-remote "$GIT_DAEMON_URL/parent" master >actual &&
42 $(git -C "$daemon_parent" rev-parse refs/heads/master)$(printf "\t")refs/heads/master
45 test_cmp actual expect
48 test_expect_success 'clone with git:// using protocol v2' '
49 test_when_finished "rm -f log" &&
51 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
52 clone "$GIT_DAEMON_URL/parent" daemon_child &&
54 git -C daemon_child log -1 --format=%s >actual &&
55 git -C "$daemon_parent" log -1 --format=%s >expect &&
56 test_cmp expect actual &&
58 # Client requested to use protocol v2
59 grep "clone> .*\\\0\\\0version=2\\\0$" log &&
60 # Server responded using protocol v2
61 grep "clone< version 2" log
64 test_expect_success 'fetch with git:// using protocol v2' '
65 test_when_finished "rm -f log" &&
67 test_commit -C "$daemon_parent" two &&
69 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
72 git -C daemon_child log -1 --format=%s origin/master >actual &&
73 git -C "$daemon_parent" log -1 --format=%s >expect &&
74 test_cmp expect actual &&
76 # Client requested to use protocol v2
77 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
78 # Server responded using protocol v2
79 grep "fetch< version 2" log
82 test_expect_success 'pull with git:// using protocol v2' '
83 test_when_finished "rm -f log" &&
85 GIT_TRACE_PACKET="$(pwd)/log" git -C daemon_child -c protocol.version=2 \
88 git -C daemon_child log -1 --format=%s >actual &&
89 git -C "$daemon_parent" log -1 --format=%s >expect &&
90 test_cmp expect actual &&
92 # Client requested to use protocol v2
93 grep "fetch> .*\\\0\\\0version=2\\\0$" log &&
94 # Server responded using protocol v2
95 grep "fetch< version 2" log
100 # Test protocol v2 with 'file://' transport
102 test_expect_success 'create repo to be served by file:// transport' '
103 git init file_parent &&
104 test_commit -C file_parent one
107 test_expect_success 'list refs with file:// using protocol v2' '
108 test_when_finished "rm -f log" &&
110 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
111 ls-remote --symref "file://$(pwd)/file_parent" >actual &&
113 # Server responded using protocol v2
114 grep "git< version 2" log &&
116 git ls-remote --symref "file://$(pwd)/file_parent" >expect &&
117 test_cmp actual expect
120 test_expect_success 'ref advertisment is filtered with ls-remote using protocol v2' '
121 test_when_finished "rm -f log" &&
123 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
124 ls-remote "file://$(pwd)/file_parent" master >actual &&
126 cat >expect <<-EOF &&
127 $(git -C file_parent rev-parse refs/heads/master)$(printf "\t")refs/heads/master
130 test_cmp actual expect
133 test_expect_success 'clone with file:// using protocol v2' '
134 test_when_finished "rm -f log" &&
136 GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
137 clone "file://$(pwd)/file_parent" file_child &&
139 git -C file_child log -1 --format=%s >actual &&
140 git -C file_parent log -1 --format=%s >expect &&
141 test_cmp expect actual &&
143 # Server responded using protocol v2
144 grep "clone< version 2" log
147 test_expect_success 'fetch with file:// using protocol v2' '
148 test_when_finished "rm -f log" &&
150 test_commit -C file_parent two &&
152 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
155 git -C file_child log -1 --format=%s origin/master >actual &&
156 git -C file_parent log -1 --format=%s >expect &&
157 test_cmp expect actual &&
159 # Server responded using protocol v2
160 grep "fetch< version 2" log
163 test_expect_success 'ref advertisment is filtered during fetch using protocol v2' '
164 test_when_finished "rm -f log" &&
166 test_commit -C file_parent three &&
168 GIT_TRACE_PACKET="$(pwd)/log" git -C file_child -c protocol.version=2 \
169 fetch origin master &&
171 git -C file_child log -1 --format=%s origin/master >actual &&
172 git -C file_parent log -1 --format=%s >expect &&
173 test_cmp expect actual &&
175 ! grep "refs/tags/one" log &&
176 ! grep "refs/tags/two" log &&
177 ! grep "refs/tags/three" log