New capability "report-status-v2" for git-push
[git.git] / t / t5411 / once-0010-report-status-v1.sh
blobbf410dc4187ee9d554fd1242d7ef949e4219d493
1 test_expect_success "setup proc-receive hook" '
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/topic1" \
6 -r "option fall-through" \
7 -r "ok refs/for/master/topic2" \
8 -r "option refname refs/for/changes/23/123/1" \
9 -r "option new-oid $A" \
10 -r "ok refs/for/master/topic2" \
11 -r "option refname refs/for/changes/24/124/2" \
12 -r "option old-oid $B" \
13 -r "option new-oid $A" \
14 -r "option forced-update" \
15 -r "ng refs/for/next/topic target branch not exist"
16 EOF
19 # Refs of upstream : master(A)
20 # Refs of workbench: master(A) tags/v123
21 # git push : (B) refs/for/master/topic1(A) foo(A) refs/for/next/topic(A) refs/for/master/topic2(A)
22 test_expect_success "proc-receive: report status v1" '
24 if test -z "$GIT_DEFAULT_HASH" || test "$GIT_DEFAULT_HASH" = "sha1"
25 then
26 printf "%s %s refs/heads/master\0report-status\n" \
27 $A $B | packetize
28 else
29 printf "%s %s refs/heads/master\0report-status object-format=$GIT_DEFAULT_HASH\n" \
30 $A $B | packetize
31 fi &&
32 printf "%s %s refs/for/master/topic1\n" \
33 $ZERO_OID $A | packetize &&
34 printf "%s %s refs/heads/foo\n" \
35 $ZERO_OID $A | packetize &&
36 printf "%s %s refs/for/next/topic\n" \
37 $ZERO_OID $A | packetize &&
38 printf "%s %s refs/for/master/topic2\n" \
39 $ZERO_OID $A | packetize &&
40 printf 0000 &&
41 printf "" | git -C "$upstream" pack-objects --stdout
42 } | git receive-pack "$upstream" --stateless-rpc \
43 >out 2>&1 &&
44 make_user_friendly_and_stable_output <out >actual &&
45 cat >expect <<-EOF &&
46 # pre-receive hook
47 pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
48 pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1
49 pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo
50 pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic
51 pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic2
52 # proc-receive hook
53 proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1
54 proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic
55 proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic2
56 proc-receive> ok refs/for/master/topic1
57 proc-receive> option fall-through
58 proc-receive> ok refs/for/master/topic2
59 proc-receive> option refname refs/for/changes/23/123/1
60 proc-receive> option new-oid <COMMIT-A>
61 proc-receive> ok refs/for/master/topic2
62 proc-receive> option refname refs/for/changes/24/124/2
63 proc-receive> option old-oid <COMMIT-B>
64 proc-receive> option new-oid <COMMIT-A>
65 proc-receive> option forced-update
66 proc-receive> ng refs/for/next/topic target branch not exist
67 000eunpack ok
68 0019ok refs/heads/master
69 001eok refs/for/master/topic1
70 0016ok refs/heads/foo
71 0033ng refs/for/next/topic target branch not exist
72 001eok refs/for/master/topic2
73 0000# post-receive hook
74 post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
75 post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1
76 post-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo
77 post-receive< <ZERO-OID> <COMMIT-A> refs/for/changes/23/123/1
78 post-receive< <COMMIT-B> <COMMIT-A> refs/for/changes/24/124/2
79 EOF
80 test_cmp expect actual &&
82 git -C "$upstream" show-ref >out &&
83 make_user_friendly_and_stable_output <out >actual &&
84 cat >expect <<-EOF &&
85 <COMMIT-A> refs/for/master/topic1
86 <COMMIT-A> refs/heads/foo
87 <COMMIT-B> refs/heads/master
88 EOF
89 test_cmp expect actual