t5411: refactor check of refs using test_cmp_refs
[alt-git.git] / t / t5411 / test-0012-no-hook-error--porcelain.sh
blob19f66fbd7dd79480c712f15713678db2ceb32a5a
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 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 &&
24 test_cmp_refs -C "$upstream" <<-EOF
25 <COMMIT-A> refs/heads/main
26 <COMMIT-A> refs/heads/next
27 EOF
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
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 cat >expect <<-EOF &&
46 remote: # pre-receive hook
47 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main
48 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
49 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic
50 remote: error: cannot find hook "proc-receive"
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 &&
59 test_cmp_refs -C "$upstream" <<-EOF
60 <COMMIT-A> refs/heads/main
61 EOF