3 # Copyright (c) 2010 Sverre Rabbelier
6 test_description
='Test remote-helper import and export commands'
9 .
"$TEST_DIRECTORY"/lib-gpg.sh
11 if ! type "${BASH-bash}" >/dev
/null
2>&1; then
12 skip_all
='skipping remote-testgit tests, bash not available'
17 git
--git-dir="$1/.git" rev-parse
--verify $2 >expect
&&
18 git
--git-dir="$3/.git" rev-parse
--verify $4 >actual
&&
19 test_cmp expect actual
22 test_expect_success
'setup repository' '
30 test_expect_success
'cloning from local repo' '
31 git clone "testgit::${PWD}/server" local &&
32 test_cmp server/file local/file
35 test_expect_success
'create new commit on remote' '
37 echo content >>file &&
41 test_expect_success
'pulling from local repo' '
42 (cd local && git pull) &&
43 test_cmp server/file local/file
46 test_expect_success
'pushing to local repo' '
48 echo content >>file &&
49 git commit -a -m three &&
51 compare_refs local HEAD server HEAD
54 test_expect_success
'fetch new branch' '
57 git checkout -b new &&
58 echo content >>file &&
64 compare_refs server HEAD local FETCH_HEAD
67 test_expect_success
'fetch multiple branches' '
71 compare_refs server master local refs/remotes/origin/master &&
72 compare_refs server new local refs/remotes/origin/new
75 test_expect_success
'push when remote has extra refs' '
77 git reset --hard origin/master &&
78 echo content >>file &&
79 git commit -a -m six &&
82 compare_refs local master server master
85 test_expect_success
'push new branch by name' '
87 git checkout -b new-name &&
88 echo content >>file &&
89 git commit -a -m seven &&
90 git push origin new-name
92 compare_refs local HEAD server refs/heads/new-name
95 test_expect_failure
'push new branch with old:new refspec' '
97 git push origin new-name:new-refspec
99 compare_refs local HEAD server refs/heads/new-refspec
102 test_expect_success
'cloning without refspec' '
103 GIT_REMOTE_TESTGIT_REFSPEC="" \
104 git clone "testgit::${PWD}/server" local2 &&
105 compare_refs local2 HEAD server HEAD
108 test_expect_success
'pulling without refspecs' '
111 GIT_REMOTE_TESTGIT_REFSPEC="" git pull) &&
112 compare_refs local2 HEAD server HEAD
115 test_expect_failure
'pushing without refspecs' '
116 test_when_finished "(cd local2 && git reset --hard origin)" &&
118 echo content >>file &&
119 git commit -a -m ten &&
120 GIT_REMOTE_TESTGIT_REFSPEC="" git push) &&
121 compare_refs local2 HEAD server HEAD
124 test_expect_success
'pulling with straight refspec' '
126 GIT_REMOTE_TESTGIT_REFSPEC="*:*" git pull) &&
127 compare_refs local2 HEAD server HEAD
130 test_expect_failure
'pushing with straight refspec' '
131 test_when_finished "(cd local2 && git reset --hard origin)" &&
133 echo content >>file &&
134 git commit -a -m eleven &&
135 GIT_REMOTE_TESTGIT_REFSPEC="*:*" git push) &&
136 compare_refs local2 HEAD server HEAD
139 test_expect_success
'pulling without marks' '
141 GIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&
142 compare_refs local2 HEAD server HEAD
145 test_expect_failure
'pushing without marks' '
146 test_when_finished "(cd local2 && git reset --hard origin)" &&
148 echo content >>file &&
149 git commit -a -m twelve &&
150 GIT_REMOTE_TESTGIT_NO_MARKS=1 git push) &&
151 compare_refs local2 HEAD server HEAD
154 test_expect_success
'push all with existing object' '
156 git branch dup2 master &&
157 git push origin --all
159 compare_refs local dup2 server dup2
162 test_expect_success
'push ref with existing object' '
164 git branch dup master &&
167 compare_refs local dup server dup
170 test_expect_success GPG
'push signed tag' '
172 git checkout master &&
173 git tag -s -m signed-tag signed-tag &&
174 git push origin signed-tag
176 compare_refs local signed-tag^{} server signed-tag^{} &&
177 test_must_fail compare_refs local signed-tag server signed-tag
180 test_expect_success GPG
'push signed tag with signed-tags capability' '
182 git checkout master &&
183 git tag -s -m signed-tag signed-tag-2 &&
184 GIT_REMOTE_TESTGIT_SIGNED_TAGS=1 git push origin signed-tag-2
186 compare_refs local signed-tag-2 server signed-tag-2