3 test_description
='test git-serve and server commands'
7 test_expect_success
'test capability advertisement' '
10 agent=git/$(git version | cut -d" " -f3)
17 git serve --advertise-capabilities >out &&
18 test-pkt-line unpack <out >actual &&
19 test_cmp actual expect
22 test_expect_success
'stateless-rpc flag does not list capabilities' '
24 test-pkt-line pack >in <<-EOF &&
27 git serve --stateless-rpc >out <in &&
28 test_must_be_empty out &&
31 git serve --stateless-rpc >out &&
32 test_must_be_empty out
35 test_expect_success
'request invalid capability' '
36 test-pkt-line pack >in <<-EOF &&
40 test_must_fail git serve --stateless-rpc 2>err <in &&
41 test_i18ngrep "unknown capability" err
44 test_expect_success
'request with no command' '
45 test-pkt-line pack >in <<-EOF &&
49 test_must_fail git serve --stateless-rpc 2>err <in &&
50 test_i18ngrep "no command requested" err
53 test_expect_success
'request invalid command' '
54 test-pkt-line pack >in <<-EOF &&
59 test_must_fail git serve --stateless-rpc 2>err <in &&
60 test_i18ngrep "invalid command" err
63 # Test the basics of ls-refs
65 test_expect_success
'setup some refs and tags' '
67 git branch dev master &&
69 git symbolic-ref refs/heads/release refs/heads/master &&
70 git tag -a -m "annotated tag" annotated-tag
73 test_expect_success
'basics of ls-refs' '
74 test-pkt-line pack >in <<-EOF &&
80 $(git rev-parse HEAD) HEAD
81 $(git rev-parse refs/heads/dev) refs/heads/dev
82 $(git rev-parse refs/heads/master) refs/heads/master
83 $(git rev-parse refs/heads/release) refs/heads/release
84 $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag
85 $(git rev-parse refs/tags/one) refs/tags/one
86 $(git rev-parse refs/tags/two) refs/tags/two
90 git serve --stateless-rpc <in >out &&
91 test-pkt-line unpack <out >actual &&
92 test_cmp actual expect
95 test_expect_success
'basic ref-prefixes' '
96 test-pkt-line pack >in <<-EOF &&
99 ref-prefix refs/heads/master
100 ref-prefix refs/tags/one
104 cat >expect <<-EOF &&
105 $(git rev-parse refs/heads/master) refs/heads/master
106 $(git rev-parse refs/tags/one) refs/tags/one
110 git serve --stateless-rpc <in >out &&
111 test-pkt-line unpack <out >actual &&
112 test_cmp actual expect
115 test_expect_success
'refs/heads prefix' '
116 test-pkt-line pack >in <<-EOF &&
119 ref-prefix refs/heads/
123 cat >expect <<-EOF &&
124 $(git rev-parse refs/heads/dev) refs/heads/dev
125 $(git rev-parse refs/heads/master) refs/heads/master
126 $(git rev-parse refs/heads/release) refs/heads/release
130 git serve --stateless-rpc <in >out &&
131 test-pkt-line unpack <out >actual &&
132 test_cmp actual expect
135 test_expect_success
'peel parameter' '
136 test-pkt-line pack >in <<-EOF &&
140 ref-prefix refs/tags/
144 cat >expect <<-EOF &&
145 $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag peeled:$(git rev-parse refs/tags/annotated-tag^{})
146 $(git rev-parse refs/tags/one) refs/tags/one
147 $(git rev-parse refs/tags/two) refs/tags/two
151 git serve --stateless-rpc <in >out &&
152 test-pkt-line unpack <out >actual &&
153 test_cmp actual expect
156 test_expect_success
'symrefs parameter' '
157 test-pkt-line pack >in <<-EOF &&
161 ref-prefix refs/heads/
165 cat >expect <<-EOF &&
166 $(git rev-parse refs/heads/dev) refs/heads/dev
167 $(git rev-parse refs/heads/master) refs/heads/master
168 $(git rev-parse refs/heads/release) refs/heads/release symref-target:refs/heads/master
172 git serve --stateless-rpc <in >out &&
173 test-pkt-line unpack <out >actual &&
174 test_cmp actual expect
177 test_expect_success
'sending server-options' '
178 test-pkt-line pack >in <<-EOF &&
187 cat >expect <<-EOF &&
188 $(git rev-parse HEAD) HEAD
192 git serve --stateless-rpc <in >out &&
193 test-pkt-line unpack <out >actual &&
194 test_cmp actual expect
197 test_expect_success
'unexpected lines are not allowed in fetch request' '
200 test-pkt-line pack >in <<-EOF &&
203 this-is-not-a-command
207 test_must_fail git -C server serve --stateless-rpc <in >/dev/null 2>err &&
208 grep "unexpected line: .this-is-not-a-command." err