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)" '
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/main
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/main
16 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
17 To <URL/of/upstream.git>
18 <OID-A>..<OID-B> <COMMIT-B> -> main
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/main
26 <COMMIT-A> refs/heads/next
28 test_cmp expect actual
31 # Refs of upstream : main(B) next(A)
32 # Refs of workbench: main(A) tags/v123
33 # git-push --atomic: main(A) next(B)
34 test_expect_success "git-push --atomic ($PROTOCOL)" '
35 test_must_fail git -C workbench push --atomic origin \
39 filter_out_user_friendly_and_stable_output \
44 To <URL/of/upstream.git>
45 ! [rejected] main -> main (non-fast-forward)
46 ! [rejected] <COMMIT-B> -> next (atomic push failed)
48 test_cmp expect actual &&
49 git -C "$upstream" show-ref >out &&
50 make_user_friendly_and_stable_output <out >actual &&
52 <COMMIT-B> refs/heads/main
53 <COMMIT-A> refs/heads/next
55 test_cmp expect actual
58 # Refs of upstream : main(B) next(A)
59 # Refs of workbench: main(A) tags/v123
60 # git-push : main(A) next(B)
61 test_expect_success "non-fast-forward git-push ($PROTOCOL)" '
64 -c advice.pushUpdateRejected=false \
69 make_user_friendly_and_stable_output <out >actual &&
71 remote: # pre-receive hook
72 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/next
73 remote: # post-receive hook
74 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/next
75 To <URL/of/upstream.git>
76 <OID-A>..<OID-B> <COMMIT-B> -> next
77 ! [rejected] main -> main (non-fast-forward)
79 test_cmp expect actual &&
80 git -C "$upstream" show-ref >out &&
81 make_user_friendly_and_stable_output <out >actual &&
83 <COMMIT-B> refs/heads/main
84 <COMMIT-B> refs/heads/next
86 test_cmp expect actual
89 # Refs of upstream : main(B) next(B)
90 # Refs of workbench: main(A) tags/v123
91 # git-push -f : main(A) NULL tags/v123 refs/review/main/topic(A) a/b/c(A)
92 test_expect_success "git-push -f ($PROTOCOL)" '
93 git -C workbench push -f origin \
97 main:refs/review/main/topic \
98 HEAD:refs/heads/a/b/c \
100 make_user_friendly_and_stable_output <out >actual &&
101 cat >expect <<-EOF &&
102 remote: # pre-receive hook
103 remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/main
104 remote: pre-receive< <COMMIT-B> <ZERO-OID> refs/heads/next
105 remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
106 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic
107 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c
108 remote: # post-receive hook
109 remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/main
110 remote: post-receive< <COMMIT-B> <ZERO-OID> refs/heads/next
111 remote: post-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
112 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic
113 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c
114 To <URL/of/upstream.git>
115 + <OID-B>...<OID-A> main -> main (forced update)
117 * [new tag] v123 -> v123
118 * [new reference] main -> refs/review/main/topic
119 * [new branch] HEAD -> a/b/c
121 test_cmp expect actual &&
122 git -C "$upstream" show-ref >out &&
123 make_user_friendly_and_stable_output <out >actual &&
124 cat >expect <<-EOF &&
125 <COMMIT-A> refs/heads/a/b/c
126 <COMMIT-A> refs/heads/main
127 <COMMIT-A> refs/review/main/topic
128 <TAG-v123> refs/tags/v123
130 test_cmp expect actual
133 # Refs of upstream : main(A) tags/v123 refs/review/main/topic(A) a/b/c(A)
134 # Refs of workbench: main(A) tags/v123
135 test_expect_success "cleanup ($PROTOCOL)" '
138 git update-ref -d refs/review/main/topic &&
139 git update-ref -d refs/tags/v123 &&
140 git update-ref -d refs/heads/a/b/c