3 test_description
='test protocol v2 server commands'
7 test_expect_success
'test capability advertisement' '
10 agent=git/$(git version | cut -d" " -f3)
17 GIT_TEST_SIDEBAND_ALL=0 test-tool serve-v2 \
18 --advertise-capabilities >out &&
19 test-tool pkt-line unpack <out >actual &&
20 test_cmp expect actual
23 test_expect_success
'stateless-rpc flag does not list capabilities' '
25 test-tool pkt-line pack >in <<-EOF &&
28 test-tool serve-v2 --stateless-rpc >out <in &&
29 test_must_be_empty out &&
32 test-tool serve-v2 --stateless-rpc >out &&
33 test_must_be_empty out
36 test_expect_success
'request invalid capability' '
37 test-tool pkt-line pack >in <<-EOF &&
41 test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
42 test_i18ngrep "unknown capability" err
45 test_expect_success
'request with no command' '
46 test-tool pkt-line pack >in <<-EOF &&
50 test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
51 test_i18ngrep "no command requested" err
54 test_expect_success
'request invalid command' '
55 test-tool pkt-line pack >in <<-EOF &&
60 test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
61 test_i18ngrep "invalid command" err
64 # Test the basics of ls-refs
66 test_expect_success
'setup some refs and tags' '
68 git branch dev master &&
70 git symbolic-ref refs/heads/release refs/heads/master &&
71 git tag -a -m "annotated tag" annotated-tag
74 test_expect_success
'basics of ls-refs' '
75 test-tool pkt-line pack >in <<-EOF &&
81 $(git rev-parse HEAD) HEAD
82 $(git rev-parse refs/heads/dev) refs/heads/dev
83 $(git rev-parse refs/heads/master) refs/heads/master
84 $(git rev-parse refs/heads/release) refs/heads/release
85 $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag
86 $(git rev-parse refs/tags/one) refs/tags/one
87 $(git rev-parse refs/tags/two) refs/tags/two
91 test-tool serve-v2 --stateless-rpc <in >out &&
92 test-tool pkt-line unpack <out >actual &&
93 test_cmp expect actual
96 test_expect_success
'basic ref-prefixes' '
97 test-tool pkt-line pack >in <<-EOF &&
100 ref-prefix refs/heads/master
101 ref-prefix refs/tags/one
105 cat >expect <<-EOF &&
106 $(git rev-parse refs/heads/master) refs/heads/master
107 $(git rev-parse refs/tags/one) refs/tags/one
111 test-tool serve-v2 --stateless-rpc <in >out &&
112 test-tool pkt-line unpack <out >actual &&
113 test_cmp expect actual
116 test_expect_success
'refs/heads prefix' '
117 test-tool pkt-line pack >in <<-EOF &&
120 ref-prefix refs/heads/
124 cat >expect <<-EOF &&
125 $(git rev-parse refs/heads/dev) refs/heads/dev
126 $(git rev-parse refs/heads/master) refs/heads/master
127 $(git rev-parse refs/heads/release) refs/heads/release
131 test-tool serve-v2 --stateless-rpc <in >out &&
132 test-tool pkt-line unpack <out >actual &&
133 test_cmp expect actual
136 test_expect_success
'peel parameter' '
137 test-tool pkt-line pack >in <<-EOF &&
141 ref-prefix refs/tags/
145 cat >expect <<-EOF &&
146 $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag peeled:$(git rev-parse refs/tags/annotated-tag^{})
147 $(git rev-parse refs/tags/one) refs/tags/one
148 $(git rev-parse refs/tags/two) refs/tags/two
152 test-tool serve-v2 --stateless-rpc <in >out &&
153 test-tool pkt-line unpack <out >actual &&
154 test_cmp expect actual
157 test_expect_success
'symrefs parameter' '
158 test-tool pkt-line pack >in <<-EOF &&
162 ref-prefix refs/heads/
166 cat >expect <<-EOF &&
167 $(git rev-parse refs/heads/dev) refs/heads/dev
168 $(git rev-parse refs/heads/master) refs/heads/master
169 $(git rev-parse refs/heads/release) refs/heads/release symref-target:refs/heads/master
173 test-tool serve-v2 --stateless-rpc <in >out &&
174 test-tool pkt-line unpack <out >actual &&
175 test_cmp expect actual
178 test_expect_success
'sending server-options' '
179 test-tool pkt-line pack >in <<-EOF &&
188 cat >expect <<-EOF &&
189 $(git rev-parse HEAD) HEAD
193 test-tool serve-v2 --stateless-rpc <in >out &&
194 test-tool pkt-line unpack <out >actual &&
195 test_cmp expect actual
198 test_expect_success
'unexpected lines are not allowed in fetch request' '
201 test-tool pkt-line pack >in <<-EOF &&
204 this-is-not-a-command
210 test_must_fail test-tool serve-v2 --stateless-rpc
211 ) <in >/dev/null 2>err &&
212 grep "unexpected line: .this-is-not-a-command." err