Merge branch 'jc/fix-ref-sorting-parse'
[git.git] / t / t5555-http-smart-common.sh
blob49faf5e283bdb05b090f9682cd315e94eea4d217
1 #!/bin/sh
3 test_description='test functionality common to smart fetch & push'
5 . ./test-lib.sh
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' '
26 cat >expect <<-EOF &&
27 $(git rev-parse HEAD) HEAD
28 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
29 0000
30 EOF
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
51 cat >expect <<-EOF &&
52 $(git rev-parse HEAD) HEAD
53 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
54 0000
55 EOF
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 &&
62 # With explicit v0
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
73 cat >expect <<-EOF &&
74 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
75 0000
76 EOF
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 &&
83 # With explicit v0
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
94 cat >expect <<-EOF &&
95 version 1
96 $(git rev-parse HEAD) HEAD
97 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
98 0000
99 EOF
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 &&
112 version 1
113 $(git rev-parse HEAD) $(git symbolic-ref HEAD)
114 0000
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 &&
127 version 2
128 agent=FAKE
129 ls-refs=unborn
130 fetch=shallow wait-for-done
131 server-option
132 object-format=$(test_oid algo)
133 object-info
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