3 test_description
='test git-serve and server commands'
7 test_expect_success
'test capability advertisement' '
10 agent=git/$(git version | cut -d" " -f3)
16 git serve --advertise-capabilities >out &&
17 test-pkt-line unpack <out >actual &&
18 test_cmp actual expect
21 test_expect_success
'stateless-rpc flag does not list capabilities' '
23 test-pkt-line pack >in <<-EOF &&
26 git serve --stateless-rpc >out <in &&
27 test_must_be_empty out &&
30 git serve --stateless-rpc >out &&
31 test_must_be_empty out
34 test_expect_success
'request invalid capability' '
35 test-pkt-line pack >in <<-EOF &&
39 test_must_fail git serve --stateless-rpc 2>err <in &&
40 test_i18ngrep "unknown capability" err
43 test_expect_success
'request with no command' '
44 test-pkt-line pack >in <<-EOF &&
48 test_must_fail git serve --stateless-rpc 2>err <in &&
49 test_i18ngrep "no command requested" err
52 test_expect_success
'request invalid command' '
53 test-pkt-line pack >in <<-EOF &&
58 test_must_fail git serve --stateless-rpc 2>err <in &&
59 test_i18ngrep "invalid command" err
62 # Test the basics of ls-refs
64 test_expect_success
'setup some refs and tags' '
66 git branch dev master &&
68 git symbolic-ref refs/heads/release refs/heads/master &&
69 git tag -a -m "annotated tag" annotated-tag
72 test_expect_success
'basics of ls-refs' '
73 test-pkt-line pack >in <<-EOF &&
79 $(git rev-parse HEAD) HEAD
80 $(git rev-parse refs/heads/dev) refs/heads/dev
81 $(git rev-parse refs/heads/master) refs/heads/master
82 $(git rev-parse refs/heads/release) refs/heads/release
83 $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag
84 $(git rev-parse refs/tags/one) refs/tags/one
85 $(git rev-parse refs/tags/two) refs/tags/two
89 git serve --stateless-rpc <in >out &&
90 test-pkt-line unpack <out >actual &&
91 test_cmp actual expect
94 test_expect_success
'basic ref-prefixes' '
95 test-pkt-line pack >in <<-EOF &&
98 ref-prefix refs/heads/master
99 ref-prefix refs/tags/one
103 cat >expect <<-EOF &&
104 $(git rev-parse refs/heads/master) refs/heads/master
105 $(git rev-parse refs/tags/one) refs/tags/one
109 git serve --stateless-rpc <in >out &&
110 test-pkt-line unpack <out >actual &&
111 test_cmp actual expect
114 test_expect_success
'refs/heads prefix' '
115 test-pkt-line pack >in <<-EOF &&
118 ref-prefix refs/heads/
122 cat >expect <<-EOF &&
123 $(git rev-parse refs/heads/dev) refs/heads/dev
124 $(git rev-parse refs/heads/master) refs/heads/master
125 $(git rev-parse refs/heads/release) refs/heads/release
129 git serve --stateless-rpc <in >out &&
130 test-pkt-line unpack <out >actual &&
131 test_cmp actual expect
134 test_expect_success
'peel parameter' '
135 test-pkt-line pack >in <<-EOF &&
139 ref-prefix refs/tags/
143 cat >expect <<-EOF &&
144 $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag peeled:$(git rev-parse refs/tags/annotated-tag^{})
145 $(git rev-parse refs/tags/one) refs/tags/one
146 $(git rev-parse refs/tags/two) refs/tags/two
150 git serve --stateless-rpc <in >out &&
151 test-pkt-line unpack <out >actual &&
152 test_cmp actual expect
155 test_expect_success
'symrefs parameter' '
156 test-pkt-line pack >in <<-EOF &&
160 ref-prefix refs/heads/
164 cat >expect <<-EOF &&
165 $(git rev-parse refs/heads/dev) refs/heads/dev
166 $(git rev-parse refs/heads/master) refs/heads/master
167 $(git rev-parse refs/heads/release) refs/heads/release symref-target:refs/heads/master
171 git serve --stateless-rpc <in >out &&
172 test-pkt-line unpack <out >actual &&
173 test_cmp actual expect