Merge branch 'js/default-branch-name-adjust-t5515'
[git] / t / t5411 / test-0012-no-hook-error--porcelain.sh
1 # Refs of upstream : main(A)
2 # Refs of workbench: main(A)  tags/v123
3 # git push         :                       next(A)  refs/for/main/topic(A)
4 test_expect_success "proc-receive: no hook, fail to push special ref ($PROTOCOL/porcelain)" '
5         test_must_fail git -C workbench push --porcelain origin \
6                 HEAD:next \
7                 HEAD:refs/for/main/topic \
8                 >out 2>&1 &&
9         make_user_friendly_and_stable_output <out >actual &&
10         cat >expect <<-EOF &&
11         remote: # pre-receive hook
12         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
13         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
14         remote: error: cannot find hook "proc-receive"
15         remote: # post-receive hook
16         remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
17         To <URL/of/upstream.git>
18         *    HEAD:refs/heads/next    [new branch]
19         !    HEAD:refs/for/main/topic    [remote rejected] (fail to run proc-receive hook)
20         Done
21         EOF
22         test_cmp expect actual &&
23         git -C "$upstream" show-ref >out &&
24         make_user_friendly_and_stable_output <out >actual &&
25         cat >expect <<-EOF &&
26         <COMMIT-A> refs/heads/main
27         <COMMIT-A> refs/heads/next
28         EOF
29         test_cmp expect actual
30 '
31
32 # Refs of upstream : main(A)             next(A)
33 # Refs of workbench: main(A)  tags/v123
34 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
35         git -C "$upstream" update-ref -d refs/heads/next
36 '
37
38 # Refs of upstream : main(A)
39 # Refs of workbench: main(A)  tags/v123
40 # git push --atomic: (B)                   next(A)  refs/for/main/topic(A)
41 test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCOL/porcelain)" '
42         test_must_fail git -C workbench push --porcelain --atomic origin \
43                 $B:main \
44                 HEAD:next \
45                 HEAD:refs/for/main/topic >out 2>&1 &&
46         make_user_friendly_and_stable_output <out >actual &&
47         cat >expect <<-EOF &&
48         remote: # pre-receive hook
49         remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main
50         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
51         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
52         remote: error: cannot find hook "proc-receive"
53         To <URL/of/upstream.git>
54         !    <COMMIT-B>:refs/heads/main    [remote rejected] (fail to run proc-receive hook)
55         !    HEAD:refs/heads/next    [remote rejected] (fail to run proc-receive hook)
56         !    HEAD:refs/for/main/topic    [remote rejected] (fail to run proc-receive hook)
57         Done
58         EOF
59         test_cmp expect actual &&
60         git -C "$upstream" show-ref >out &&
61         make_user_friendly_and_stable_output <out >actual &&
62         cat >expect <<-EOF &&
63         <COMMIT-A> refs/heads/main
64         EOF
65         test_cmp expect actual
66 '