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)" '
5 git -C workbench push 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 <OID-A>..<OID-B> <COMMIT-B> -> master
19 * [new branch] HEAD -> next
21 test_cmp expect actual &&
22 git -C "$upstream" show-ref >out &&
23 make_user_friendly_and_stable_output <out >actual &&
25 <COMMIT-B> refs/heads/master
26 <COMMIT-A> refs/heads/next
28 test_cmp expect actual
31 # Refs of upstream : master(B) next(A)
32 # Refs of workbench: master(A) tags/v123
33 # git-push --atomic: master(A) next(B)
34 test_expect_success "git-push --atomic ($PROTOCOL)" '
35 test_must_fail git -C workbench push --atomic origin \
39 make_user_friendly_and_stable_output <out |
41 -e "/^To / { s/ */ /g; p; }" \
42 -e "/^ ! / { s/ */ /g; p; }" \
45 To <URL/of/upstream.git>
46 ! [rejected] master -> master (non-fast-forward)
47 ! [rejected] <COMMIT-B> -> next (atomic push failed)
49 test_cmp expect actual &&
50 git -C "$upstream" show-ref >out &&
51 make_user_friendly_and_stable_output <out >actual &&
53 <COMMIT-B> refs/heads/master
54 <COMMIT-A> refs/heads/next
56 test_cmp expect actual
59 # Refs of upstream : master(B) next(A)
60 # Refs of workbench: master(A) tags/v123
61 # git-push : master(A) next(B)
62 test_expect_success "non-fast-forward git-push ($PROTOCOL)" '
65 -c advice.pushUpdateRejected=false \
70 make_user_friendly_and_stable_output <out >actual &&
72 remote: # pre-receive hook
73 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/next
74 remote: # post-receive hook
75 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/next
76 To <URL/of/upstream.git>
77 <OID-A>..<OID-B> <COMMIT-B> -> next
78 ! [rejected] master -> master (non-fast-forward)
80 test_cmp expect actual &&
81 git -C "$upstream" show-ref >out &&
82 make_user_friendly_and_stable_output <out >actual &&
84 <COMMIT-B> refs/heads/master
85 <COMMIT-B> refs/heads/next
87 test_cmp expect actual
90 # Refs of upstream : master(B) next(B)
91 # Refs of workbench: master(A) tags/v123
92 # git-push -f : master(A) NULL tags/v123 refs/review/master/topic(A) a/b/c(A)
93 test_expect_success "git-push -f ($PROTOCOL)" '
94 git -C workbench push -f origin \
98 master:refs/review/master/topic \
99 HEAD:refs/heads/a/b/c \
101 make_user_friendly_and_stable_output <out >actual &&
102 cat >expect <<-EOF &&
103 remote: # pre-receive hook
104 remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/master
105 remote: pre-receive< <COMMIT-B> <ZERO-OID> refs/heads/next
106 remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
107 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/master/topic
108 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c
109 remote: # post-receive hook
110 remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/master
111 remote: post-receive< <COMMIT-B> <ZERO-OID> refs/heads/next
112 remote: post-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
113 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/master/topic
114 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c
115 To <URL/of/upstream.git>
116 + <OID-B>...<OID-A> master -> master (forced update)
118 * [new tag] v123 -> v123
119 * [new reference] master -> refs/review/master/topic
120 * [new branch] HEAD -> a/b/c
122 test_cmp expect actual &&
123 git -C "$upstream" show-ref >out &&
124 make_user_friendly_and_stable_output <out >actual &&
125 cat >expect <<-EOF &&
126 <COMMIT-A> refs/heads/a/b/c
127 <COMMIT-A> refs/heads/master
128 <COMMIT-A> refs/review/master/topic
129 <TAG-v123> refs/tags/v123
131 test_cmp expect actual
134 # Refs of upstream : master(A) tags/v123 refs/review/master/topic(A) a/b/c(A)
135 # Refs of workbench: master(A) tags/v123
136 test_expect_success "cleanup ($PROTOCOL)" '
139 git update-ref -d refs/review/master/topic &&
140 git update-ref -d refs/tags/v123 &&
141 git update-ref -d refs/heads/a/b/c