3 test_description
='fetching and pushing, with or without wildcard'
23 git push testrepo
$the_first_commit:refs
/$ref ||
{
24 echo "Oops, push refs/$ref failure"
31 r
=$
(git show-ref
-s --verify refs
/$ref) &&
32 test "z$r" = "z$the_first_commit" ||
{
33 echo "Oops, refs/$ref is wrong"
41 check_push_result
() {
48 r
=$
(git show-ref
-s --verify refs
/$ref) &&
49 test "z$r" = "z$it" ||
{
50 echo "Oops, refs/$ref is wrong"
58 test_expect_success setup
'
63 git commit -a -m repo &&
64 the_first_commit=$(git show-ref -s --verify refs/heads/master) &&
69 git commit -a -m second &&
70 the_commit=$(git show-ref -s --verify refs/heads/master)
74 test_expect_success
'fetch without wildcard' '
78 git fetch .. refs/heads/master:refs/remotes/origin/master &&
80 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
81 test "z$r" = "z$the_commit" &&
83 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
87 test_expect_success
'fetch with wildcard' '
91 git config remote.up.url .. &&
92 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
95 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
96 test "z$r" = "z$the_commit" &&
98 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
102 test_expect_success
'push without wildcard' '
105 git push testrepo refs/heads/master:refs/remotes/origin/master &&
108 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
109 test "z$r" = "z$the_commit" &&
111 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
115 test_expect_success
'push with wildcard' '
118 git push testrepo "refs/heads/*:refs/remotes/origin/*" &&
121 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
122 test "z$r" = "z$the_commit" &&
124 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
128 test_expect_success
'push with matching heads' '
130 mk_test heads/master &&
132 check_push_result $the_commit heads/master
136 test_expect_success
'push with no ambiguity (1)' '
138 mk_test heads/master &&
139 git push testrepo master:master &&
140 check_push_result $the_commit heads/master
144 test_expect_success
'push with no ambiguity (2)' '
146 mk_test remotes/origin/master &&
147 git push testrepo master:master &&
148 check_push_result $the_commit remotes/origin/master
152 test_expect_success
'push with weak ambiguity (1)' '
154 mk_test heads/master remotes/origin/master &&
155 git push testrepo master:master &&
156 check_push_result $the_commit heads/master &&
157 check_push_result $the_first_commit remotes/origin/master
161 test_expect_success
'push with weak ambiguity (2)' '
163 mk_test heads/master remotes/origin/master remotes/another/master &&
164 git push testrepo master:master &&
165 check_push_result $the_commit heads/master &&
166 check_push_result $the_first_commit remotes/origin/master remotes/another/master
170 test_expect_success
'push with ambiguity (1)' '
172 mk_test remotes/origin/master remotes/frotz/master &&
173 if git push testrepo master:master
175 echo "Oops, should have failed"
178 check_push_result $the_first_commit remotes/origin/master remotes/frotz/master
182 test_expect_success
'push with ambiguity (2)' '
184 mk_test heads/frotz tags/frotz &&
185 if git push testrepo master:frotz
187 echo "Oops, should have failed"
190 check_push_result $the_first_commit heads/frotz tags/frotz
195 test_expect_success
'push with colon-less refspec (1)' '
197 mk_test heads/frotz tags/frotz &&
198 git branch -f frotz master &&
199 git push testrepo frotz &&
200 check_push_result $the_commit heads/frotz &&
201 check_push_result $the_first_commit tags/frotz
205 test_expect_success
'push with colon-less refspec (2)' '
207 mk_test heads/frotz tags/frotz &&
208 if git show-ref --verify -q refs/heads/frotz
213 git push testrepo frotz &&
214 check_push_result $the_commit tags/frotz &&
215 check_push_result $the_first_commit heads/frotz
219 test_expect_success
'push with colon-less refspec (3)' '
222 if git show-ref --verify -q refs/tags/frotz
226 git branch -f frotz master &&
227 git push testrepo frotz &&
228 check_push_result $the_commit heads/frotz &&
229 test 1 = $( cd testrepo && git show-ref | wc -l )
232 test_expect_success
'push with colon-less refspec (4)' '
235 if git show-ref --verify -q refs/heads/frotz
240 git push testrepo frotz &&
241 check_push_result $the_commit tags/frotz &&
242 test 1 = $( cd testrepo && git show-ref | wc -l )