fetch: fix segfault in --negotiate-only without --negotiation-tip=*
[alt-git.git] / t / t5411 / test-0027-push-options--porcelain.sh
blob447fbfec0c9045da74479d08f563ce1d175077be
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"
7 EOF
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 \
15 --porcelain \
16 -o issue=123 \
17 -o reviewer=user1 \
18 origin \
19 HEAD:refs/for/main/topic \
20 >out-$test_count 2>&1 &&
21 make_user_friendly_and_stable_output <out-$test_count >actual &&
22 test_i18ngrep "fatal: the receiving end does not support push options" \
23 actual &&
25 test_cmp_refs -C "$upstream" <<-EOF
26 <COMMIT-A> refs/heads/main
27 EOF
30 test_expect_success "enable push options ($PROTOCOL/porcelain)" '
31 git -C "$upstream" config receive.advertisePushOptions true
34 test_expect_success "setup version=0 for proc-receive hook ($PROTOCOL/porcelain)" '
35 write_script "$upstream/hooks/proc-receive" <<-EOF
36 printf >&2 "# proc-receive hook\n"
37 test-tool proc-receive -v \
38 --version 0 \
39 -r "ok refs/for/main/topic"
40 EOF
43 # Refs of upstream : main(A)
44 # Refs of workbench: main(A) tags/v123
45 # git push -o ... : next(A) refs/for/main/topic
46 test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL/porcelain)" '
47 git -C workbench push \
48 --porcelain \
49 --atomic \
50 -o issue=123 \
51 -o reviewer=user1 \
52 origin \
53 HEAD:refs/heads/next \
54 HEAD:refs/for/main/topic \
55 >out 2>&1 &&
56 make_user_friendly_and_stable_output <out >actual &&
57 cat >expect <<-EOF &&
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 * HEAD:refs/heads/next [new branch]
69 * HEAD:refs/for/main/topic [new reference]
70 Done
71 EOF
72 test_cmp expect actual &&
74 test_cmp_refs -C "$upstream" <<-EOF
75 <COMMIT-A> refs/heads/main
76 <COMMIT-A> refs/heads/next
77 EOF
80 test_expect_success "restore proc-receive hook ($PROTOCOL/porcelain)" '
81 write_script "$upstream/hooks/proc-receive" <<-EOF
82 printf >&2 "# proc-receive hook\n"
83 test-tool proc-receive -v \
84 -r "ok refs/for/main/topic"
85 EOF
88 # Refs of upstream : main(A) next(A)
89 # Refs of workbench: main(A) tags/v123
90 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
91 git -C "$upstream" update-ref -d refs/heads/next
94 # Refs of upstream : main(A)
95 # Refs of workbench: main(A) tags/v123
96 # git push -o ... : next(A) refs/for/main/topic
97 test_expect_success "proc-receive: push with options ($PROTOCOL/porcelain)" '
98 git -C workbench push \
99 --porcelain \
100 --atomic \
101 -o issue=123 \
102 -o reviewer=user1 \
103 origin \
104 HEAD:refs/heads/next \
105 HEAD:refs/for/main/topic \
106 >out 2>&1 &&
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 * HEAD:refs/heads/next [new branch]
123 * HEAD:refs/for/main/topic [new reference]
124 Done
126 test_cmp expect actual &&
128 test_cmp_refs -C "$upstream" <<-EOF
129 <COMMIT-A> refs/heads/main
130 <COMMIT-A> refs/heads/next
134 # Refs of upstream : main(A) next(A)
135 # Refs of workbench: main(A) tags/v123
136 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
137 git -C "$upstream" update-ref -d refs/heads/next