Merge branch 'jk/multi-line-indent-style-fix'
[git] / t / t5411 / test-0022-report-unexpect-ref.sh
1 test_expect_success "setup proc-receive hook (unexpected ref, $PROTOCOL)" '
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/heads/main"
6         EOF
7 '
8
9 # Refs of upstream : main(A)
10 # Refs of workbench: main(A)  tags/v123
11 # git push         : (B)                   refs/for/main/topic
12 test_expect_success "proc-receive: report unexpected ref ($PROTOCOL)" '
13         test_must_fail git -C workbench push origin \
14                 $B:refs/heads/main \
15                 HEAD:refs/for/main/topic \
16                 >out 2>&1 &&
17         make_user_friendly_and_stable_output <out >actual &&
18         cat >expect <<-EOF &&
19         remote: # pre-receive hook
20         remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main
21         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
22         remote: # proc-receive hook
23         remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
24         remote: proc-receive> ok refs/heads/main
25         remote: error: proc-receive reported status on unexpected ref: refs/heads/main
26         remote: # post-receive hook
27         remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main
28         To <URL/of/upstream.git>
29          <OID-A>..<OID-B> <COMMIT-B> -> main
30          ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status)
31         EOF
32         test_cmp expect actual &&
33         git -C "$upstream" show-ref >out &&
34         make_user_friendly_and_stable_output <out >actual &&
35         cat >expect <<-EOF &&
36         <COMMIT-B> refs/heads/main
37         EOF
38         test_cmp expect actual
39 '
40
41 # Refs of upstream : main(B)
42 # Refs of workbench: main(A)  tags/v123
43 test_expect_success "cleanup ($PROTOCOL)" '
44         git -C "$upstream" update-ref refs/heads/main $A
45 '