]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t5801-remote-helpers.sh
3 # Copyright (c) 2010 Sverre Rabbelier
6 test_description
='Test remote-helper import and export commands'
9 .
"$TEST_DIRECTORY"/lib-gpg.sh
11 PATH
="$TEST_DIRECTORY/t5801:$PATH"
20 git
--git-dir="$1/.git" rev-parse
--verify $2 >expect
&&
21 git
--git-dir="$3/.git" rev-parse
--verify $4 >actual
&&
22 eval $fail test_cmp expect actual
25 test_expect_success
'setup repository' '
33 test_expect_success
'cloning from local repo' '
34 git clone "testgit::${PWD}/server" local &&
35 test_cmp server/file local/file
38 test_expect_success
'create new commit on remote' '
40 echo content >>file &&
44 test_expect_success
'pulling from local repo' '
45 (cd local && git pull) &&
46 test_cmp server/file local/file
49 test_expect_success
'pushing to local repo' '
51 echo content >>file &&
52 git commit -a -m three &&
54 compare_refs local HEAD server HEAD
57 test_expect_success
'fetch new branch' '
60 git checkout -b new &&
61 echo content >>file &&
67 compare_refs server HEAD local FETCH_HEAD
70 test_expect_success
'fetch multiple branches' '
74 compare_refs server master local refs/remotes/origin/master &&
75 compare_refs server new local refs/remotes/origin/new
78 test_expect_success
'push when remote has extra refs' '
80 git reset --hard origin/master &&
81 echo content >>file &&
82 git commit -a -m six &&
85 compare_refs local master server master
88 test_expect_success
'push new branch by name' '
90 git checkout -b new-name &&
91 echo content >>file &&
92 git commit -a -m seven &&
93 git push origin new-name
95 compare_refs local HEAD server refs/heads/new-name
98 test_expect_success
'push new branch with old:new refspec' '
100 git push origin new-name:new-refspec
102 compare_refs local HEAD server refs/heads/new-refspec
105 test_expect_success
'push new branch with HEAD:new refspec' '
107 git checkout new-name &&
108 git push origin HEAD:new-refspec-2
110 compare_refs local HEAD server refs/heads/new-refspec-2
113 test_expect_success
'push delete branch' '
115 git push origin :new-name
117 test_must_fail git --git-dir="server/.git" \
118 rev-parse --verify refs/heads/new-name
121 test_expect_success
'forced push' '
123 git checkout -b force-test &&
124 echo content >> file &&
125 git commit -a -m eight &&
126 git push origin force-test &&
127 echo content >> file &&
128 git commit -a --amend -m eight-modified &&
129 git push --force origin force-test
131 compare_refs local refs/heads/force-test server refs/heads/force-test
134 test_expect_success
'cloning without refspec' '
135 GIT_REMOTE_TESTGIT_NOREFSPEC=1 \
136 git clone "testgit::${PWD}/server" local2 2>error &&
137 test_i18ngrep "this remote helper should implement refspec capability" error &&
138 compare_refs local2 HEAD server HEAD
141 test_expect_success
'pulling without refspecs' '
144 GIT_REMOTE_TESTGIT_NOREFSPEC=1 git pull 2>../error) &&
145 test_i18ngrep "this remote helper should implement refspec capability" error &&
146 compare_refs local2 HEAD server HEAD
149 test_expect_success
'pushing without refspecs' '
150 test_when_finished "(cd local2 && git reset --hard origin)" &&
152 echo content >>file &&
153 git commit -a -m ten &&
154 GIT_REMOTE_TESTGIT_NOREFSPEC=1 &&
155 export GIT_REMOTE_TESTGIT_NOREFSPEC &&
156 test_must_fail git push 2>../error) &&
157 test_i18ngrep "remote-helper doesn.t support push; refspec needed" error
160 test_expect_success
'pulling without marks' '
162 GIT_REMOTE_TESTGIT_NO_MARKS=1 git pull) &&
163 compare_refs local2 HEAD server HEAD
166 test_expect_failure
'pushing without marks' '
167 test_when_finished "(cd local2 && git reset --hard origin)" &&
169 echo content >>file &&
170 git commit -a -m twelve &&
171 GIT_REMOTE_TESTGIT_NO_MARKS=1 git push) &&
172 compare_refs local2 HEAD server HEAD
175 test_expect_success
'push all with existing object' '
177 git branch dup2 master &&
178 git push origin --all
180 compare_refs local dup2 server dup2
183 test_expect_success
'push ref with existing object' '
185 git branch dup master &&
188 compare_refs local dup server dup
191 test_expect_success GPG
'push signed tag' '
193 git checkout master &&
194 git tag -s -m signed-tag signed-tag &&
195 git push origin signed-tag
197 compare_refs local signed-tag^{} server signed-tag^{} &&
198 compare_refs ! local signed-tag server signed-tag
201 test_expect_success GPG
'push signed tag with signed-tags capability' '
203 git checkout master &&
204 git tag -s -m signed-tag signed-tag-2 &&
205 GIT_REMOTE_TESTGIT_SIGNED_TAGS=1 git push origin signed-tag-2
207 compare_refs local signed-tag-2 server signed-tag-2
210 test_expect_success
'push update refs' '
212 git checkout -b update master &&
213 echo update >>file &&
214 git commit -a -m update &&
215 git push origin update &&
216 git rev-parse --verify remotes/origin/update >expect &&
217 git rev-parse --verify testgit/origin/heads/update >actual &&
218 test_cmp expect actual
222 test_expect_success
'push update refs disabled by no-private-update' '
224 echo more-update >>file &&
225 git commit -a -m more-update &&
226 git rev-parse --verify testgit/origin/heads/update >expect &&
227 GIT_REMOTE_TESTGIT_NO_PRIVATE_UPDATE=t git push origin update &&
228 git rev-parse --verify testgit/origin/heads/update >actual &&
229 test_cmp expect actual
233 test_expect_success
'push update refs failure' '
235 git checkout update &&
236 echo "update fail" >>file &&
237 git commit -a -m "update fail" &&
238 git rev-parse --verify testgit/origin/heads/update >expect &&
239 test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
240 git push origin update &&
241 git rev-parse --verify testgit/origin/heads/update >actual &&
242 test_cmp expect actual
247 cut
-f 2 -d ' ' "$1" |
248 git cat-file
--batch-check |
250 sort >$
(basename "$1")
253 test_expect_success
'proper failure checks for fetching' '
255 test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git fetch 2>error &&
256 test_i18ngrep -q "error while running fast-import" error
260 test_expect_success
'proper failure checks for pushing' '
261 test_when_finished "rm -rf local/git.marks local/testgit.marks" &&
263 git checkout -b crash master &&
265 git commit -a -m crash &&
266 test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all &&
267 clean_mark ".git/testgit/origin/git.marks" &&
268 clean_mark ".git/testgit/origin/testgit.marks" &&
269 test_cmp git.marks testgit.marks
273 test_expect_success
'push messages' '
275 git checkout -b new_branch master &&
277 git commit -a -m new &&
278 git push origin new_branch &&
281 git commit -a -m new &&
282 git push origin new_branch 2> msg &&
283 ! grep "\[new branch\]" msg
287 test_expect_success
'fetch HEAD' '
289 git checkout master &&
291 git commit -a -m more
294 git fetch origin HEAD
296 compare_refs server HEAD local FETCH_HEAD
299 test_expect_success
'fetch url' '
301 git checkout master &&
303 git commit -a -m more
306 git fetch "testgit::${PWD}/../server"
308 compare_refs server HEAD local FETCH_HEAD
311 test_expect_success
'fetch tag' '
318 compare_refs local v1.0 server v1.0