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