1 test_expect_success "setup proc-receive hook ($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/next/topic2" \
6 -r "ng refs/for/next/topic1 fail to call Web API" \
7 -r "ok refs/for/master/topic" \
8 -r "option refname refs/for/master/topic" \
9 -r "option old-oid $A" \
10 -r "option new-oid $B"
14 # Refs of upstream : master(A)
15 # Refs of workbench: master(A) tags/v123
16 # git push : (B) bar(A) baz(A) refs/for/next/topic(A) foo(A) refs/for/master/topic(A)
17 test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcelain)" '
18 test_must_fail git -C workbench push --porcelain origin \
19 $B:refs/heads/master \
22 HEAD:refs/for/next/topic2 \
23 HEAD:refs/for/next/topic1 \
25 HEAD:refs/for/master/topic \
26 HEAD:refs/for/next/topic3 \
28 make_user_friendly_and_stable_output <out >actual &&
30 remote: # pre-receive hook
31 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
32 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/bar
33 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/baz
34 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic2
35 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic1
36 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo
37 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
38 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic3
39 remote: # proc-receive hook
40 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic2
41 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic1
42 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
43 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic3
44 remote: proc-receive> ok refs/for/next/topic2
45 remote: proc-receive> ng refs/for/next/topic1 fail to call Web API
46 remote: proc-receive> ok refs/for/master/topic
47 remote: proc-receive> option refname refs/for/master/topic
48 remote: proc-receive> option old-oid <COMMIT-A>
49 remote: proc-receive> option new-oid <COMMIT-B>
50 remote: # post-receive hook
51 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
52 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/bar
53 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/baz
54 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic2
55 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo
56 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic
57 To <URL/of/upstream.git>
58 <COMMIT-B>:refs/heads/master <OID-A>..<OID-B>
59 * HEAD:refs/heads/bar [new branch]
60 * HEAD:refs/heads/baz [new branch]
61 * HEAD:refs/for/next/topic2 [new reference]
62 * HEAD:refs/heads/foo [new branch]
63 HEAD:refs/for/master/topic <OID-A>..<OID-B>
64 ! HEAD:refs/for/next/topic1 [remote rejected] (fail to call Web API)
65 ! HEAD:refs/for/next/topic3 [remote rejected] (proc-receive failed to report status)
68 test_cmp expect actual &&
69 git -C "$upstream" show-ref >out &&
70 make_user_friendly_and_stable_output <out >actual &&
72 <COMMIT-A> refs/heads/bar
73 <COMMIT-A> refs/heads/baz
74 <COMMIT-A> refs/heads/foo
75 <COMMIT-B> refs/heads/master
77 test_cmp expect actual
80 # Refs of upstream : master(B) foo(A) bar(A)) baz(A)
81 # Refs of workbench: master(A) tags/v123
82 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
85 git update-ref refs/heads/master $A &&
86 git update-ref -d refs/heads/foo &&
87 git update-ref -d refs/heads/bar &&
88 git update-ref -d refs/heads/baz