1 test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no refname for the 1st rewrite, $PROTOCOL/porcelain)" '
2 write_script "$upstream/hooks/proc-receive" <<-EOF
3 printf >&2 "# proc-receive hook\n"
4 test-tool proc-receive -v \
5 -r "ok refs/for/master/topic" \
6 -r "option old-oid $A" \
7 -r "option new-oid $B" \
8 -r "ok refs/for/master/topic" \
9 -r "option refname refs/changes/24/124/1" \
10 -r "option old-oid $ZERO_OID" \
11 -r "option new-oid $A" \
12 -r "ok refs/for/master/topic" \
13 -r "option refname refs/changes/25/125/1" \
14 -r "option old-oid $A" \
15 -r "option new-oid $B"
19 # Refs of upstream : master(A)
20 # Refs of workbench: master(A) tags/v123
21 # git push : refs/for/master/topic(A)
22 test_expect_success "proc-receive: multiple rewrite for one ref, no refname for the 1st rewrite ($PROTOCOL/porcelain)" '
23 git -C workbench push --porcelain origin \
24 HEAD:refs/for/master/topic \
26 make_user_friendly_and_stable_output <out >actual &&
28 remote: # pre-receive hook
29 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
30 remote: # proc-receive hook
31 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
32 remote: proc-receive> ok refs/for/master/topic
33 remote: proc-receive> option old-oid <COMMIT-A>
34 remote: proc-receive> option new-oid <COMMIT-B>
35 remote: proc-receive> ok refs/for/master/topic
36 remote: proc-receive> option refname refs/changes/24/124/1
37 remote: proc-receive> option old-oid <ZERO-OID>
38 remote: proc-receive> option new-oid <COMMIT-A>
39 remote: proc-receive> ok refs/for/master/topic
40 remote: proc-receive> option refname refs/changes/25/125/1
41 remote: proc-receive> option old-oid <COMMIT-A>
42 remote: proc-receive> option new-oid <COMMIT-B>
43 remote: # post-receive hook
44 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic
45 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1
46 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/25/125/1
47 To <URL/of/upstream.git>
48 HEAD:refs/for/master/topic <OID-A>..<OID-B>
49 * HEAD:refs/changes/24/124/1 [new reference]
50 HEAD:refs/changes/25/125/1 <OID-A>..<OID-B>
53 test_cmp expect actual &&
54 git -C "$upstream" show-ref >out &&
55 make_user_friendly_and_stable_output <out >actual &&
57 <COMMIT-A> refs/heads/master
59 test_cmp expect actual
62 test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no refname for the 2nd rewrite, $PROTOCOL/porcelain)" '
63 write_script "$upstream/hooks/proc-receive" <<-EOF
64 printf >&2 "# proc-receive hook\n"
65 test-tool proc-receive -v \
66 -r "ok refs/for/master/topic" \
67 -r "option refname refs/changes/24/124/1" \
68 -r "option old-oid $ZERO_OID" \
69 -r "option new-oid $A" \
70 -r "ok refs/for/master/topic" \
71 -r "option old-oid $A" \
72 -r "option new-oid $B" \
73 -r "ok refs/for/master/topic" \
74 -r "option refname refs/changes/25/125/1" \
75 -r "option old-oid $B" \
76 -r "option new-oid $A" \
77 -r "option forced-update"
81 # Refs of upstream : master(A)
82 # Refs of workbench: master(A) tags/v123
83 # git push : refs/for/master/topic(A)
84 test_expect_success "proc-receive: multiple rewrites for one ref, no refname for the 2nd rewrite ($PROTOCOL/porcelain)" '
85 git -C workbench push --porcelain origin \
86 HEAD:refs/for/master/topic \
88 make_user_friendly_and_stable_output <out >actual &&
90 remote: # pre-receive hook
91 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
92 remote: # proc-receive hook
93 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
94 remote: proc-receive> ok refs/for/master/topic
95 remote: proc-receive> option refname refs/changes/24/124/1
96 remote: proc-receive> option old-oid <ZERO-OID>
97 remote: proc-receive> option new-oid <COMMIT-A>
98 remote: proc-receive> ok refs/for/master/topic
99 remote: proc-receive> option old-oid <COMMIT-A>
100 remote: proc-receive> option new-oid <COMMIT-B>
101 remote: proc-receive> ok refs/for/master/topic
102 remote: proc-receive> option refname refs/changes/25/125/1
103 remote: proc-receive> option old-oid <COMMIT-B>
104 remote: proc-receive> option new-oid <COMMIT-A>
105 remote: proc-receive> option forced-update
106 remote: # post-receive hook
107 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1
108 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic
109 remote: post-receive< <COMMIT-B> <COMMIT-A> refs/changes/25/125/1
110 To <URL/of/upstream.git>
111 * HEAD:refs/changes/24/124/1 [new reference]
112 HEAD:refs/for/master/topic <OID-A>..<OID-B>
113 + HEAD:refs/changes/25/125/1 <OID-B>...<OID-A> (forced update)
116 test_cmp expect actual &&
117 git -C "$upstream" show-ref >out &&
118 make_user_friendly_and_stable_output <out >actual &&
119 cat >expect <<-EOF &&
120 <COMMIT-A> refs/heads/master
122 test_cmp expect actual
125 test_expect_success "setup proc-receive hook (multiple rewrites for one ref, $PROTOCOL/porcelain)" '
126 write_script "$upstream/hooks/proc-receive" <<-EOF
127 printf >&2 "# proc-receive hook\n"
128 test-tool proc-receive -v \
129 -r "ok refs/for/master/topic" \
130 -r "option refname refs/changes/23/123/1" \
131 -r "ok refs/for/master/topic" \
132 -r "option refname refs/changes/24/124/2" \
133 -r "option old-oid $A" \
134 -r "option new-oid $B"
138 # Refs of upstream : master(A)
139 # Refs of workbench: master(A) tags/v123
140 # git push : refs/for/master/topic(A)
141 test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porcelain)" '
142 git -C workbench push --porcelain origin \
143 HEAD:refs/for/master/topic \
145 make_user_friendly_and_stable_output <out >actual &&
146 cat >expect <<-EOF &&
147 remote: # pre-receive hook
148 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
149 remote: # proc-receive hook
150 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
151 remote: proc-receive> ok refs/for/master/topic
152 remote: proc-receive> option refname refs/changes/23/123/1
153 remote: proc-receive> ok refs/for/master/topic
154 remote: proc-receive> option refname refs/changes/24/124/2
155 remote: proc-receive> option old-oid <COMMIT-A>
156 remote: proc-receive> option new-oid <COMMIT-B>
157 remote: # post-receive hook
158 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/23/123/1
159 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/24/124/2
160 To <URL/of/upstream.git>
161 * HEAD:refs/changes/23/123/1 [new reference]
162 HEAD:refs/changes/24/124/2 <OID-A>..<OID-B>
165 test_cmp expect actual &&
166 git -C "$upstream" show-ref >out &&
167 make_user_friendly_and_stable_output <out >actual &&
168 cat >expect <<-EOF &&
169 <COMMIT-A> refs/heads/master
171 test_cmp expect actual