]>
Commit | Line | Data |
---|---|---|
760486a1 ÆAB |
1 | #!/bin/sh |
2 | ||
3 | test_description='test functionality common to smart fetch & push' | |
4 | ||
d96fb140 | 5 | TEST_PASSES_SANITIZE_LEAK=true |
760486a1 ÆAB |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success 'setup' ' | |
9 | test_commit --no-tag initial | |
10 | ' | |
11 | ||
98e2d9d6 ÆAB |
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 | |
17 | ' | |
18 | ||
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 | |
24 | ' | |
25 | ||
760486a1 ÆAB |
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 | |
32 | ||
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 && | |
37 | ||
38 | test-tool pkt-line unpack <out >actual && | |
39 | test_must_be_empty err && | |
40 | test_cmp actual expect && | |
41 | ||
42 | # The --advertise-refs alias works | |
43 | git upload-pack --advertise-refs . >out 2>err && | |
44 | ||
45 | test-tool pkt-line unpack <out >actual && | |
46 | test_must_be_empty err && | |
47 | test_cmp actual expect | |
48 | ' | |
49 | ||
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 | |
57 | ||
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 && | |
62 | ||
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 | |
69 | ||
70 | ' | |
71 | ||
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 | |
78 | ||
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 && | |
83 | ||
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 | |
90 | ||
91 | ' | |
92 | ||
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 | |
100 | EOF | |
101 | ||
102 | GIT_PROTOCOL=version=1 \ | |
103 | git upload-pack --advertise-refs . >out && | |
104 | ||
105 | test-tool pkt-line unpack <out >actual 2>err && | |
106 | test_must_be_empty err && | |
107 | test_cmp actual expect | |
108 | ' | |
109 | ||
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 | |
116 | EOF | |
117 | ||
118 | GIT_PROTOCOL=version=1 \ | |
119 | git receive-pack --advertise-refs . >out && | |
120 | ||
121 | test-tool pkt-line unpack <out >actual 2>err && | |
122 | test_must_be_empty err && | |
123 | test_cmp actual expect | |
124 | ' | |
125 | ||
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) | |
760486a1 ÆAB |
134 | 0000 |
135 | EOF | |
136 | ||
137 | GIT_PROTOCOL=version=2 \ | |
138 | GIT_USER_AGENT=FAKE \ | |
139 | git upload-pack --advertise-refs . >out 2>err && | |
140 | ||
141 | test-tool pkt-line unpack <out >actual && | |
142 | test_must_be_empty err && | |
143 | test_cmp actual expect | |
144 | ' | |
145 | ||
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 | |
151 | EOF | |
152 | ||
153 | GIT_PROTOCOL=version=2 \ | |
154 | git receive-pack --advertise-refs . >out 2>err && | |
155 | ||
156 | test-tool pkt-line unpack <out >actual && | |
157 | test_must_be_empty err && | |
158 | test_cmp actual expect | |
159 | ' | |
160 | ||
161 | test_done |