]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5411/test-0001-standard-git-push--porcelain.sh
Merge branch 'jk/end-of-options' into jc/sparse-checkout-set-add-end-of-options
[thirdparty/git.git] / t / t5411 / test-0001-standard-git-push--porcelain.sh
CommitLineData
a9568dba
JS
1# Refs of upstream : main(A)
2# Refs of workbench: main(A) tags/v123
3# git-push : main(B) next(A)
38b9197a
JX
4test_expect_success "git-push ($PROTOCOL/porcelain)" '
5 git -C workbench push --porcelain origin \
a9568dba 6 $B:refs/heads/main \
38b9197a
JX
7 HEAD:refs/heads/next \
8 >out 2>&1 &&
9 make_user_friendly_and_stable_output <out >actual &&
2bafb3d7
JX
10 format_and_save_expect <<-EOF &&
11 > remote: # pre-receive hook Z
12 > remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/main Z
13 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z
14 > remote: # post-receive hook Z
15 > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/main Z
16 > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z
17 > To <URL/of/upstream.git>
12d6991c 18 > <COMMIT-B>:refs/heads/main <COMMIT-A>..<COMMIT-B>
2bafb3d7
JX
19 > * HEAD:refs/heads/next [new branch]
20 > Done
38b9197a
JX
21 EOF
22 test_cmp expect actual &&
822ee894
JX
23
24 test_cmp_refs -C "$upstream" <<-EOF
a9568dba 25 <COMMIT-B> refs/heads/main
38b9197a
JX
26 <COMMIT-A> refs/heads/next
27 EOF
38b9197a
JX
28'
29
a9568dba
JS
30# Refs of upstream : main(B) next(A)
31# Refs of workbench: main(A) tags/v123
32# git-push --atomic: main(A) next(B)
38b9197a
JX
33test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" '
34 test_must_fail git -C workbench push --atomic --porcelain origin \
a9568dba 35 main \
38b9197a 36 $B:refs/heads/next \
8388a64c 37 >out-$test_count 2>&1 &&
cf3d868f
JX
38 filter_out_user_friendly_and_stable_output \
39 -e "s/^# GETTEXT POISON #//" \
40 -e "/^To / { p; }" \
2bafb3d7 41 -e "/^!/ { p; }" \
8388a64c 42 <out-$test_count >actual &&
2bafb3d7
JX
43 format_and_save_expect <<-EOF &&
44 > To <URL/of/upstream.git>
45 > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
46 > ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed)
38b9197a
JX
47 EOF
48 test_cmp expect actual &&
822ee894
JX
49
50 test_cmp_refs -C "$upstream" <<-EOF
a9568dba 51 <COMMIT-B> refs/heads/main
38b9197a
JX
52 <COMMIT-A> refs/heads/next
53 EOF
38b9197a
JX
54'
55
a9568dba
JS
56# Refs of upstream : main(B) next(A)
57# Refs of workbench: main(A) tags/v123
58# git-push : main(A) next(B)
38b9197a
JX
59test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" '
60 test_must_fail git \
61 -C workbench \
62 -c advice.pushUpdateRejected=false \
63 push --porcelain origin \
a9568dba 64 main \
38b9197a 65 $B:refs/heads/next \
8388a64c
JX
66 >out-$test_count 2>&1 &&
67 make_user_friendly_and_stable_output <out-$test_count >actual &&
2bafb3d7
JX
68 format_and_save_expect <<-EOF &&
69 > remote: # pre-receive hook Z
70 > remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/next Z
71 > remote: # post-receive hook Z
72 > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/next Z
73 > To <URL/of/upstream.git>
12d6991c 74 > <COMMIT-B>:refs/heads/next <COMMIT-A>..<COMMIT-B>
2bafb3d7
JX
75 > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
76 > Done
38b9197a
JX
77 EOF
78 test_cmp expect actual &&
822ee894
JX
79
80 test_cmp_refs -C "$upstream" <<-EOF
a9568dba 81 <COMMIT-B> refs/heads/main
38b9197a
JX
82 <COMMIT-B> refs/heads/next
83 EOF
38b9197a
JX
84'
85
a9568dba
JS
86# Refs of upstream : main(B) next(B)
87# Refs of workbench: main(A) tags/v123
88# git-push -f : main(A) NULL tags/v123 refs/review/main/topic(A) a/b/c(A)
38b9197a
JX
89test_expect_success "git-push -f ($PROTOCOL/porcelain)" '
90 git -C workbench push --porcelain -f origin \
91 refs/tags/v123 \
92 :refs/heads/next \
a9568dba
JS
93 main \
94 main:refs/review/main/topic \
38b9197a
JX
95 HEAD:refs/heads/a/b/c \
96 >out 2>&1 &&
97 make_user_friendly_and_stable_output <out >actual &&
2bafb3d7
JX
98 format_and_save_expect <<-EOF &&
99 > remote: # pre-receive hook Z
100 > remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/main Z
101 > remote: pre-receive< <COMMIT-B> <ZERO-OID> refs/heads/next Z
102 > remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 Z
103 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic Z
104 > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c Z
105 > remote: # post-receive hook Z
106 > remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/main Z
107 > remote: post-receive< <COMMIT-B> <ZERO-OID> refs/heads/next Z
108 > remote: post-receive< <ZERO-OID> <TAG-v123> refs/tags/v123 Z
109 > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic Z
110 > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c Z
111 > To <URL/of/upstream.git>
12d6991c 112 > + refs/heads/main:refs/heads/main <COMMIT-B>...<COMMIT-A> (forced update)
2bafb3d7
JX
113 > - :refs/heads/next [deleted]
114 > * refs/tags/v123:refs/tags/v123 [new tag]
115 > * refs/heads/main:refs/review/main/topic [new reference]
116 > * HEAD:refs/heads/a/b/c [new branch]
117 > Done
38b9197a
JX
118 EOF
119 test_cmp expect actual &&
822ee894
JX
120
121 test_cmp_refs -C "$upstream" <<-EOF
38b9197a 122 <COMMIT-A> refs/heads/a/b/c
a9568dba
JS
123 <COMMIT-A> refs/heads/main
124 <COMMIT-A> refs/review/main/topic
38b9197a
JX
125 <TAG-v123> refs/tags/v123
126 EOF
38b9197a
JX
127'
128
a9568dba
JS
129# Refs of upstream : main(A) tags/v123 refs/review/main/topic(A) a/b/c(A)
130# Refs of workbench: main(A) tags/v123
38b9197a
JX
131test_expect_success "cleanup ($PROTOCOL/porcelain)" '
132 (
133 cd "$upstream" &&
a9568dba 134 git update-ref -d refs/review/main/topic &&
38b9197a
JX
135 git update-ref -d refs/tags/v123 &&
136 git update-ref -d refs/heads/a/b/c
137 )
138'