Merge branch 'ab/mediawiki-fixes'
[git] / t / t5411 / test-0026-push-options.sh
1 test_expect_success "setup proc-receive hook and disable push-options ($PROTOCOL)" '
2         git -C "$upstream" config receive.advertisePushOptions false &&
3         write_script "$upstream/hooks/proc-receive" <<-EOF
4         printf >&2 "# proc-receive hook\n"
5         test-tool proc-receive -v \
6                 -r "ok refs/for/master/topic"
7         EOF
8 '
9
10 # Refs of upstream : master(A)
11 # Refs of workbench: master(A)  tags/v123
12 # git push -o ...  :                       refs/for/master/topic
13 test_expect_success "proc-receive: not support push options ($PROTOCOL)" '
14         test_must_fail git -C workbench push \
15                 -o issue=123 \
16                 -o reviewer=user1 \
17                 origin \
18                 HEAD:refs/for/master/topic \
19                 >out 2>&1 &&
20         make_user_friendly_and_stable_output <out >actual &&
21         test_i18ngrep "fatal: the receiving end does not support push options" \
22                 actual &&
23         git -C "$upstream" show-ref >out &&
24         make_user_friendly_and_stable_output <out >actual &&
25         cat >expect <<-EOF &&
26         <COMMIT-A> refs/heads/master
27         EOF
28         test_cmp expect actual
29 '
30
31 test_expect_success "enable push options ($PROTOCOL)" '
32         git -C "$upstream" config receive.advertisePushOptions true
33 '
34
35 # Refs of upstream : master(A)
36 # Refs of workbench: master(A)  tags/v123
37 # git push -o ...  :                       next(A)  refs/for/master/topic
38 test_expect_success "proc-receive: push with options ($PROTOCOL)" '
39         git -C workbench push \
40                 --atomic \
41                 -o issue=123 \
42                 -o reviewer=user1 \
43                 origin \
44                 HEAD:refs/heads/next \
45                 HEAD:refs/for/master/topic \
46                 >out 2>&1 &&
47         make_user_friendly_and_stable_output <out >actual &&
48         cat >expect <<-EOF &&
49         remote: # pre-receive hook
50         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
51         remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
52         remote: # proc-receive hook
53         remote: proc-receive: atomic push_options
54         remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
55         remote: proc-receive< issue=123
56         remote: proc-receive< reviewer=user1
57         remote: proc-receive> ok refs/for/master/topic
58         remote: # post-receive hook
59         remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
60         remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
61         To <URL/of/upstream.git>
62          * [new branch] HEAD -> next
63          * [new reference] HEAD -> refs/for/master/topic
64         EOF
65         test_cmp expect actual &&
66         git -C "$upstream" show-ref >out &&
67         make_user_friendly_and_stable_output <out >actual &&
68         cat >expect <<-EOF &&
69         <COMMIT-A> refs/heads/master
70         <COMMIT-A> refs/heads/next
71         EOF
72         test_cmp expect actual
73 '
74
75 # Refs of upstream : master(A)             next(A)
76 # Refs of workbench: master(A)  tags/v123
77 test_expect_success "cleanup ($PROTOCOL)" '
78         git -C "$upstream" update-ref -d refs/heads/next
79 '