3 test_description='test git-serve and server commands'
7 test_expect_success 'test capability advertisement' '
10 agent=git/$(git version | cut -d" " -f3)
15 git serve --advertise-capabilities >out &&
16 test-pkt-line unpack <out >actual &&
17 test_cmp actual expect
20 test_expect_success 'stateless-rpc flag does not list capabilities' '
22 test-pkt-line pack >in <<-EOF &&
25 git serve --stateless-rpc >out <in &&
26 test_must_be_empty out &&
29 git serve --stateless-rpc >out &&
30 test_must_be_empty out
33 test_expect_success 'request invalid capability' '
34 test-pkt-line pack >in <<-EOF &&
38 test_must_fail git serve --stateless-rpc 2>err <in &&
39 test_i18ngrep "unknown capability" err
42 test_expect_success 'request with no command' '
43 test-pkt-line pack >in <<-EOF &&
47 test_must_fail git serve --stateless-rpc 2>err <in &&
48 test_i18ngrep "no command requested" err
51 test_expect_success 'request invalid command' '
52 test-pkt-line pack >in <<-EOF &&
57 test_must_fail git serve --stateless-rpc 2>err <in &&
58 test_i18ngrep "invalid command" err
61 # Test the basics of ls-refs
63 test_expect_success 'setup some refs and tags' '
65 git branch dev master &&
67 git symbolic-ref refs/heads/release refs/heads/master &&
68 git tag -a -m "annotated tag" annotated-tag
71 test_expect_success 'basics of ls-refs' '
72 test-pkt-line pack >in <<-EOF &&
78 $(git rev-parse HEAD) HEAD
79 $(git rev-parse refs/heads/dev) refs/heads/dev
80 $(git rev-parse refs/heads/master) refs/heads/master
81 $(git rev-parse refs/heads/release) refs/heads/release
82 $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag
83 $(git rev-parse refs/tags/one) refs/tags/one
84 $(git rev-parse refs/tags/two) refs/tags/two
88 git serve --stateless-rpc <in >out &&
89 test-pkt-line unpack <out >actual &&
90 test_cmp actual expect
93 test_expect_success 'basic ref-prefixes' '
94 test-pkt-line pack >in <<-EOF &&
97 ref-prefix refs/heads/master
98 ref-prefix refs/tags/one
102 cat >expect <<-EOF &&
103 $(git rev-parse refs/heads/master) refs/heads/master
104 $(git rev-parse refs/tags/one) refs/tags/one
108 git serve --stateless-rpc <in >out &&
109 test-pkt-line unpack <out >actual &&
110 test_cmp actual expect
113 test_expect_success 'refs/heads prefix' '
114 test-pkt-line pack >in <<-EOF &&
117 ref-prefix refs/heads/
121 cat >expect <<-EOF &&
122 $(git rev-parse refs/heads/dev) refs/heads/dev
123 $(git rev-parse refs/heads/master) refs/heads/master
124 $(git rev-parse refs/heads/release) refs/heads/release
128 git serve --stateless-rpc <in >out &&
129 test-pkt-line unpack <out >actual &&
130 test_cmp actual expect
133 test_expect_success 'peel parameter' '
134 test-pkt-line pack >in <<-EOF &&
138 ref-prefix refs/tags/
142 cat >expect <<-EOF &&
143 $(git rev-parse refs/tags/annotated-tag) refs/tags/annotated-tag peeled:$(git rev-parse refs/tags/annotated-tag^{})
144 $(git rev-parse refs/tags/one) refs/tags/one
145 $(git rev-parse refs/tags/two) refs/tags/two
149 git serve --stateless-rpc <in >out &&
150 test-pkt-line unpack <out >actual &&
151 test_cmp actual expect
154 test_expect_success 'symrefs parameter' '
155 test-pkt-line pack >in <<-EOF &&
159 ref-prefix refs/heads/
163 cat >expect <<-EOF &&
164 $(git rev-parse refs/heads/dev) refs/heads/dev
165 $(git rev-parse refs/heads/master) refs/heads/master
166 $(git rev-parse refs/heads/release) refs/heads/release symref-target:refs/heads/master
170 git serve --stateless-rpc <in >out &&
171 test-pkt-line unpack <out >actual &&
172 test_cmp actual expect