1 # Refs of upstream : main(A)
2 # Refs of workbench: main(A) tags/v123
3 # git-push : main(B) next(A)
4 test_expect_success
"git-push ($PROTOCOL/porcelain)" '
5 git -C workbench push --porcelain origin \
9 make_user_friendly_and_stable_output <out >actual &&
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>
18 > <COMMIT-B>:refs/heads/main <COMMIT-A>..<COMMIT-B>
19 > * HEAD:refs/heads/next [new branch]
22 test_cmp expect actual &&
24 test_cmp_refs -C "$upstream" <<-EOF
25 <COMMIT-B> refs/heads/main
26 <COMMIT-A> refs/heads/next
30 # Refs of upstream : main(B) next(A)
31 # Refs of workbench: main(A) tags/v123
32 # git-push --atomic: main(A) next(B)
33 test_expect_success
"git-push --atomic ($PROTOCOL/porcelain)" '
34 test_must_fail git -C workbench push --atomic --porcelain origin \
37 >out-$test_count 2>&1 &&
38 filter_out_user_friendly_and_stable_output \
39 -e "s/^# GETTEXT POISON #//" \
42 <out-$test_count >actual &&
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)
48 test_cmp expect actual &&
50 test_cmp_refs -C "$upstream" <<-EOF
51 <COMMIT-B> refs/heads/main
52 <COMMIT-A> refs/heads/next
56 # Refs of upstream : main(B) next(A)
57 # Refs of workbench: main(A) tags/v123
58 # git-push : main(A) next(B)
59 test_expect_success
"non-fast-forward git-push ($PROTOCOL/porcelain)" '
62 -c advice.pushUpdateRejected=false \
63 push --porcelain origin \
66 >out-$test_count 2>&1 &&
67 make_user_friendly_and_stable_output <out-$test_count >actual &&
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>
74 > <COMMIT-B>:refs/heads/next <COMMIT-A>..<COMMIT-B>
75 > ! refs/heads/main:refs/heads/main [rejected] (non-fast-forward)
78 test_cmp expect actual &&
80 test_cmp_refs -C "$upstream" <<-EOF
81 <COMMIT-B> refs/heads/main
82 <COMMIT-B> refs/heads/next
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)
89 test_expect_success
"git-push -f ($PROTOCOL/porcelain)" '
90 git -C workbench push --porcelain -f origin \
94 main:refs/review/main/topic \
95 HEAD:refs/heads/a/b/c \
97 make_user_friendly_and_stable_output <out >actual &&
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>
112 > + refs/heads/main:refs/heads/main <COMMIT-B>...<COMMIT-A> (forced update)
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]
119 test_cmp expect actual &&
121 test_cmp_refs -C "$upstream" <<-EOF
122 <COMMIT-A> refs/heads/a/b/c
123 <COMMIT-A> refs/heads/main
124 <COMMIT-A> refs/review/main/topic
125 <TAG-v123> refs/tags/v123
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
131 test_expect_success
"cleanup ($PROTOCOL/porcelain)" '
134 git update-ref -d refs/review/main/topic &&
135 git update-ref -d refs/tags/v123 &&
136 git update-ref -d refs/heads/a/b/c