Merge branch 'ab/config-based-hooks-base' into seen
[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-$test_count 2>&1 &&
9         make_user_friendly_and_stable_output <out-$test_count >actual &&
10         format_and_save_expect <<-EOF &&
11         > remote: # pre-receive hook        Z
12         > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next        Z
13         > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic        Z
14         > remote: error: cannot find hook "proc-receive"        Z
15         > remote: # post-receive hook        Z
16         > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next        Z
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
24         test_cmp_refs -C "$upstream" <<-EOF
25         <COMMIT-A> refs/heads/main
26         <COMMIT-A> refs/heads/next
27         EOF
28 '
29
30 # Refs of upstream : main(A)             next(A)
31 # Refs of workbench: main(A)  tags/v123
32 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
33         git -C "$upstream" update-ref -d refs/heads/next
34 '
35
36 # Refs of upstream : main(A)
37 # Refs of workbench: main(A)  tags/v123
38 # git push --atomic: (B)                   next(A)  refs/for/main/topic(A)
39 test_expect_success "proc-receive: no hook, all failed for atomic push ($PROTOCOL/porcelain)" '
40         test_must_fail git -C workbench push --porcelain --atomic origin \
41                 $B:main \
42                 HEAD:next \
43                 HEAD:refs/for/main/topic >out-$test_count 2>&1 &&
44         make_user_friendly_and_stable_output <out-$test_count >actual &&
45         format_and_save_expect <<-EOF &&
46         > remote: # pre-receive hook        Z
47         > remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main        Z
48         > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next        Z
49         > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic        Z
50         > remote: error: cannot find hook "proc-receive"        Z
51         > To <URL/of/upstream.git>
52         > !     <COMMIT-B>:refs/heads/main      [remote rejected] (fail to run proc-receive hook)
53         > !     HEAD:refs/heads/next    [remote rejected] (fail to run proc-receive hook)
54         > !     HEAD:refs/for/main/topic        [remote rejected] (fail to run proc-receive hook)
55         > Done
56         EOF
57         test_cmp expect actual &&
58
59         test_cmp_refs -C "$upstream" <<-EOF
60         <COMMIT-A> refs/heads/main
61         EOF
62 '