]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t5411/test-0000-standard-git-push.sh
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 &&
23 test_cmp_refs -C "$upstream" <<-EOF
24 <COMMIT-B> refs/heads/main
25 <COMMIT-A> refs/heads/next
29 # Refs of upstream : main(B) next(A)
30 # Refs of workbench: main(A) tags/v123
31 # git-push --atomic: main(A) next(B)
32 test_expect_success
"git-push --atomic ($PROTOCOL)" '
33 test_must_fail git -C workbench push --atomic origin \
36 >out-$test_count 2>&1 &&
37 filter_out_user_friendly_and_stable_output \
40 <out-$test_count >actual &&
42 To <URL/of/upstream.git>
43 ! [rejected] main -> main (non-fast-forward)
44 ! [rejected] <COMMIT-B> -> next (atomic push failed)
46 test_cmp expect actual &&
48 test_cmp_refs -C "$upstream" <<-EOF
49 <COMMIT-B> refs/heads/main
50 <COMMIT-A> refs/heads/next
54 # Refs of upstream : main(B) next(A)
55 # Refs of workbench: main(A) tags/v123
56 # git-push : main(A) next(B)
57 test_expect_success
"non-fast-forward git-push ($PROTOCOL)" '
60 -c advice.pushUpdateRejected=false \
64 >out-$test_count 2>&1 &&
65 make_user_friendly_and_stable_output <out-$test_count >actual &&
67 remote: # pre-receive hook
68 remote: pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/next
69 remote: # post-receive hook
70 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/heads/next
71 To <URL/of/upstream.git>
72 <OID-A>..<OID-B> <COMMIT-B> -> next
73 ! [rejected] main -> main (non-fast-forward)
75 test_cmp expect actual &&
77 test_cmp_refs -C "$upstream" <<-EOF
78 <COMMIT-B> refs/heads/main
79 <COMMIT-B> refs/heads/next
83 # Refs of upstream : main(B) next(B)
84 # Refs of workbench: main(A) tags/v123
85 # git-push -f : main(A) NULL tags/v123 refs/review/main/topic(A) a/b/c(A)
86 test_expect_success
"git-push -f ($PROTOCOL)" '
87 git -C workbench push -f origin \
91 main:refs/review/main/topic \
92 HEAD:refs/heads/a/b/c \
94 make_user_friendly_and_stable_output <out >actual &&
96 remote: # pre-receive hook
97 remote: pre-receive< <COMMIT-B> <COMMIT-A> refs/heads/main
98 remote: pre-receive< <COMMIT-B> <ZERO-OID> refs/heads/next
99 remote: pre-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
100 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic
101 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c
102 remote: # post-receive hook
103 remote: post-receive< <COMMIT-B> <COMMIT-A> refs/heads/main
104 remote: post-receive< <COMMIT-B> <ZERO-OID> refs/heads/next
105 remote: post-receive< <ZERO-OID> <TAG-v123> refs/tags/v123
106 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/review/main/topic
107 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/a/b/c
108 To <URL/of/upstream.git>
109 + <OID-B>...<OID-A> main -> main (forced update)
111 * [new tag] v123 -> v123
112 * [new reference] main -> refs/review/main/topic
113 * [new branch] HEAD -> a/b/c
115 test_cmp expect actual &&
117 test_cmp_refs -C "$upstream" <<-EOF
118 <COMMIT-A> refs/heads/a/b/c
119 <COMMIT-A> refs/heads/main
120 <COMMIT-A> refs/review/main/topic
121 <TAG-v123> refs/tags/v123
125 # Refs of upstream : main(A) tags/v123 refs/review/main/topic(A) a/b/c(A)
126 # Refs of workbench: main(A) tags/v123
127 test_expect_success
"cleanup ($PROTOCOL)" '
130 git update-ref -d refs/review/main/topic &&
131 git update-ref -d refs/tags/v123 &&
132 git update-ref -d refs/heads/a/b/c