]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5411/test-0032-report-with-options.sh
Merge branch 'pk/subsub-fetch-fix-take-2' into maint
[thirdparty/git.git] / t / t5411 / test-0032-report-with-options.sh
CommitLineData
15d3af5e
JX
1test_expect_success "setup proc-receive hook (option without matching ok, $PROTOCOL)" '
2 write_script "$upstream/hooks/proc-receive" <<-EOF
3 printf >&2 "# proc-receive hook\n"
4 test-tool proc-receive -v \
5 -r "option refname refs/pull/123/head" \
6 -r "option old-oid $B"
7 EOF
8'
9
8f0a2645
JS
10# Refs of upstream : main(A)
11# Refs of workbench: main(A) tags/v123
12# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A)
15d3af5e
JX
13test_expect_success "proc-receive: report option without matching ok ($PROTOCOL)" '
14 test_must_fail git -C workbench push origin \
8f0a2645 15 HEAD:refs/for/main/topic \
15d3af5e
JX
16 >out 2>&1 &&
17 make_user_friendly_and_stable_output <out >actual &&
18 cat >expect <<-EOF &&
19 remote: # pre-receive hook
8f0a2645 20 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 21 remote: # proc-receive hook
8f0a2645 22 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e
JX
23 remote: proc-receive> option refname refs/pull/123/head
24 remote: proc-receive> option old-oid <COMMIT-B>
25 remote: error: proc-receive reported "option" without a matching "ok/ng" directive
26 To <URL/of/upstream.git>
8f0a2645 27 ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status)
15d3af5e
JX
28 EOF
29 test_cmp expect actual
30'
31
32test_expect_success "setup proc-receive hook (option refname, $PROTOCOL)" '
33 write_script "$upstream/hooks/proc-receive" <<-EOF
34 printf >&2 "# proc-receive hook\n"
35 test-tool proc-receive -v \
8f0a2645 36 -r "ok refs/for/main/topic" \
15d3af5e
JX
37 -r "option refname refs/pull/123/head"
38 EOF
39'
40
8f0a2645
JS
41# Refs of upstream : main(A)
42# Refs of workbench: main(A) tags/v123
43# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A)
15d3af5e
JX
44test_expect_success "proc-receive: report option refname ($PROTOCOL)" '
45 git -C workbench push origin \
8f0a2645 46 HEAD:refs/for/main/topic \
15d3af5e
JX
47 >out 2>&1 &&
48 make_user_friendly_and_stable_output <out >actual &&
49 cat >expect <<-EOF &&
50 remote: # pre-receive hook
8f0a2645 51 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 52 remote: # proc-receive hook
8f0a2645
JS
53 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
54 remote: proc-receive> ok refs/for/main/topic
15d3af5e
JX
55 remote: proc-receive> option refname refs/pull/123/head
56 remote: # post-receive hook
195d6eae 57 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head
15d3af5e 58 To <URL/of/upstream.git>
63518a57 59 * [new reference] HEAD -> refs/pull/123/head
15d3af5e
JX
60 EOF
61 test_cmp expect actual
62'
63
64test_expect_success "setup proc-receive hook (option refname and forced-update, $PROTOCOL)" '
65 write_script "$upstream/hooks/proc-receive" <<-EOF
66 printf >&2 "# proc-receive hook\n"
67 test-tool proc-receive -v \
8f0a2645 68 -r "ok refs/for/main/topic" \
15d3af5e
JX
69 -r "option refname refs/pull/123/head" \
70 -r "option forced-update"
71 EOF
72'
8f0a2645
JS
73# Refs of upstream : main(A)
74# Refs of workbench: main(A) tags/v123
75# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A)
15d3af5e
JX
76test_expect_success "proc-receive: report option refname and forced-update ($PROTOCOL)" '
77 git -C workbench push origin \
8f0a2645 78 HEAD:refs/for/main/topic \
15d3af5e
JX
79 >out 2>&1 &&
80 make_user_friendly_and_stable_output <out >actual &&
81 cat >expect <<-EOF &&
82 remote: # pre-receive hook
8f0a2645 83 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 84 remote: # proc-receive hook
8f0a2645
JS
85 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
86 remote: proc-receive> ok refs/for/main/topic
15d3af5e
JX
87 remote: proc-receive> option refname refs/pull/123/head
88 remote: proc-receive> option forced-update
89 remote: # post-receive hook
195d6eae 90 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head
15d3af5e 91 To <URL/of/upstream.git>
63518a57 92 * [new reference] HEAD -> refs/pull/123/head
15d3af5e
JX
93 EOF
94 test_cmp expect actual
95'
96
97test_expect_success "setup proc-receive hook (option refname and old-oid, $PROTOCOL)" '
98 write_script "$upstream/hooks/proc-receive" <<-EOF
99 printf >&2 "# proc-receive hook\n"
100 test-tool proc-receive -v \
8f0a2645 101 -r "ok refs/for/main/topic" \
15d3af5e
JX
102 -r "option refname refs/pull/123/head" \
103 -r "option old-oid $B"
104 EOF
105'
106
8f0a2645
JS
107# Refs of upstream : main(A)
108# Refs of workbench: main(A) tags/v123
109# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A)
15d3af5e
JX
110test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL)" '
111 git -C workbench push origin \
8f0a2645 112 HEAD:refs/for/main/topic \
15d3af5e
JX
113 >out 2>&1 &&
114 make_user_friendly_and_stable_output <out >actual &&
115 cat >expect <<-EOF &&
116 remote: # pre-receive hook
8f0a2645 117 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 118 remote: # proc-receive hook
8f0a2645
JS
119 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
120 remote: proc-receive> ok refs/for/main/topic
15d3af5e
JX
121 remote: proc-receive> option refname refs/pull/123/head
122 remote: proc-receive> option old-oid <COMMIT-B>
123 remote: # post-receive hook
195d6eae 124 remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/123/head
15d3af5e 125 To <URL/of/upstream.git>
63518a57 126 <OID-B>..<OID-A> HEAD -> refs/pull/123/head
15d3af5e
JX
127 EOF
128 test_cmp expect actual
129'
130
131test_expect_success "setup proc-receive hook (option old-oid, $PROTOCOL)" '
132 write_script "$upstream/hooks/proc-receive" <<-EOF
133 printf >&2 "# proc-receive hook\n"
134 test-tool proc-receive -v \
8f0a2645 135 -r "ok refs/for/main/topic" \
15d3af5e
JX
136 -r "option old-oid $B"
137 EOF
138'
139
8f0a2645
JS
140# Refs of upstream : main(A)
141# Refs of workbench: main(A) tags/v123
142# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A)
15d3af5e
JX
143test_expect_success "proc-receive: report option old-oid ($PROTOCOL)" '
144 git -C workbench push origin \
8f0a2645 145 HEAD:refs/for/main/topic \
15d3af5e
JX
146 >out 2>&1 &&
147 make_user_friendly_and_stable_output <out >actual &&
148 cat >expect <<-EOF &&
149 remote: # pre-receive hook
8f0a2645 150 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 151 remote: # proc-receive hook
8f0a2645
JS
152 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
153 remote: proc-receive> ok refs/for/main/topic
15d3af5e
JX
154 remote: proc-receive> option old-oid <COMMIT-B>
155 remote: # post-receive hook
8f0a2645 156 remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/main/topic
15d3af5e 157 To <URL/of/upstream.git>
8f0a2645 158 <OID-B>..<OID-A> HEAD -> refs/for/main/topic
15d3af5e
JX
159 EOF
160 test_cmp expect actual
161'
162
163test_expect_success "setup proc-receive hook (option old-oid and new-oid, $PROTOCOL)" '
164 write_script "$upstream/hooks/proc-receive" <<-EOF
165 printf >&2 "# proc-receive hook\n"
166 test-tool proc-receive -v \
8f0a2645 167 -r "ok refs/for/main/topic" \
15d3af5e
JX
168 -r "option old-oid $A" \
169 -r "option new-oid $B"
170 EOF
171'
172
8f0a2645
JS
173# Refs of upstream : main(A)
174# Refs of workbench: main(A) tags/v123
175# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A)
15d3af5e
JX
176test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL)" '
177 git -C workbench push origin \
8f0a2645 178 HEAD:refs/for/main/topic \
15d3af5e
JX
179 >out 2>&1 &&
180 make_user_friendly_and_stable_output <out >actual &&
181 cat >expect <<-EOF &&
182 remote: # pre-receive hook
8f0a2645 183 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 184 remote: # proc-receive hook
8f0a2645
JS
185 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
186 remote: proc-receive> ok refs/for/main/topic
15d3af5e
JX
187 remote: proc-receive> option old-oid <COMMIT-A>
188 remote: proc-receive> option new-oid <COMMIT-B>
189 remote: # post-receive hook
8f0a2645 190 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic
15d3af5e 191 To <URL/of/upstream.git>
8f0a2645 192 <OID-A>..<OID-B> HEAD -> refs/for/main/topic
15d3af5e
JX
193 EOF
194 test_cmp expect actual
195'
196
197test_expect_success "setup proc-receive hook (report with multiple rewrites, $PROTOCOL)" '
198 write_script "$upstream/hooks/proc-receive" <<-EOF
199 printf >&2 "# proc-receive hook\n"
200 test-tool proc-receive -v \
201 -r "ok refs/for/a/b/c/topic" \
202 -r "ok refs/for/next/topic" \
203 -r "option refname refs/pull/123/head" \
8f0a2645 204 -r "ok refs/for/main/topic" \
15d3af5e
JX
205 -r "option refname refs/pull/124/head" \
206 -r "option old-oid $B" \
207 -r "option forced-update" \
208 -r "option new-oid $A"
209 EOF
210'
211
8f0a2645
JS
212# Refs of upstream : main(A)
213# Refs of workbench: main(A) tags/v123
214# git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A)
15d3af5e
JX
215test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL)" '
216 git -C workbench push origin \
217 HEAD:refs/for/next/topic \
218 HEAD:refs/for/a/b/c/topic \
8f0a2645 219 HEAD:refs/for/main/topic \
15d3af5e
JX
220 >out 2>&1 &&
221 make_user_friendly_and_stable_output <out >actual &&
222 cat >expect <<-EOF &&
223 remote: # pre-receive hook
224 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic
225 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic
8f0a2645 226 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e
JX
227 remote: # proc-receive hook
228 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic
229 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic
8f0a2645 230 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e
JX
231 remote: proc-receive> ok refs/for/a/b/c/topic
232 remote: proc-receive> ok refs/for/next/topic
233 remote: proc-receive> option refname refs/pull/123/head
8f0a2645 234 remote: proc-receive> ok refs/for/main/topic
15d3af5e
JX
235 remote: proc-receive> option refname refs/pull/124/head
236 remote: proc-receive> option old-oid <COMMIT-B>
237 remote: proc-receive> option forced-update
238 remote: proc-receive> option new-oid <COMMIT-A>
239 remote: # post-receive hook
195d6eae 240 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head
15d3af5e 241 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic
195d6eae 242 remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/124/head
15d3af5e 243 To <URL/of/upstream.git>
63518a57 244 * [new reference] HEAD -> refs/pull/123/head
15d3af5e 245 * [new reference] HEAD -> refs/for/a/b/c/topic
63518a57 246 + <OID-B>...<OID-A> HEAD -> refs/pull/124/head (forced update)
15d3af5e
JX
247 EOF
248 test_cmp expect actual &&
249
250 git -C "$upstream" show-ref >out &&
251 make_user_friendly_and_stable_output <out >actual &&
252 cat >expect <<-EOF &&
8f0a2645 253 <COMMIT-A> refs/heads/main
15d3af5e
JX
254 EOF
255 test_cmp expect actual
256'