1 test_expect_success "config receive.procReceiveRefs with modifiers ($PROTOCOL)" '
4 git config --unset-all receive.procReceiveRefs &&
5 git config --add receive.procReceiveRefs m:refs/heads/master &&
6 git config --add receive.procReceiveRefs ad:refs/heads &&
7 git config --add receive.procReceiveRefs "a!:refs/heads"
11 test_expect_success "setup proc-receive hook ($PROTOCOL)" '
12 write_script "$upstream/hooks/proc-receive" <<-EOF
13 printf >&2 "# proc-receive hook\n"
14 test-tool proc-receive -v \
15 -r "ok refs/heads/master" \
16 -r "option refname refs/pull/123/head" \
17 -r "option old-oid $A" \
18 -r "option new-oid $B" \
19 -r "ok refs/tags/v123 " \
20 -r "option refname refs/pull/124/head"
24 # Refs of upstream : master(A)
25 # Refs of workbench: master(A) tags/v123
26 # git push : master(B) tags/v123
27 test_expect_success "proc-receive: update branch and new tag ($PROTOCOL)" '
28 git -C workbench push origin \
29 $B:refs/heads/master \
31 make_user_friendly_and_stable_output <out >actual &&
33 remote: # pre-receive hook
34 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
35 remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
36 remote: # proc-receive hook
37 remote: proc-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
38 remote: proc-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
39 remote: proc-receive> ok refs/heads/master
40 remote: proc-receive> option refname refs/pull/123/head
41 remote: proc-receive> option old-oid <COMMIT-A>
42 remote: proc-receive> option new-oid <COMMIT-B>
43 remote: proc-receive> ok refs/tags/v123
44 remote: proc-receive> option refname refs/pull/124/head
45 remote: # post-receive hook
46 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/pull/123/head
47 remote: post-receive< <ZERO-OID> <TAG-v123> refs/pull/124/head
48 To <URL/of/upstream.git>
49 <OID-A>..<OID-B> <COMMIT-B> -> refs/pull/123/head
50 * [new reference] v123 -> refs/pull/124/head
52 test_cmp expect actual &&
53 git -C "$upstream" show-ref >out &&
54 make_user_friendly_and_stable_output <out >actual &&
56 <COMMIT-A> refs/heads/master
58 test_cmp expect actual
61 # Refs of upstream : master(A)
62 # Refs of workbench: master(A) tags/v123
63 test_expect_success "setup upstream: create tags/v123 ($PROTOCOL)" '
64 git -C "$upstream" update-ref refs/heads/topic $A &&
65 git -C "$upstream" update-ref refs/tags/v123 $TAG &&
66 git -C "$upstream" show-ref >out &&
67 make_user_friendly_and_stable_output <out >actual &&
69 <COMMIT-A> refs/heads/master
70 <COMMIT-A> refs/heads/topic
71 <TAG-v123> refs/tags/v123
73 test_cmp expect actual
76 test_expect_success "setup proc-receive hook ($PROTOCOL)" '
77 write_script "$upstream/hooks/proc-receive" <<-EOF
78 printf >&2 "# proc-receive hook\n"
79 test-tool proc-receive -v \
80 -r "ok refs/heads/master" \
81 -r "option refname refs/pull/123/head" \
82 -r "option old-oid $A" \
83 -r "option new-oid $ZERO_OID" \
84 -r "ok refs/heads/next" \
85 -r "option refname refs/pull/124/head" \
86 -r "option new-oid $A"
90 # Refs of upstream : master(A) topic(A) tags/v123
91 # Refs of workbench: master(A) tags/v123
92 # git push : NULL topic(B) NULL next(A)
93 test_expect_success "proc-receive: create/delete branch, and delete tag ($PROTOCOL)" '
94 git -C workbench push origin \
98 :refs/tags/v123 >out 2>&1 &&
99 make_user_friendly_and_stable_output <out >actual &&
100 cat >expect <<-EOF &&
101 remote: # pre-receive hook
102 remote: pre-receive< <COMMIT-A> <ZERO-OID> refs/heads/master
103 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/topic
104 remote: pre-receive< <TAG-v123> <ZERO-OID> refs/tags/v123
105 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
106 remote: # proc-receive hook
107 remote: proc-receive< <COMMIT-A> <ZERO-OID> refs/heads/master
108 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
109 remote: proc-receive> ok refs/heads/master
110 remote: proc-receive> option refname refs/pull/123/head
111 remote: proc-receive> option old-oid <COMMIT-A>
112 remote: proc-receive> option new-oid <ZERO-OID>
113 remote: proc-receive> ok refs/heads/next
114 remote: proc-receive> option refname refs/pull/124/head
115 remote: proc-receive> option new-oid <COMMIT-A>
116 remote: # post-receive hook
117 remote: post-receive< <COMMIT-A> <ZERO-OID> refs/pull/123/head
118 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/topic
119 remote: post-receive< <TAG-v123> <ZERO-OID> refs/tags/v123
120 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/124/head
121 To <URL/of/upstream.git>
122 - [deleted] refs/pull/123/head
123 <OID-A>..<OID-B> <COMMIT-B> -> topic
125 * [new reference] <COMMIT-A> -> refs/pull/124/head
127 test_cmp expect actual &&
128 git -C "$upstream" show-ref >out &&
129 make_user_friendly_and_stable_output <out >actual &&
130 cat >expect <<-EOF &&
131 <COMMIT-A> refs/heads/master
132 <COMMIT-B> refs/heads/topic
134 test_cmp expect actual