3 # Copyright (c) 2010 Sverre Rabbelier
6 test_description
='Test remote-helper import and export commands'
10 if ! test_have_prereq PYTHON
; then
11 skip_all
='skipping git-remote-hg tests, python not available'
17 if sys.hexversion < 0x02040000:
20 skip_all
='skipping git-remote-hg tests, python version < 2.4'
25 git
--git-dir="$1/.git" rev-parse
--verify $2 >expect
&&
26 git
--git-dir="$3/.git" rev-parse
--verify $4 >actual
&&
27 test_cmp expect actual
30 test_expect_success
'setup repository' '
31 git init --bare server/.git &&
32 git clone server public &&
37 git push origin master)
40 test_expect_success
'cloning from local repo' '
41 git clone "testgit::${PWD}/server" localclone &&
42 test_cmp public/file localclone/file
45 test_expect_success
'cloning from remote repo' '
46 git clone "testgit::file://${PWD}/server" clone &&
47 test_cmp public/file clone/file
50 test_expect_success
'create new commit on remote' '
52 echo content >>file &&
53 git commit -a -m two &&
57 test_expect_success
'pulling from local repo' '
58 (cd localclone && git pull) &&
59 test_cmp public/file localclone/file
62 test_expect_success
'pulling from remote remote' '
63 (cd clone && git pull) &&
64 test_cmp public/file clone/file
67 test_expect_success
'pushing to local repo' '
69 echo content >>file &&
70 git commit -a -m three &&
72 compare_refs localclone HEAD server HEAD
75 # Generally, skip this test. It demonstrates a now-fixed race in
76 # git-remote-testgit, but is too slow to leave in for general use.
77 : test_expect_success
'racily pushing to local repo' '
78 test_when_finished "rm -rf server2 localclone2" &&
79 cp -R server server2 &&
80 git clone "testgit::${PWD}/server2" localclone2 &&
82 echo content >>file &&
83 git commit -a -m three &&
84 GIT_REMOTE_TESTGIT_SLEEPY=2 git push) &&
85 compare_refs localclone2 HEAD server2 HEAD
88 test_expect_success
'synch with changes from localclone' '
93 test_expect_success
'pushing remote local repo' '
95 echo content >>file &&
96 git commit -a -m four &&
98 compare_refs clone HEAD server HEAD
101 test_expect_success
'fetch new branch' '
103 git checkout -b new &&
104 echo content >>file &&
105 git commit -a -m five &&
111 compare_refs public HEAD localclone FETCH_HEAD
114 test_expect_success
'fetch multiple branches' '
118 compare_refs server master localclone refs/remotes/origin/master &&
119 compare_refs server new localclone refs/remotes/origin/new
122 test_expect_success
'push when remote has extra refs' '
124 echo content >>file &&
125 git commit -a -m six &&
128 compare_refs clone master server master
131 test_expect_success
'push new branch by name' '
133 git checkout -b new-name &&
134 echo content >>file &&
135 git commit -a -m seven &&
136 git push origin new-name
138 compare_refs clone HEAD server refs/heads/new-name
141 test_expect_failure
'push new branch with old:new refspec' '
143 git push origin new-name:new-refspec
145 compare_refs clone HEAD server refs/heads/new-refspec