]>
Commit | Line | Data |
---|---|---|
15d3af5e | 1 | test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no refname for the 1st rewrite, $PROTOCOL/porcelain)" ' |
c39176b1 | 2 | test_hook -C "$upstream" --clobber proc-receive <<-EOF |
15d3af5e JX |
3 | printf >&2 "# proc-receive hook\n" |
4 | test-tool proc-receive -v \ | |
8f0a2645 | 5 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
6 | -r "option old-oid $A" \ |
7 | -r "option new-oid $B" \ | |
8f0a2645 | 8 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
9 | -r "option refname refs/changes/24/124/1" \ |
10 | -r "option old-oid $ZERO_OID" \ | |
11 | -r "option new-oid $A" \ | |
8f0a2645 | 12 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
13 | -r "option refname refs/changes/25/125/1" \ |
14 | -r "option old-oid $A" \ | |
15 | -r "option new-oid $B" | |
16 | EOF | |
17 | ' | |
18 | ||
8f0a2645 JS |
19 | # Refs of upstream : main(A) |
20 | # Refs of workbench: main(A) tags/v123 | |
21 | # git push : refs/for/main/topic(A) | |
15d3af5e JX |
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 \ | |
8f0a2645 | 24 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
25 | >out 2>&1 && |
26 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
27 | format_and_save_expect <<-EOF && |
28 | > remote: # pre-receive hook Z | |
29 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
30 | > remote: # proc-receive hook Z | |
31 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
32 | > remote: proc-receive> ok refs/for/main/topic Z | |
33 | > remote: proc-receive> option old-oid <COMMIT-A> Z | |
34 | > remote: proc-receive> option new-oid <COMMIT-B> Z | |
35 | > remote: proc-receive> ok refs/for/main/topic Z | |
36 | > remote: proc-receive> option refname refs/changes/24/124/1 Z | |
37 | > remote: proc-receive> option old-oid <ZERO-OID> Z | |
38 | > remote: proc-receive> option new-oid <COMMIT-A> Z | |
39 | > remote: proc-receive> ok refs/for/main/topic Z | |
40 | > remote: proc-receive> option refname refs/changes/25/125/1 Z | |
41 | > remote: proc-receive> option old-oid <COMMIT-A> Z | |
42 | > remote: proc-receive> option new-oid <COMMIT-B> Z | |
43 | > remote: # post-receive hook Z | |
44 | > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic Z | |
45 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 Z | |
46 | > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/25/125/1 Z | |
47 | > To <URL/of/upstream.git> | |
12d6991c | 48 | > HEAD:refs/for/main/topic <COMMIT-A>..<COMMIT-B> |
2bafb3d7 | 49 | > * HEAD:refs/changes/24/124/1 [new reference] |
12d6991c | 50 | > HEAD:refs/changes/25/125/1 <COMMIT-A>..<COMMIT-B> |
2bafb3d7 | 51 | > Done |
15d3af5e JX |
52 | EOF |
53 | test_cmp expect actual && | |
822ee894 JX |
54 | |
55 | test_cmp_refs -C "$upstream" <<-EOF | |
8f0a2645 | 56 | <COMMIT-A> refs/heads/main |
15d3af5e | 57 | EOF |
15d3af5e JX |
58 | ' |
59 | ||
60 | test_expect_success "setup proc-receive hook (multiple rewrites for one ref, no refname for the 2nd rewrite, $PROTOCOL/porcelain)" ' | |
c39176b1 | 61 | test_hook -C "$upstream" --clobber proc-receive <<-EOF |
15d3af5e JX |
62 | printf >&2 "# proc-receive hook\n" |
63 | test-tool proc-receive -v \ | |
8f0a2645 | 64 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
65 | -r "option refname refs/changes/24/124/1" \ |
66 | -r "option old-oid $ZERO_OID" \ | |
67 | -r "option new-oid $A" \ | |
8f0a2645 | 68 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
69 | -r "option old-oid $A" \ |
70 | -r "option new-oid $B" \ | |
8f0a2645 | 71 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
72 | -r "option refname refs/changes/25/125/1" \ |
73 | -r "option old-oid $B" \ | |
74 | -r "option new-oid $A" \ | |
75 | -r "option forced-update" | |
76 | EOF | |
77 | ' | |
78 | ||
8f0a2645 JS |
79 | # Refs of upstream : main(A) |
80 | # Refs of workbench: main(A) tags/v123 | |
81 | # git push : refs/for/main/topic(A) | |
15d3af5e JX |
82 | test_expect_success "proc-receive: multiple rewrites for one ref, no refname for the 2nd rewrite ($PROTOCOL/porcelain)" ' |
83 | git -C workbench push --porcelain origin \ | |
8f0a2645 | 84 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
85 | >out 2>&1 && |
86 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
87 | format_and_save_expect <<-EOF && |
88 | > remote: # pre-receive hook Z | |
89 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
90 | > remote: # proc-receive hook Z | |
91 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
92 | > remote: proc-receive> ok refs/for/main/topic Z | |
93 | > remote: proc-receive> option refname refs/changes/24/124/1 Z | |
94 | > remote: proc-receive> option old-oid <ZERO-OID> Z | |
95 | > remote: proc-receive> option new-oid <COMMIT-A> Z | |
96 | > remote: proc-receive> ok refs/for/main/topic Z | |
97 | > remote: proc-receive> option old-oid <COMMIT-A> Z | |
98 | > remote: proc-receive> option new-oid <COMMIT-B> Z | |
99 | > remote: proc-receive> ok refs/for/main/topic Z | |
100 | > remote: proc-receive> option refname refs/changes/25/125/1 Z | |
101 | > remote: proc-receive> option old-oid <COMMIT-B> Z | |
102 | > remote: proc-receive> option new-oid <COMMIT-A> Z | |
103 | > remote: proc-receive> option forced-update Z | |
104 | > remote: # post-receive hook Z | |
105 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 Z | |
106 | > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic Z | |
107 | > remote: post-receive< <COMMIT-B> <COMMIT-A> refs/changes/25/125/1 Z | |
108 | > To <URL/of/upstream.git> | |
109 | > * HEAD:refs/changes/24/124/1 [new reference] | |
12d6991c JX |
110 | > HEAD:refs/for/main/topic <COMMIT-A>..<COMMIT-B> |
111 | > + HEAD:refs/changes/25/125/1 <COMMIT-B>...<COMMIT-A> (forced update) | |
2bafb3d7 | 112 | > Done |
15d3af5e JX |
113 | EOF |
114 | test_cmp expect actual && | |
822ee894 JX |
115 | |
116 | test_cmp_refs -C "$upstream" <<-EOF | |
8f0a2645 | 117 | <COMMIT-A> refs/heads/main |
15d3af5e | 118 | EOF |
15d3af5e JX |
119 | ' |
120 | ||
121 | test_expect_success "setup proc-receive hook (multiple rewrites for one ref, $PROTOCOL/porcelain)" ' | |
c39176b1 | 122 | test_hook -C "$upstream" --clobber proc-receive <<-EOF |
15d3af5e JX |
123 | printf >&2 "# proc-receive hook\n" |
124 | test-tool proc-receive -v \ | |
8f0a2645 | 125 | -r "ok refs/for/main/topic" \ |
15d3af5e | 126 | -r "option refname refs/changes/23/123/1" \ |
8f0a2645 | 127 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
128 | -r "option refname refs/changes/24/124/2" \ |
129 | -r "option old-oid $A" \ | |
130 | -r "option new-oid $B" | |
131 | EOF | |
132 | ' | |
133 | ||
8f0a2645 JS |
134 | # Refs of upstream : main(A) |
135 | # Refs of workbench: main(A) tags/v123 | |
136 | # git push : refs/for/main/topic(A) | |
15d3af5e JX |
137 | test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porcelain)" ' |
138 | git -C workbench push --porcelain origin \ | |
8f0a2645 | 139 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
140 | >out 2>&1 && |
141 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
142 | format_and_save_expect <<-EOF && |
143 | > remote: # pre-receive hook Z | |
144 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
145 | > remote: # proc-receive hook Z | |
146 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
147 | > remote: proc-receive> ok refs/for/main/topic Z | |
148 | > remote: proc-receive> option refname refs/changes/23/123/1 Z | |
149 | > remote: proc-receive> ok refs/for/main/topic Z | |
150 | > remote: proc-receive> option refname refs/changes/24/124/2 Z | |
151 | > remote: proc-receive> option old-oid <COMMIT-A> Z | |
152 | > remote: proc-receive> option new-oid <COMMIT-B> Z | |
153 | > remote: # post-receive hook Z | |
154 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/23/123/1 Z | |
155 | > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/24/124/2 Z | |
156 | > To <URL/of/upstream.git> | |
157 | > * HEAD:refs/changes/23/123/1 [new reference] | |
12d6991c | 158 | > HEAD:refs/changes/24/124/2 <COMMIT-A>..<COMMIT-B> |
2bafb3d7 | 159 | > Done |
15d3af5e JX |
160 | EOF |
161 | test_cmp expect actual && | |
822ee894 JX |
162 | |
163 | test_cmp_refs -C "$upstream" <<-EOF | |
8f0a2645 | 164 | <COMMIT-A> refs/heads/main |
15d3af5e | 165 | EOF |
15d3af5e | 166 | ' |