1 test_expect_success "setup proc-receive hook and disable push-options ($PROTOCOL/porcelain)" '
2 git -C "$upstream" config receive.advertisePushOptions false &&
3 write_script "$upstream/hooks/proc-receive" <<-EOF
4 printf >&2 "# proc-receive hook\n"
5 test-tool proc-receive -v \
6 -r "ok refs/for/main/topic"
10 # Refs of upstream : main(A)
11 # Refs of workbench: main(A) tags/v123
12 # git push -o ... : refs/for/main/topic
13 test_expect_success "proc-receive: not support push options ($PROTOCOL/porcelain)" '
14 test_must_fail git -C workbench push \
19 HEAD:refs/for/main/topic \
21 make_user_friendly_and_stable_output <out >actual &&
22 test_i18ngrep "fatal: the receiving end does not support push options" \
24 git -C "$upstream" show-ref >out &&
25 make_user_friendly_and_stable_output <out >actual &&
27 <COMMIT-A> refs/heads/main
29 test_cmp expect actual
32 test_expect_success "enable push options ($PROTOCOL/porcelain)" '
33 git -C "$upstream" config receive.advertisePushOptions true
36 test_expect_success "setup version=0 for proc-receive hook ($PROTOCOL/porcelain)" '
37 write_script "$upstream/hooks/proc-receive" <<-EOF
38 printf >&2 "# proc-receive hook\n"
39 test-tool proc-receive -v \
41 -r "ok refs/for/main/topic"
45 # Refs of upstream : main(A)
46 # Refs of workbench: main(A) tags/v123
47 # git push -o ... : next(A) refs/for/main/topic
48 test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL/porcelain)" '
49 git -C workbench push \
55 HEAD:refs/heads/next \
56 HEAD:refs/for/main/topic \
58 make_user_friendly_and_stable_output <out >actual &&
60 remote: # pre-receive hook
61 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
62 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
63 remote: # proc-receive hook
64 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
65 remote: proc-receive> ok refs/for/main/topic
66 remote: # post-receive hook
67 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
68 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
69 To <URL/of/upstream.git>
70 * HEAD:refs/heads/next [new branch]
71 * HEAD:refs/for/main/topic [new reference]
74 test_cmp expect actual &&
75 git -C "$upstream" show-ref >out &&
76 make_user_friendly_and_stable_output <out >actual &&
78 <COMMIT-A> refs/heads/main
79 <COMMIT-A> refs/heads/next
81 test_cmp expect actual
84 test_expect_success "restore proc-receive hook ($PROTOCOL/porcelain)" '
85 write_script "$upstream/hooks/proc-receive" <<-EOF
86 printf >&2 "# proc-receive hook\n"
87 test-tool proc-receive -v \
88 -r "ok refs/for/main/topic"
92 # Refs of upstream : main(A) next(A)
93 # Refs of workbench: main(A) tags/v123
94 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
95 git -C "$upstream" update-ref -d refs/heads/next
98 # Refs of upstream : main(A)
99 # Refs of workbench: main(A) tags/v123
100 # git push -o ... : next(A) refs/for/main/topic
101 test_expect_success "proc-receive: push with options ($PROTOCOL/porcelain)" '
102 git -C workbench push \
108 HEAD:refs/heads/next \
109 HEAD:refs/for/main/topic \
111 make_user_friendly_and_stable_output <out >actual &&
112 cat >expect <<-EOF &&
113 remote: # pre-receive hook
114 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
115 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
116 remote: # proc-receive hook
117 remote: proc-receive: atomic push_options
118 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
119 remote: proc-receive< issue=123
120 remote: proc-receive< reviewer=user1
121 remote: proc-receive> ok refs/for/main/topic
122 remote: # post-receive hook
123 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
124 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
125 To <URL/of/upstream.git>
126 * HEAD:refs/heads/next [new branch]
127 * HEAD:refs/for/main/topic [new reference]
130 test_cmp expect actual &&
131 git -C "$upstream" show-ref >out &&
132 make_user_friendly_and_stable_output <out >actual &&
133 cat >expect <<-EOF &&
134 <COMMIT-A> refs/heads/main
135 <COMMIT-A> refs/heads/next
137 test_cmp expect actual
140 # Refs of upstream : main(A) next(A)
141 # Refs of workbench: main(A) tags/v123
142 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
143 git -C "$upstream" update-ref -d refs/heads/next