Git 2.45
[git/gitster.git] / t / t5555-http-smart-common.sh
blob3dcb3340a36bb0e0efca1c1dfad6373dd5aeedc5
1 #!/bin/sh
3 test_description='test functionality common to smart fetch & push'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup' '
9 test_commit --no-tag initial
12 test_expect_success 'git upload-pack --http-backend-info-refs and --advertise-refs are aliased' '
13 git upload-pack --http-backend-info-refs . >expected 2>err.expected &&
14 git upload-pack --advertise-refs . >actual 2>err.actual &&
15 test_cmp err.expected err.actual &&
16 test_cmp expected actual
19 test_expect_success 'git receive-pack --http-backend-info-refs and --advertise-refs are aliased' '
20 git receive-pack --http-backend-info-refs . >expected 2>err.expected &&
21 git receive-pack --advertise-refs . >actual 2>err.actual &&
22 test_cmp err.expected err.actual &&
23 test_cmp expected actual
26 test_expect_success 'git upload-pack --advertise-refs' '
27 cat >expect <<-EOF &&
28 $(git rev-parse HEAD) HEAD
29 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
30 0000
31 EOF
33 # We only care about GIT_PROTOCOL, not GIT_TEST_PROTOCOL_VERSION
34 sane_unset GIT_PROTOCOL &&
35 GIT_TEST_PROTOCOL_VERSION=2 \
36 git upload-pack --advertise-refs . >out 2>err &&
38 test-tool pkt-line unpack <out >actual &&
39 test_must_be_empty err &&
40 test_cmp actual expect &&
42 # The --advertise-refs alias works
43 git upload-pack --advertise-refs . >out 2>err &&
45 test-tool pkt-line unpack <out >actual &&
46 test_must_be_empty err &&
47 test_cmp actual expect
50 test_expect_success 'git upload-pack --advertise-refs: v0' '
51 # With no specified protocol
52 cat >expect <<-EOF &&
53 $(git rev-parse HEAD) HEAD
54 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
55 0000
56 EOF
58 git upload-pack --advertise-refs . >out 2>err &&
59 test-tool pkt-line unpack <out >actual &&
60 test_must_be_empty err &&
61 test_cmp actual expect &&
63 # With explicit v0
64 GIT_PROTOCOL=version=0 \
65 git upload-pack --advertise-refs . >out 2>err &&
66 test-tool pkt-line unpack <out >actual 2>err &&
67 test_must_be_empty err &&
68 test_cmp actual expect
72 test_expect_success 'git receive-pack --advertise-refs: v0' '
73 # With no specified protocol
74 cat >expect <<-EOF &&
75 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
76 0000
77 EOF
79 git receive-pack --advertise-refs . >out 2>err &&
80 test-tool pkt-line unpack <out >actual &&
81 test_must_be_empty err &&
82 test_cmp actual expect &&
84 # With explicit v0
85 GIT_PROTOCOL=version=0 \
86 git receive-pack --advertise-refs . >out 2>err &&
87 test-tool pkt-line unpack <out >actual 2>err &&
88 test_must_be_empty err &&
89 test_cmp actual expect
93 test_expect_success 'git upload-pack --advertise-refs: v1' '
94 # With no specified protocol
95 cat >expect <<-EOF &&
96 version 1
97 $(git rev-parse HEAD) HEAD
98 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
99 0000
102 GIT_PROTOCOL=version=1 \
103 git upload-pack --advertise-refs . >out &&
105 test-tool pkt-line unpack <out >actual 2>err &&
106 test_must_be_empty err &&
107 test_cmp actual expect
110 test_expect_success 'git receive-pack --advertise-refs: v1' '
111 # With no specified protocol
112 cat >expect <<-EOF &&
113 version 1
114 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
115 0000
118 GIT_PROTOCOL=version=1 \
119 git receive-pack --advertise-refs . >out &&
121 test-tool pkt-line unpack <out >actual 2>err &&
122 test_must_be_empty err &&
123 test_cmp actual expect
126 test_expect_success 'git upload-pack --advertise-refs: v2' '
127 cat >expect <<-EOF &&
128 version 2
129 agent=FAKE
130 ls-refs=unborn
131 fetch=shallow wait-for-done
132 server-option
133 object-format=$(test_oid algo)
134 0000
137 GIT_PROTOCOL=version=2 \
138 GIT_USER_AGENT=FAKE \
139 git upload-pack --advertise-refs . >out 2>err &&
141 test-tool pkt-line unpack <out >actual &&
142 test_must_be_empty err &&
143 test_cmp actual expect
146 test_expect_success 'git receive-pack --advertise-refs: v2' '
147 # There is no v2 yet for receive-pack, implicit v0
148 cat >expect <<-EOF &&
149 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
150 0000
153 GIT_PROTOCOL=version=2 \
154 git receive-pack --advertise-refs . >out 2>err &&
156 test-tool pkt-line unpack <out >actual &&
157 test_must_be_empty err &&
158 test_cmp actual expect
161 test_done