1 test_expect_success "setup proc-receive hook and disable push-options ($PROTOCOL)" '
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)" '
14 test_must_fail git -C workbench push \
18 HEAD:refs/for/main/topic \
20 make_user_friendly_and_stable_output <out >actual &&
21 test_i18ngrep "fatal: the receiving end does not support push options" \
23 git -C "$upstream" show-ref >out &&
24 make_user_friendly_and_stable_output <out >actual &&
26 <COMMIT-A> refs/heads/main
28 test_cmp expect actual
31 test_expect_success "enable push options ($PROTOCOL)" '
32 git -C "$upstream" config receive.advertisePushOptions true
35 test_expect_success "setup version=0 for proc-receive hook ($PROTOCOL)" '
36 write_script "$upstream/hooks/proc-receive" <<-EOF
37 printf >&2 "# proc-receive hook\n"
38 test-tool proc-receive -v \
40 -r "ok refs/for/main/topic"
44 # Refs of upstream : main(A)
45 # Refs of workbench: main(A) tags/v123
46 # git push -o ... : next(A) refs/for/main/topic
47 test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL)" '
48 git -C workbench push \
53 HEAD:refs/heads/next \
54 HEAD:refs/for/main/topic \
56 make_user_friendly_and_stable_output <out >actual &&
58 remote: # pre-receive hook
59 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
60 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
61 remote: # proc-receive hook
62 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
63 remote: proc-receive> ok refs/for/main/topic
64 remote: # post-receive hook
65 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
66 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
67 To <URL/of/upstream.git>
68 * [new branch] HEAD -> next
69 * [new reference] HEAD -> refs/for/main/topic
71 test_cmp expect actual &&
72 git -C "$upstream" show-ref >out &&
73 make_user_friendly_and_stable_output <out >actual &&
75 <COMMIT-A> refs/heads/main
76 <COMMIT-A> refs/heads/next
78 test_cmp expect actual
81 test_expect_success "restore proc-receive hook ($PROTOCOL)" '
82 write_script "$upstream/hooks/proc-receive" <<-EOF
83 printf >&2 "# proc-receive hook\n"
84 test-tool proc-receive -v \
85 -r "ok refs/for/main/topic"
89 # Refs of upstream : main(A) next(A)
90 # Refs of workbench: main(A) tags/v123
91 test_expect_success "cleanup ($PROTOCOL)" '
92 git -C "$upstream" update-ref -d refs/heads/next
95 # Refs of upstream : main(A)
96 # Refs of workbench: main(A) tags/v123
97 # git push -o ... : next(A) refs/for/main/topic
98 test_expect_success "proc-receive: push with options ($PROTOCOL)" '
99 git -C workbench push \
104 HEAD:refs/heads/next \
105 HEAD:refs/for/main/topic \
107 make_user_friendly_and_stable_output <out >actual &&
108 cat >expect <<-EOF &&
109 remote: # pre-receive hook
110 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
111 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
112 remote: # proc-receive hook
113 remote: proc-receive: atomic push_options
114 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
115 remote: proc-receive< issue=123
116 remote: proc-receive< reviewer=user1
117 remote: proc-receive> ok refs/for/main/topic
118 remote: # post-receive hook
119 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
120 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
121 To <URL/of/upstream.git>
122 * [new branch] HEAD -> next
123 * [new reference] HEAD -> refs/for/main/topic
125 test_cmp expect actual &&
126 git -C "$upstream" show-ref >out &&
127 make_user_friendly_and_stable_output <out >actual &&
128 cat >expect <<-EOF &&
129 <COMMIT-A> refs/heads/main
130 <COMMIT-A> refs/heads/next
132 test_cmp expect actual
135 # Refs of upstream : main(A) next(A)
136 # Refs of workbench: main(A) tags/v123
137 test_expect_success "cleanup ($PROTOCOL)" '
138 git -C "$upstream" update-ref -d refs/heads/next