3 test_description
='pushing to a mirror repository'
18 rm -rf master mirror
&&
28 git config remote.up.url ..
/mirror
34 test_expect_success
'push mirror creates new branches' '
39 echo one >foo && git add foo && git commit -m one &&
42 master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
43 mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
44 test "$master_master" = "$mirror_master"
48 test_expect_success
'push mirror updates existing branches' '
53 echo one >foo && git add foo && git commit -m one &&
54 git push --mirror up &&
55 echo two >foo && git add foo && git commit -m two &&
58 master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
59 mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
60 test "$master_master" = "$mirror_master"
64 test_expect_success
'push mirror force updates existing branches' '
69 echo one >foo && git add foo && git commit -m one &&
70 git push --mirror up &&
71 echo two >foo && git add foo && git commit -m two &&
72 git push --mirror up &&
73 git reset --hard HEAD^
76 master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
77 mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
78 test "$master_master" = "$mirror_master"
82 test_expect_success
'push mirror removes branches' '
87 echo one >foo && git add foo && git commit -m one &&
88 git branch remove master &&
89 git push --mirror up &&
95 invert git show-ref -s --verify refs/heads/remove
100 test_expect_success
'push mirror adds, updates and removes branches together' '
105 echo one >foo && git add foo && git commit -m one &&
106 git branch remove master &&
107 git push --mirror up &&
108 git branch -D remove &&
109 git branch add master &&
110 echo two >foo && git add foo && git commit -m two &&
113 master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
114 master_add=$(cd master && git show-ref -s --verify refs/heads/add) &&
115 mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
116 mirror_add=$(cd mirror && git show-ref -s --verify refs/heads/add) &&
117 test "$master_master" = "$mirror_master" &&
118 test "$master_add" = "$mirror_add" &&
121 invert git show-ref -s --verify refs/heads/remove
128 test_expect_success
'push mirror creates new tags' '
133 echo one >foo && git add foo && git commit -m one &&
134 git tag -f tmaster master &&
137 master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
138 mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
139 test "$master_master" = "$mirror_master"
143 test_expect_success
'push mirror updates existing tags' '
148 echo one >foo && git add foo && git commit -m one &&
149 git tag -f tmaster master &&
150 git push --mirror up &&
151 echo two >foo && git add foo && git commit -m two &&
152 git tag -f tmaster master &&
155 master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
156 mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
157 test "$master_master" = "$mirror_master"
161 test_expect_success
'push mirror force updates existing tags' '
166 echo one >foo && git add foo && git commit -m one &&
167 git tag -f tmaster master &&
168 git push --mirror up &&
169 echo two >foo && git add foo && git commit -m two &&
170 git tag -f tmaster master &&
171 git push --mirror up &&
172 git reset --hard HEAD^
173 git tag -f tmaster master &&
176 master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
177 mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
178 test "$master_master" = "$mirror_master"
182 test_expect_success
'push mirror removes tags' '
187 echo one >foo && git add foo && git commit -m one &&
188 git tag -f tremove master &&
189 git push --mirror up &&
195 invert git show-ref -s --verify refs/tags/tremove
200 test_expect_success
'push mirror adds, updates and removes tags together' '
205 echo one >foo && git add foo && git commit -m one &&
206 git tag -f tmaster master &&
207 git tag -f tremove master &&
208 git push --mirror up &&
209 git tag -d tremove &&
210 git tag tadd master &&
211 echo two >foo && git add foo && git commit -m two &&
212 git tag -f tmaster master &&
215 master_master=$(cd master && git show-ref -s --verify refs/tags/tmaster) &&
216 master_add=$(cd master && git show-ref -s --verify refs/tags/tadd) &&
217 mirror_master=$(cd mirror && git show-ref -s --verify refs/tags/tmaster) &&
218 mirror_add=$(cd mirror && git show-ref -s --verify refs/tags/tadd) &&
219 test "$master_master" = "$mirror_master" &&
220 test "$master_add" = "$mirror_add" &&
223 invert git show-ref -s --verify refs/tags/tremove