3 test_description
='test functionality common to smart fetch & push'
5 TEST_PASSES_SANITIZE_LEAK
=true
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' '
28 $(git rev-parse HEAD) HEAD
29 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
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
53 $(git rev-parse HEAD) HEAD
54 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
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 &&
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
75 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
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 &&
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
97 $(git rev-parse HEAD) HEAD
98 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
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 &&
114 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
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 &&
131 fetch=shallow wait-for-done
133 object-format=$(test_oid algo)
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)
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