1 # Refs of upstream : master(A)
2 # Refs of workbench: master(A) tags/v123
3 # git-push : master(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 &&
11 remote: # pre-receive hook
12 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
13 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
14 remote: # post-receive hook
15 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master
16 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
17 To <URL/of/upstream.git>
18 <COMMIT-B>:refs/heads/master <OID-A>..<OID-B>
19 * HEAD:refs/heads/next [new branch]
22 test_cmp expect actual &&
23 git -C "$upstream" show-ref >out &&
24 make_user_friendly_and_stable_output <out >actual &&
26 <COMMIT-B> refs/heads/master
27 <COMMIT-A> refs/heads/next
29 test_cmp expect actual
32 # Refs of upstream : master(B) next(A)
33 # Refs of workbench: master(A) tags/v123
34 # git-push --atomic: master(A) next(B)
35 test_expect_success "git-push --atomic ($PROTOCOL/porcelain)" '
36 test_must_fail git -C workbench push --atomic --porcelain origin \
40 make_user_friendly_and_stable_output <out |
42 -e "s/^# GETTEXT POISON #//" \
43 -e "/^To / { s/ */ /g; p; }" \
44 -e "/^! / { s/ */ /g; p; }" \
47 To <URL/of/upstream.git>
48 ! refs/heads/master:refs/heads/master [rejected] (non-fast-forward)
49 ! <COMMIT-B>:refs/heads/next [rejected] (atomic push failed)
51 test_cmp expect actual &&
52 git -C "$upstream" show-ref >out &&
53 make_user_friendly_and_stable_output <out >actual &&
55 <COMMIT-B> refs/heads/master
56 <COMMIT-A> refs/heads/next
58 test_cmp expect actual
61 # Refs of upstream : master(B) next(A)
62 # Refs of workbench: master(A) tags/v123
63 # git-push : master(A) next(B)
64 test_expect_success "non-fast-forward git-push ($PROTOCOL/porcelain)" '
67 -c advice.pushUpdateRejected=false \
68 push --porcelain origin \
72 make_user_friendly_and_stable_output <out >actual &&
74 remote: # pre-receive hook
75 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/next
76 remote: # post-receive hook
77 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/next
78 To <URL/of/upstream.git>
79 <COMMIT-B>:refs/heads/next <OID-A>..<OID-B>
80 ! refs/heads/master:refs/heads/master [rejected] (non-fast-forward)
83 test_cmp expect actual &&
84 git -C "$upstream" show-ref >out &&
85 make_user_friendly_and_stable_output <out >actual &&
87 <COMMIT-B> refs/heads/master
88 <COMMIT-B> refs/heads/next
90 test_cmp expect actual
93 # Refs of upstream : master(B) next(B)
94 # Refs of workbench: master(A) tags/v123
95 # git-push -f : master(A) NULL tags/v123 refs/review/master/topic(A) a/b/c(A)
96 test_expect_success "git-push -f ($PROTOCOL/porcelain)" '
97 git -C workbench push --porcelain -f origin \
101 master:refs/review/master/topic \
102 HEAD:refs/heads/a/b/c \
104 make_user_friendly_and_stable_output <out >actual &&
105 cat >expect <<-EOF &&
106 remote: # pre-receive hook
107 remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/master
108 remote: pre-receive< <COMMIT-B> <ZERO-OID> refs/heads/next
109 remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
110 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/master/topic
111 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c
112 remote: # post-receive hook
113 remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/master
114 remote: post-receive< <COMMIT-B> <ZERO-OID> refs/heads/next
115 remote: post-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
116 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/master/topic
117 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c
118 To <URL/of/upstream.git>
119 + refs/heads/master:refs/heads/master <OID-B>...<OID-A> (forced update)
120 - :refs/heads/next [deleted]
121 * refs/tags/v123:refs/tags/v123 [new tag]
122 * refs/heads/master:refs/review/master/topic [new reference]
123 * HEAD:refs/heads/a/b/c [new branch]
126 test_cmp expect actual &&
127 git -C "$upstream" show-ref >out &&
128 make_user_friendly_and_stable_output <out >actual &&
129 cat >expect <<-EOF &&
130 <COMMIT-A> refs/heads/a/b/c
131 <COMMIT-A> refs/heads/master
132 <COMMIT-A> refs/review/master/topic
133 <TAG-v123> refs/tags/v123
135 test_cmp expect actual
138 # Refs of upstream : master(A) tags/v123 refs/review/master/topic(A) a/b/c(A)
139 # Refs of workbench: master(A) tags/v123
140 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
143 git update-ref -d refs/review/master/topic &&
144 git update-ref -d refs/tags/v123 &&
145 git update-ref -d refs/heads/a/b/c