split-index: do not invalidate cache-tree at read time
[git/debian.git] / t / t5533-push-cas.sh
blobba20d83333155b824506c33014019c1ce8868d68
1 #!/bin/sh
3 test_description='compare & swap push force/delete safety'
5 . ./test-lib.sh
7 setup_srcdst_basic () {
8 rm -fr src dst &&
9 git clone --no-local . src &&
10 git clone --no-local src dst &&
12 cd src && git checkout HEAD^0
16 test_expect_success setup '
17 : create template repository
18 test_commit A &&
19 test_commit B &&
20 test_commit C
23 test_expect_success 'push to update (protected)' '
24 setup_srcdst_basic &&
26 cd dst &&
27 test_commit D &&
28 test_must_fail git push --force-with-lease=master:master origin master
29 ) &&
30 git ls-remote . refs/heads/master >expect &&
31 git ls-remote src refs/heads/master >actual &&
32 test_cmp expect actual
35 test_expect_success 'push to update (protected, forced)' '
36 setup_srcdst_basic &&
38 cd dst &&
39 test_commit D &&
40 git push --force --force-with-lease=master:master origin master
41 ) &&
42 git ls-remote dst refs/heads/master >expect &&
43 git ls-remote src refs/heads/master >actual &&
44 test_cmp expect actual
47 test_expect_success 'push to update (protected, tracking)' '
48 setup_srcdst_basic &&
50 cd src &&
51 git checkout master &&
52 test_commit D &&
53 git checkout HEAD^0
54 ) &&
55 git ls-remote src refs/heads/master >expect &&
57 cd dst &&
58 test_commit E &&
59 git ls-remote . refs/remotes/origin/master >expect &&
60 test_must_fail git push --force-with-lease=master origin master &&
61 git ls-remote . refs/remotes/origin/master >actual &&
62 test_cmp expect actual
63 ) &&
64 git ls-remote src refs/heads/master >actual &&
65 test_cmp expect actual
68 test_expect_success 'push to update (protected, tracking, forced)' '
69 setup_srcdst_basic &&
71 cd src &&
72 git checkout master &&
73 test_commit D &&
74 git checkout HEAD^0
75 ) &&
77 cd dst &&
78 test_commit E &&
79 git ls-remote . refs/remotes/origin/master >expect &&
80 git push --force --force-with-lease=master origin master
81 ) &&
82 git ls-remote dst refs/heads/master >expect &&
83 git ls-remote src refs/heads/master >actual &&
84 test_cmp expect actual
87 test_expect_success 'push to update (allowed)' '
88 setup_srcdst_basic &&
90 cd dst &&
91 test_commit D &&
92 git push --force-with-lease=master:master^ origin master
93 ) &&
94 git ls-remote dst refs/heads/master >expect &&
95 git ls-remote src refs/heads/master >actual &&
96 test_cmp expect actual
99 test_expect_success 'push to update (allowed, tracking)' '
100 setup_srcdst_basic &&
102 cd dst &&
103 test_commit D &&
104 git push --force-with-lease=master origin master
105 ) &&
106 git ls-remote dst refs/heads/master >expect &&
107 git ls-remote src refs/heads/master >actual &&
108 test_cmp expect actual
111 test_expect_success 'push to update (allowed even though no-ff)' '
112 setup_srcdst_basic &&
114 cd dst &&
115 git reset --hard HEAD^ &&
116 test_commit D &&
117 git push --force-with-lease=master origin master
118 ) &&
119 git ls-remote dst refs/heads/master >expect &&
120 git ls-remote src refs/heads/master >actual &&
121 test_cmp expect actual
124 test_expect_success 'push to delete (protected)' '
125 setup_srcdst_basic &&
126 git ls-remote src refs/heads/master >expect &&
128 cd dst &&
129 test_must_fail git push --force-with-lease=master:master^ origin :master
130 ) &&
131 git ls-remote src refs/heads/master >actual &&
132 test_cmp expect actual
135 test_expect_success 'push to delete (protected, forced)' '
136 setup_srcdst_basic &&
138 cd dst &&
139 git push --force --force-with-lease=master:master^ origin :master
140 ) &&
141 >expect &&
142 git ls-remote src refs/heads/master >actual &&
143 test_cmp expect actual
146 test_expect_success 'push to delete (allowed)' '
147 setup_srcdst_basic &&
149 cd dst &&
150 git push --force-with-lease=master origin :master
151 ) &&
152 >expect &&
153 git ls-remote src refs/heads/master >actual &&
154 test_cmp expect actual
157 test_expect_success 'cover everything with default force-with-lease (protected)' '
158 setup_srcdst_basic &&
160 cd src &&
161 git branch naster master^
163 git ls-remote src refs/heads/\* >expect &&
165 cd dst &&
166 test_must_fail git push --force-with-lease origin master master:naster
167 ) &&
168 git ls-remote src refs/heads/\* >actual &&
169 test_cmp expect actual
172 test_expect_success 'cover everything with default force-with-lease (allowed)' '
173 setup_srcdst_basic &&
175 cd src &&
176 git branch naster master^
179 cd dst &&
180 git fetch &&
181 git push --force-with-lease origin master master:naster
182 ) &&
183 git ls-remote dst refs/heads/master |
184 sed -e "s/master/naster/" >expect &&
185 git ls-remote src refs/heads/naster >actual &&
186 test_cmp expect actual
189 test_done