]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5411/test-0022-report-unexpect-ref.sh
Merge branch 'jc/diffcore-rotate'
[thirdparty/git.git] / t / t5411 / test-0022-report-unexpect-ref.sh
CommitLineData
15d3af5e
JX
1test_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 \
a9568dba 5 -r "ok refs/heads/main"
15d3af5e
JX
6 EOF
7'
8
a9568dba
JS
9# Refs of upstream : main(A)
10# Refs of workbench: main(A) tags/v123
11# git push : (B) refs/for/main/topic
15d3af5e
JX
12test_expect_success "proc-receive: report unexpected ref ($PROTOCOL)" '
13 test_must_fail git -C workbench push origin \
a9568dba
JS
14 $B:refs/heads/main \
15 HEAD:refs/for/main/topic \
8388a64c
JX
16 >out-$test_count 2>&1 &&
17 make_user_friendly_and_stable_output <out-$test_count >actual &&
15d3af5e
JX
18 cat >expect <<-EOF &&
19 remote: # pre-receive hook
a9568dba
JS
20 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main
21 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
15d3af5e 22 remote: # proc-receive hook
a9568dba
JS
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
15d3af5e 26 remote: # post-receive hook
a9568dba 27 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main
15d3af5e 28 To <URL/of/upstream.git>
a9568dba
JS
29 <OID-A>..<OID-B> <COMMIT-B> -> main
30 ! [remote rejected] HEAD -> refs/for/main/topic (proc-receive failed to report status)
15d3af5e
JX
31 EOF
32 test_cmp expect actual &&
822ee894
JX
33
34 test_cmp_refs -C "$upstream" <<-EOF
a9568dba 35 <COMMIT-B> refs/heads/main
15d3af5e 36 EOF
15d3af5e
JX
37'
38
a9568dba
JS
39# Refs of upstream : main(B)
40# Refs of workbench: main(A) tags/v123
15d3af5e 41test_expect_success "cleanup ($PROTOCOL)" '
a9568dba 42 git -C "$upstream" update-ref refs/heads/main $A
15d3af5e 43'