]>
Commit | Line | Data |
---|---|---|
c6a6a01c JX |
1 | test_expect_success "setup git config for remote-tracking of special refs" ' |
2 | ( | |
3 | cd workbench && | |
4 | if ! git config --get-all remote.origin.fetch | grep refs/for/ | |
5 | then | |
6 | git config --add remote.origin.fetch \ | |
7 | "+refs/for/*:refs/t/for/*" && | |
8 | git config --add remote.origin.fetch \ | |
9 | "+refs/pull/*:refs/t/pull/*" && | |
10 | git config --add remote.origin.fetch \ | |
11 | "+refs/changes/*:refs/t/changes/*" | |
12 | fi | |
13 | ) | |
14 | ' | |
15 | ||
15d3af5e JX |
16 | test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no refname for the 1st rewrite, $PROTOCOL)" ' |
17 | write_script "$upstream/hooks/proc-receive" <<-EOF | |
18 | printf >&2 "# proc-receive hook\n" | |
19 | test-tool proc-receive -v \ | |
8f0a2645 | 20 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
21 | -r "option old-oid $A" \ |
22 | -r "option new-oid $B" \ | |
8f0a2645 | 23 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
24 | -r "option refname refs/changes/24/124/1" \ |
25 | -r "option old-oid $ZERO_OID" \ | |
26 | -r "option new-oid $A" \ | |
8f0a2645 | 27 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
28 | -r "option refname refs/changes/25/125/1" \ |
29 | -r "option old-oid $A" \ | |
30 | -r "option new-oid $B" | |
31 | EOF | |
32 | ' | |
33 | ||
8f0a2645 JS |
34 | # Refs of upstream : main(A) |
35 | # Refs of workbench: main(A) tags/v123 | |
36 | # git push : refs/for/main/topic(A) | |
15d3af5e JX |
37 | test_expect_success "proc-receive: multiple rewrite for one ref, no refname for the 1st rewrite ($PROTOCOL)" ' |
38 | git -C workbench push origin \ | |
8f0a2645 | 39 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
40 | >out 2>&1 && |
41 | make_user_friendly_and_stable_output <out >actual && | |
42 | cat >expect <<-EOF && | |
43 | remote: # pre-receive hook | |
8f0a2645 | 44 | remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic |
15d3af5e | 45 | remote: # proc-receive hook |
8f0a2645 JS |
46 | remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic |
47 | remote: proc-receive> ok refs/for/main/topic | |
15d3af5e JX |
48 | remote: proc-receive> option old-oid <COMMIT-A> |
49 | remote: proc-receive> option new-oid <COMMIT-B> | |
8f0a2645 | 50 | remote: proc-receive> ok refs/for/main/topic |
15d3af5e JX |
51 | remote: proc-receive> option refname refs/changes/24/124/1 |
52 | remote: proc-receive> option old-oid <ZERO-OID> | |
53 | remote: proc-receive> option new-oid <COMMIT-A> | |
8f0a2645 | 54 | remote: proc-receive> ok refs/for/main/topic |
15d3af5e JX |
55 | remote: proc-receive> option refname refs/changes/25/125/1 |
56 | remote: proc-receive> option old-oid <COMMIT-A> | |
57 | remote: proc-receive> option new-oid <COMMIT-B> | |
58 | remote: # post-receive hook | |
8f0a2645 | 59 | remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic |
195d6eae JX |
60 | remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 |
61 | remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/25/125/1 | |
15d3af5e | 62 | To <URL/of/upstream.git> |
8f0a2645 | 63 | <OID-A>..<OID-B> HEAD -> refs/for/main/topic |
63518a57 JX |
64 | * [new reference] HEAD -> refs/changes/24/124/1 |
65 | <OID-A>..<OID-B> HEAD -> refs/changes/25/125/1 | |
15d3af5e JX |
66 | EOF |
67 | test_cmp expect actual && | |
68 | git -C "$upstream" show-ref >out && | |
69 | make_user_friendly_and_stable_output <out >actual && | |
70 | cat >expect <<-EOF && | |
8f0a2645 | 71 | <COMMIT-A> refs/heads/main |
15d3af5e JX |
72 | EOF |
73 | test_cmp expect actual | |
74 | ' | |
75 | ||
c6a6a01c JX |
76 | test_expect_success "proc-receive: check remote-tracking #1 ($PROTOCOL)" ' |
77 | git -C workbench show-ref | | |
78 | grep -v -e refs/remotes -e refs/heads -e refs/tags >out && | |
79 | make_user_friendly_and_stable_output <out >actual && | |
80 | cat >expect <<-EOF && | |
1702ae6f JX |
81 | <COMMIT-A> refs/t/changes/24/124/1 |
82 | <COMMIT-B> refs/t/changes/25/125/1 | |
8f0a2645 | 83 | <COMMIT-B> refs/t/for/main/topic |
c6a6a01c JX |
84 | EOF |
85 | test_cmp expect actual && | |
8f0a2645 | 86 | git -C workbench update-ref -d refs/t/for/main/topic && |
1702ae6f JX |
87 | git -C workbench update-ref -d refs/t/changes/24/124/1 && |
88 | git -C workbench update-ref -d refs/t/changes/25/125/1 | |
c6a6a01c JX |
89 | ' |
90 | ||
15d3af5e JX |
91 | test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no refname for the 2nd rewrite, $PROTOCOL)" ' |
92 | write_script "$upstream/hooks/proc-receive" <<-EOF | |
93 | printf >&2 "# proc-receive hook\n" | |
94 | test-tool proc-receive -v \ | |
8f0a2645 | 95 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
96 | -r "option refname refs/changes/24/124/1" \ |
97 | -r "option old-oid $ZERO_OID" \ | |
98 | -r "option new-oid $A" \ | |
8f0a2645 | 99 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
100 | -r "option old-oid $A" \ |
101 | -r "option new-oid $B" \ | |
8f0a2645 | 102 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
103 | -r "option refname refs/changes/25/125/1" \ |
104 | -r "option old-oid $B" \ | |
105 | -r "option new-oid $A" \ | |
106 | -r "option forced-update" | |
107 | EOF | |
108 | ' | |
109 | ||
8f0a2645 JS |
110 | # Refs of upstream : main(A) |
111 | # Refs of workbench: main(A) tags/v123 | |
112 | # git push : refs/for/main/topic(A) | |
15d3af5e JX |
113 | test_expect_success "proc-receive: multiple rewrites for one ref, no refname for the 2nd rewrite ($PROTOCOL)" ' |
114 | git -C workbench push origin \ | |
8f0a2645 | 115 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
116 | >out 2>&1 && |
117 | make_user_friendly_and_stable_output <out >actual && | |
118 | cat >expect <<-EOF && | |
119 | remote: # pre-receive hook | |
8f0a2645 | 120 | remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic |
15d3af5e | 121 | remote: # proc-receive hook |
8f0a2645 JS |
122 | remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic |
123 | remote: proc-receive> ok refs/for/main/topic | |
15d3af5e JX |
124 | remote: proc-receive> option refname refs/changes/24/124/1 |
125 | remote: proc-receive> option old-oid <ZERO-OID> | |
126 | remote: proc-receive> option new-oid <COMMIT-A> | |
8f0a2645 | 127 | remote: proc-receive> ok refs/for/main/topic |
15d3af5e JX |
128 | remote: proc-receive> option old-oid <COMMIT-A> |
129 | remote: proc-receive> option new-oid <COMMIT-B> | |
8f0a2645 | 130 | remote: proc-receive> ok refs/for/main/topic |
15d3af5e JX |
131 | remote: proc-receive> option refname refs/changes/25/125/1 |
132 | remote: proc-receive> option old-oid <COMMIT-B> | |
133 | remote: proc-receive> option new-oid <COMMIT-A> | |
134 | remote: proc-receive> option forced-update | |
135 | remote: # post-receive hook | |
195d6eae | 136 | remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 |
8f0a2645 | 137 | remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic |
195d6eae | 138 | remote: post-receive< <COMMIT-B> <COMMIT-A> refs/changes/25/125/1 |
15d3af5e | 139 | To <URL/of/upstream.git> |
63518a57 | 140 | * [new reference] HEAD -> refs/changes/24/124/1 |
8f0a2645 | 141 | <OID-A>..<OID-B> HEAD -> refs/for/main/topic |
63518a57 | 142 | + <OID-B>...<OID-A> HEAD -> refs/changes/25/125/1 (forced update) |
15d3af5e JX |
143 | EOF |
144 | test_cmp expect actual && | |
145 | git -C "$upstream" show-ref >out && | |
146 | make_user_friendly_and_stable_output <out >actual && | |
147 | cat >expect <<-EOF && | |
8f0a2645 | 148 | <COMMIT-A> refs/heads/main |
15d3af5e JX |
149 | EOF |
150 | test_cmp expect actual | |
151 | ' | |
152 | ||
c6a6a01c JX |
153 | test_expect_success "proc-receive: check remote-tracking #2 ($PROTOCOL)" ' |
154 | git -C workbench show-ref | | |
155 | grep -v -e refs/remotes -e refs/heads -e refs/tags >out && | |
156 | make_user_friendly_and_stable_output <out >actual && | |
157 | cat >expect <<-EOF && | |
1702ae6f JX |
158 | <COMMIT-A> refs/t/changes/24/124/1 |
159 | <COMMIT-A> refs/t/changes/25/125/1 | |
8f0a2645 | 160 | <COMMIT-B> refs/t/for/main/topic |
c6a6a01c JX |
161 | EOF |
162 | test_cmp expect actual && | |
8f0a2645 | 163 | git -C workbench update-ref -d refs/t/for/main/topic && |
1702ae6f JX |
164 | git -C workbench update-ref -d refs/t/changes/24/124/1 && |
165 | git -C workbench update-ref -d refs/t/changes/25/125/1 | |
c6a6a01c JX |
166 | ' |
167 | ||
15d3af5e JX |
168 | test_expect_success "setup proc-receive hook (multiple rewrites for one ref, $PROTOCOL)" ' |
169 | write_script "$upstream/hooks/proc-receive" <<-EOF | |
170 | printf >&2 "# proc-receive hook\n" | |
171 | test-tool proc-receive -v \ | |
8f0a2645 | 172 | -r "ok refs/for/main/topic" \ |
15d3af5e | 173 | -r "option refname refs/changes/23/123/1" \ |
8f0a2645 | 174 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
175 | -r "option refname refs/changes/24/124/2" \ |
176 | -r "option old-oid $A" \ | |
177 | -r "option new-oid $B" | |
178 | EOF | |
179 | ' | |
180 | ||
8f0a2645 JS |
181 | # Refs of upstream : main(A) |
182 | # Refs of workbench: main(A) tags/v123 | |
183 | # git push : refs/for/main/topic(A) | |
15d3af5e JX |
184 | test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL)" ' |
185 | git -C workbench push origin \ | |
8f0a2645 | 186 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
187 | >out 2>&1 && |
188 | make_user_friendly_and_stable_output <out >actual && | |
189 | cat >expect <<-EOF && | |
190 | remote: # pre-receive hook | |
8f0a2645 | 191 | remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic |
15d3af5e | 192 | remote: # proc-receive hook |
8f0a2645 JS |
193 | remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic |
194 | remote: proc-receive> ok refs/for/main/topic | |
15d3af5e | 195 | remote: proc-receive> option refname refs/changes/23/123/1 |
8f0a2645 | 196 | remote: proc-receive> ok refs/for/main/topic |
15d3af5e JX |
197 | remote: proc-receive> option refname refs/changes/24/124/2 |
198 | remote: proc-receive> option old-oid <COMMIT-A> | |
199 | remote: proc-receive> option new-oid <COMMIT-B> | |
200 | remote: # post-receive hook | |
195d6eae JX |
201 | remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/23/123/1 |
202 | remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/24/124/2 | |
15d3af5e | 203 | To <URL/of/upstream.git> |
63518a57 JX |
204 | * [new reference] HEAD -> refs/changes/23/123/1 |
205 | <OID-A>..<OID-B> HEAD -> refs/changes/24/124/2 | |
15d3af5e JX |
206 | EOF |
207 | test_cmp expect actual && | |
208 | git -C "$upstream" show-ref >out && | |
209 | make_user_friendly_and_stable_output <out >actual && | |
210 | cat >expect <<-EOF && | |
8f0a2645 | 211 | <COMMIT-A> refs/heads/main |
15d3af5e JX |
212 | EOF |
213 | test_cmp expect actual | |
214 | ' | |
c6a6a01c JX |
215 | |
216 | test_expect_success "proc-receive: check remote-tracking #3 ($PROTOCOL)" ' | |
217 | git -C workbench show-ref | | |
218 | grep -v -e refs/remotes -e refs/heads -e refs/tags >out && | |
219 | make_user_friendly_and_stable_output <out >actual && | |
220 | cat >expect <<-EOF && | |
1702ae6f JX |
221 | <COMMIT-A> refs/t/changes/23/123/1 |
222 | <COMMIT-B> refs/t/changes/24/124/2 | |
c6a6a01c JX |
223 | EOF |
224 | test_cmp expect actual && | |
1702ae6f JX |
225 | git -C workbench update-ref -d refs/t/changes/24/124/1 && |
226 | git -C workbench update-ref -d refs/t/changes/25/125/2 | |
c6a6a01c | 227 | ' |