3 test_description
='test functionality common to smart fetch & push'
7 test_expect_success
'setup' '
8 test_commit --no-tag initial
11 test_expect_success
'git upload-pack --http-backend-info-refs and --advertise-refs are aliased' '
12 git upload-pack --http-backend-info-refs . >expected 2>err.expected &&
13 git upload-pack --advertise-refs . >actual 2>err.actual &&
14 test_cmp err.expected err.actual &&
15 test_cmp expected actual
18 test_expect_success
'git receive-pack --http-backend-info-refs and --advertise-refs are aliased' '
19 git receive-pack --http-backend-info-refs . >expected 2>err.expected &&
20 git receive-pack --advertise-refs . >actual 2>err.actual &&
21 test_cmp err.expected err.actual &&
22 test_cmp expected actual
25 test_expect_success
'git upload-pack --advertise-refs' '
27 $(git rev-parse HEAD) HEAD
28 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
32 # We only care about GIT_PROTOCOL, not GIT_TEST_PROTOCOL_VERSION
33 sane_unset GIT_PROTOCOL &&
34 GIT_TEST_PROTOCOL_VERSION=2 \
35 git upload-pack --advertise-refs . >out 2>err &&
37 test-tool pkt-line unpack <out >actual &&
38 test_must_be_empty err &&
39 test_cmp actual expect &&
41 # The --advertise-refs alias works
42 git upload-pack --advertise-refs . >out 2>err &&
44 test-tool pkt-line unpack <out >actual &&
45 test_must_be_empty err &&
46 test_cmp actual expect
49 test_expect_success
'git upload-pack --advertise-refs: v0' '
50 # With no specified protocol
52 $(git rev-parse HEAD) HEAD
53 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
57 git upload-pack --advertise-refs . >out 2>err &&
58 test-tool pkt-line unpack <out >actual &&
59 test_must_be_empty err &&
60 test_cmp actual expect &&
63 GIT_PROTOCOL=version=0 \
64 git upload-pack --advertise-refs . >out 2>err &&
65 test-tool pkt-line unpack <out >actual 2>err &&
66 test_must_be_empty err &&
67 test_cmp actual expect
71 test_expect_success
'git receive-pack --advertise-refs: v0' '
72 # With no specified protocol
74 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
78 git receive-pack --advertise-refs . >out 2>err &&
79 test-tool pkt-line unpack <out >actual &&
80 test_must_be_empty err &&
81 test_cmp actual expect &&
84 GIT_PROTOCOL=version=0 \
85 git receive-pack --advertise-refs . >out 2>err &&
86 test-tool pkt-line unpack <out >actual 2>err &&
87 test_must_be_empty err &&
88 test_cmp actual expect
92 test_expect_success
'git upload-pack --advertise-refs: v1' '
93 # With no specified protocol
96 $(git rev-parse HEAD) HEAD
97 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
101 GIT_PROTOCOL=version=1 \
102 git upload-pack --advertise-refs . >out &&
104 test-tool pkt-line unpack <out >actual 2>err &&
105 test_must_be_empty err &&
106 test_cmp actual expect
109 test_expect_success
'git receive-pack --advertise-refs: v1' '
110 # With no specified protocol
111 cat >expect <<-EOF &&
113 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
117 GIT_PROTOCOL=version=1 \
118 git receive-pack --advertise-refs . >out &&
120 test-tool pkt-line unpack <out >actual 2>err &&
121 test_must_be_empty err &&
122 test_cmp actual expect
125 test_expect_success
'git upload-pack --advertise-refs: v2' '
126 cat >expect <<-EOF &&
130 fetch=shallow wait-for-done
132 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