]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5411/test-0032-report-with-options.sh
test: compare raw output, not mangle tabs and spaces
[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 \
8388a64c
JX
16 >out-$test_count 2>&1 &&
17 make_user_friendly_and_stable_output <out-$test_count >actual &&
2bafb3d7
JX
18 format_and_save_expect <<-EOF &&
19 > remote: # pre-receive hook Z
20 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
21 > remote: # proc-receive hook Z
22 > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
23 > remote: proc-receive> option refname refs/pull/123/head Z
24 > remote: proc-receive> option old-oid <COMMIT-B> Z
25 > remote: error: proc-receive reported "option" without a matching "ok/ng" directive Z
26 > To <URL/of/upstream.git>
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 &&
2bafb3d7
JX
49 format_and_save_expect <<-EOF &&
50 > remote: # pre-receive hook Z
51 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
52 > remote: # proc-receive hook Z
53 > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
54 > remote: proc-receive> ok refs/for/main/topic Z
55 > remote: proc-receive> option refname refs/pull/123/head Z
56 > remote: # post-receive hook Z
57 > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head Z
58 > To <URL/of/upstream.git>
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 &&
2bafb3d7
JX
81 format_and_save_expect <<-EOF &&
82 > remote: # pre-receive hook Z
83 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
84 > remote: # proc-receive hook Z
85 > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
86 > remote: proc-receive> ok refs/for/main/topic Z
87 > remote: proc-receive> option refname refs/pull/123/head Z
88 > remote: proc-receive> option forced-update Z
89 > remote: # post-receive hook Z
90 > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head Z
91 > To <URL/of/upstream.git>
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 &&
2bafb3d7
JX
115 format_and_save_expect <<-EOF &&
116 > remote: # pre-receive hook Z
117 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
118 > remote: # proc-receive hook Z
119 > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
120 > remote: proc-receive> ok refs/for/main/topic Z
121 > remote: proc-receive> option refname refs/pull/123/head Z
122 > remote: proc-receive> option old-oid <COMMIT-B> Z
123 > remote: # post-receive hook Z
124 > remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/123/head Z
125 > To <URL/of/upstream.git>
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 &&
2bafb3d7
JX
148 format_and_save_expect <<-EOF &&
149 > remote: # pre-receive hook Z
150 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
151 > remote: # proc-receive hook Z
152 > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
153 > remote: proc-receive> ok refs/for/main/topic Z
154 > remote: proc-receive> option old-oid <COMMIT-B> Z
155 > remote: # post-receive hook Z
156 > remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/main/topic Z
157 > To <URL/of/upstream.git>
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 &&
2bafb3d7
JX
181 format_and_save_expect <<-EOF &&
182 > remote: # pre-receive hook Z
183 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
184 > remote: # proc-receive hook Z
185 > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
186 > remote: proc-receive> ok refs/for/main/topic Z
187 > remote: proc-receive> option old-oid <COMMIT-A> Z
188 > remote: proc-receive> option new-oid <COMMIT-B> Z
189 > remote: # post-receive hook Z
190 > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic Z
191 > To <URL/of/upstream.git>
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 &&
2bafb3d7
JX
222 format_and_save_expect <<-EOF &&
223 > remote: # pre-receive hook Z
224 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic Z
225 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic Z
226 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
227 > remote: # proc-receive hook Z
228 > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic Z
229 > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic Z
230 > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z
231 > remote: proc-receive> ok refs/for/a/b/c/topic Z
232 > remote: proc-receive> ok refs/for/next/topic Z
233 > remote: proc-receive> option refname refs/pull/123/head Z
234 > remote: proc-receive> ok refs/for/main/topic Z
235 > remote: proc-receive> option refname refs/pull/124/head Z
236 > remote: proc-receive> option old-oid <COMMIT-B> Z
237 > remote: proc-receive> option forced-update Z
238 > remote: proc-receive> option new-oid <COMMIT-A> Z
239 > remote: # post-receive hook Z
240 > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head Z
241 > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic Z
242 > remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/124/head Z
243 > To <URL/of/upstream.git>
244 > * [new reference] HEAD -> refs/pull/123/head
245 > * [new reference] HEAD -> refs/for/a/b/c/topic
246 > + <OID-B>...<OID-A> HEAD -> refs/pull/124/head (forced update)
15d3af5e
JX
247 EOF
248 test_cmp expect actual &&
249
822ee894 250 test_cmp_refs -C "$upstream" <<-EOF
8f0a2645 251 <COMMIT-A> refs/heads/main
15d3af5e 252 EOF
15d3af5e 253'