]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5411/test-0014-bad-protocol--porcelain.sh
t5411: new helper filter_out_user_friendly_and_stable_output
[thirdparty/git.git] / t / t5411 / test-0014-bad-protocol--porcelain.sh
CommitLineData
15d3af5e
JX
1test_expect_success "setup proc-receive hook (unknown version, $PROTOCOL/porcelain)" '
2 write_script "$upstream/hooks/proc-receive" <<-EOF
3 printf >&2 "# proc-receive hook\n"
4 test-tool proc-receive -v --version 2
5 EOF
6'
7
a9568dba
JS
8# Refs of upstream : main(A)
9# Refs of workbench: main(A) tags/v123
10# git push : refs/for/main/topic(A)
15d3af5e
JX
11test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porcelain)" '
12 test_must_fail git -C workbench push --porcelain origin \
a9568dba 13 HEAD:refs/for/main/topic \
15d3af5e
JX
14 >out 2>&1 &&
15 make_user_friendly_and_stable_output <out >actual &&
16
17 # Check status report for git-push
18 sed -n \
19 -e "/^To / { p; n; p; n; p; }" \
20 <actual >actual-report &&
21 cat >expect <<-EOF &&
22 To <URL/of/upstream.git>
a9568dba 23 ! HEAD:refs/for/main/topic [remote rejected] (fail to run proc-receive hook)
15d3af5e
JX
24 Done
25 EOF
26 test_cmp expect actual-report &&
27
28 # Check error message from "receive-pack", but ignore unstable fatal error
29 # message ("remote: fatal: the remote end hung up unexpectedly") which
30 # is different from the remote HTTP server with different locale settings.
31 grep "^remote: error:" <actual >actual-error &&
32 cat >expect <<-EOF &&
33 remote: error: proc-receive version "2" is not supported
34 EOF
35 test_cmp expect actual-error &&
36
37 git -C "$upstream" show-ref >out &&
38 make_user_friendly_and_stable_output <out >actual &&
39 cat >expect <<-EOF &&
a9568dba 40 <COMMIT-A> refs/heads/main
15d3af5e
JX
41 EOF
42 test_cmp expect actual
43'
44
45test_expect_success "setup proc-receive hook (no report, $PROTOCOL/porcelain)" '
46 write_script "$upstream/hooks/proc-receive" <<-EOF
47 printf >&2 "# proc-receive hook\n"
48 test-tool proc-receive -v
49 EOF
50'
51
a9568dba
JS
52# Refs of upstream : main(A)
53# Refs of workbench: main(A) tags/v123
54# git push : next(A) refs/for/main/topic(A)
15d3af5e
JX
55test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)" '
56 test_must_fail git -C workbench push --porcelain origin \
57 HEAD:refs/heads/next \
a9568dba 58 HEAD:refs/for/main/topic >out 2>&1 &&
15d3af5e
JX
59 make_user_friendly_and_stable_output <out >actual &&
60 cat >expect <<-EOF &&
61 remote: # pre-receive hook
62 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
a9568dba 63 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 64 remote: # proc-receive hook
a9568dba 65 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e
JX
66 remote: # post-receive hook
67 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
68 To <URL/of/upstream.git>
69 * HEAD:refs/heads/next [new branch]
a9568dba 70 ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status)
15d3af5e
JX
71 Done
72 EOF
73 test_cmp expect actual &&
74 git -C "$upstream" show-ref >out &&
75 make_user_friendly_and_stable_output <out >actual &&
76 cat >expect <<-EOF &&
a9568dba 77 <COMMIT-A> refs/heads/main
15d3af5e
JX
78 <COMMIT-A> refs/heads/next
79 EOF
80 test_cmp expect actual
81'
82
a9568dba
JS
83# Refs of upstream : main(A) next(A)
84# Refs of workbench: main(A) tags/v123
15d3af5e
JX
85test_expect_success "cleanup ($PROTOCOL/porcelain)" '
86 git -C "$upstream" update-ref -d refs/heads/next
87
88'
89
90test_expect_success "setup proc-receive hook (no ref, $PROTOCOL/porcelain)" '
91 write_script "$upstream/hooks/proc-receive" <<-EOF
92 printf >&2 "# proc-receive hook\n"
93 test-tool proc-receive -v \
94 -r "ok"
95 EOF
96'
97
a9568dba
JS
98# Refs of upstream : main(A)
99# Refs of workbench: main(A) tags/v123
100# git push : refs/for/main/topic
15d3af5e
JX
101test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" '
102 test_must_fail git -C workbench push --porcelain origin \
a9568dba 103 HEAD:refs/for/main/topic\
15d3af5e
JX
104 >out 2>&1 &&
105 make_user_friendly_and_stable_output <out >actual &&
106 cat >expect <<-EOF &&
107 remote: # pre-receive hook
a9568dba 108 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 109 remote: # proc-receive hook
a9568dba 110 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e
JX
111 remote: proc-receive> ok
112 remote: error: proc-receive reported incomplete status line: "ok"
113 To <URL/of/upstream.git>
a9568dba 114 ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status)
15d3af5e
JX
115 Done
116 EOF
117 test_cmp expect actual &&
118 git -C "$upstream" show-ref >out &&
119 make_user_friendly_and_stable_output <out >actual &&
120 cat >expect <<-EOF &&
a9568dba 121 <COMMIT-A> refs/heads/main
15d3af5e
JX
122 EOF
123 test_cmp expect actual
124'
125
126test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL/porcelain)" '
127 write_script "$upstream/hooks/proc-receive" <<-EOF
128 printf >&2 "# proc-receive hook\n"
129 test-tool proc-receive -v \
a9568dba 130 -r "xx refs/for/main/topic"
15d3af5e
JX
131 EOF
132'
133
a9568dba
JS
134# Refs of upstream : main(A)
135# Refs of workbench: main(A) tags/v123
136# git push : refs/for/main/topic
15d3af5e
JX
137test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porcelain)" '
138 test_must_fail git -C workbench push --porcelain origin \
a9568dba 139 HEAD:refs/for/main/topic \
15d3af5e
JX
140 >out 2>&1 &&
141 make_user_friendly_and_stable_output <out >actual &&
142 cat >expect <<-EOF &&
143 remote: # pre-receive hook
a9568dba 144 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 145 remote: # proc-receive hook
a9568dba
JS
146 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
147 remote: proc-receive> xx refs/for/main/topic
148 remote: error: proc-receive reported bad status "xx" on ref "refs/for/main/topic"
15d3af5e 149 To <URL/of/upstream.git>
a9568dba 150 ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status)
15d3af5e
JX
151 Done
152 EOF
153 test_cmp expect actual &&
154 git -C "$upstream" show-ref >out &&
155 make_user_friendly_and_stable_output <out >actual &&
156 cat >expect <<-EOF &&
a9568dba 157 <COMMIT-A> refs/heads/main
15d3af5e
JX
158 EOF
159 test_cmp expect actual
160'