Merge branch 'pw/rebase-i-orig-head'
[git] / t / t5411 / test-0024-report-unknown-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/for/main/topic"
6         EOF
7 '
8
9 # Refs of upstream : main(A)
10 # Refs of workbench: main(A)  tags/v123
11 # git push         :                       refs/for/a/b/c/my/topic
12 test_expect_success "proc-receive: report unknown reference ($PROTOCOL)" '
13         test_must_fail git -C workbench push origin \
14                 HEAD:refs/for/a/b/c/my/topic \
15                 >out 2>&1 &&
16         make_user_friendly_and_stable_output <out >actual &&
17         cat >expect <<-EOF &&
18         remote: # pre-receive hook
19         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/my/topic
20         remote: # proc-receive hook
21         remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/my/topic
22         remote: proc-receive> ok refs/for/main/topic
23         remote: error: proc-receive reported status on unknown ref: refs/for/main/topic
24         To <URL/of/upstream.git>
25          ! [remote rejected] HEAD -> refs/for/a/b/c/my/topic (proc-receive failed to report status)
26         EOF
27         test_cmp expect actual &&
28         git -C "$upstream" show-ref >out &&
29         make_user_friendly_and_stable_output <out >actual &&
30         cat >expect <<-EOF &&
31         <COMMIT-A> refs/heads/main
32         EOF
33         test_cmp expect actual
34 '