3 test_description='pushing to a mirror repository'
18 rm -rf master mirror &&
23 git config receive.denyCurrentBranch warn
29 git remote add $1 up ../mirror
35 test_expect_success 'push mirror creates new branches' '
40 echo one >foo && git add foo && git commit -m one &&
43 master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
44 mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
45 test "$master_master" = "$mirror_master"
49 test_expect_success 'push mirror updates existing branches' '
54 echo one >foo && git add foo && git commit -m one &&
55 git push --mirror up &&
56 echo two >foo && git add foo && git commit -m two &&
59 master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
60 mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
61 test "$master_master" = "$mirror_master"
65 test_expect_success 'push mirror force updates existing branches' '
70 echo one >foo && git add foo && git commit -m one &&
71 git push --mirror up &&
72 echo two >foo && git add foo && git commit -m two &&
73 git push --mirror up &&
74 git reset --hard HEAD^
77 master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
78 mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
79 test "$master_master" = "$mirror_master"
83 test_expect_success 'push mirror removes branches' '
88 echo one >foo && git add foo && git commit -m one &&
89 git branch remove master &&
90 git push --mirror up &&
96 invert git show-ref -s --verify refs/heads/remove
101 test_expect_success 'push mirror adds, updates and removes branches together' '
106 echo one >foo && git add foo && git commit -m one &&
107 git branch remove master &&
108 git push --mirror up &&
109 git branch -D remove &&
110 git branch add master &&
111 echo two >foo && git add foo && git commit -m two &&
114 master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
115 master_add=$(cd master && git show-ref -s --verify refs/heads/add) &&
116 mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
117 mirror_add=$(cd mirror && git show-ref -s --verify refs/heads/add) &&
118 test "$master_master" = "$mirror_master" &&
119 test "$master_add" = "$mirror_add" &&
122 invert git show-ref -s --verify refs/heads/remove
129 test_expect_success 'push mirror creates new tags' '
134 echo one >foo && git add foo && git commit -m one &&
135 git tag -f tmaster master &&
138 master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
139 mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
140 test "$master_master" = "$mirror_master"
144 test_expect_success 'push mirror updates existing tags' '
149 echo one >foo && git add foo && git commit -m one &&
150 git tag -f tmaster master &&
151 git push --mirror up &&
152 echo two >foo && git add foo && git commit -m two &&
153 git tag -f tmaster master &&
156 master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
157 mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
158 test "$master_master" = "$mirror_master"
162 test_expect_success 'push mirror force updates existing tags' '
167 echo one >foo && git add foo && git commit -m one &&
168 git tag -f tmaster master &&
169 git push --mirror up &&
170 echo two >foo && git add foo && git commit -m two &&
171 git tag -f tmaster master &&
172 git push --mirror up &&
173 git reset --hard HEAD^
174 git tag -f tmaster master &&
177 master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
178 mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
179 test "$master_master" = "$mirror_master"
183 test_expect_success 'push mirror removes tags' '
188 echo one >foo && git add foo && git commit -m one &&
189 git tag -f tremove master &&
190 git push --mirror up &&
196 invert git show-ref -s --verify refs/tags/tremove
201 test_expect_success 'push mirror adds, updates and removes tags together' '
206 echo one >foo && git add foo && git commit -m one &&
207 git tag -f tmaster master &&
208 git tag -f tremove master &&
209 git push --mirror up &&
210 git tag -d tremove &&
211 git tag tadd master &&
212 echo two >foo && git add foo && git commit -m two &&
213 git tag -f tmaster master &&
216 master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
217 master_add=$(cd master && git show-ref -s --verify refs/tags/tadd) &&
218 mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
219 mirror_add=$(cd mirror && git show-ref -s --verify refs/tags/tadd) &&
220 test "$master_master" = "$mirror_master" &&
221 test "$master_add" = "$mirror_add" &&
224 invert git show-ref -s --verify refs/tags/tremove
229 test_expect_success 'remote.foo.mirror adds and removes branches' '
231 mk_repo_pair --mirror &&
234 echo one >foo && git add foo && git commit -m one &&
235 git branch keep master &&
236 git branch remove master &&
243 git show-ref -s --verify refs/heads/keep &&
244 invert git show-ref -s --verify refs/heads/remove
249 test_expect_success 'remote.foo.mirror=no has no effect' '
254 echo one >foo && git add foo && git commit -m one &&
255 git config --add remote.up.mirror no &&
256 git branch keep master &&
257 git push --mirror up &&
258 git branch -D keep &&
263 git show-ref -s --verify refs/heads/keep