rebase: fix run_specific_rebase's use of "return" on FreeBSD
[git/debian.git] / t / t5801-remote-helpers.sh
blob69212cdde14c012261eabc4ac9b2e5956213f8d5
1 #!/bin/sh
3 # Copyright (c) 2010 Sverre Rabbelier
6 test_description='Test remote-helper import and export commands'
8 . ./test-lib.sh
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'
13 test_done
16 compare_refs() {
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' '
23 git init server &&
24 (cd server &&
25 echo content >file &&
26 git add file &&
27 git commit -m one)
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' '
36 (cd server &&
37 echo content >>file &&
38 git commit -a -m two)
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' '
47 (cd local &&
48 echo content >>file &&
49 git commit -a -m three &&
50 git push) &&
51 compare_refs local HEAD server HEAD
54 test_expect_success 'fetch new branch' '
55 (cd server &&
56 git reset --hard &&
57 git checkout -b new &&
58 echo content >>file &&
59 git commit -a -m five
60 ) &&
61 (cd local &&
62 git fetch origin new
63 ) &&
64 compare_refs server HEAD local FETCH_HEAD
67 test_expect_success 'fetch multiple branches' '
68 (cd local &&
69 git fetch
70 ) &&
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' '
76 (cd local &&
77 git reset --hard origin/master &&
78 echo content >>file &&
79 git commit -a -m six &&
80 git push
81 ) &&
82 compare_refs local master server master
85 test_expect_success 'push new branch by name' '
86 (cd local &&
87 git checkout -b new-name &&
88 echo content >>file &&
89 git commit -a -m seven &&
90 git push origin new-name
91 ) &&
92 compare_refs local HEAD server refs/heads/new-name
95 test_expect_failure 'push new branch with old:new refspec' '
96 (cd local &&
97 git push origin new-name:new-refspec
98 ) &&
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' '
109 (cd local2 &&
110 git reset --hard &&
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)" &&
117 (cd local2 &&
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' '
125 (cd local2 &&
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)" &&
132 (cd local2 &&
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' '
140 (cd local2 &&
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)" &&
147 (cd local2 &&
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' '
155 (cd local &&
156 git branch dup2 master &&
157 git push origin --all
158 ) &&
159 compare_refs local dup2 server dup2
162 test_expect_success 'push ref with existing object' '
163 (cd local &&
164 git branch dup master &&
165 git push origin dup
166 ) &&
167 compare_refs local dup server dup
170 test_expect_success GPG 'push signed tag' '
171 (cd local &&
172 git checkout master &&
173 git tag -s -m signed-tag signed-tag &&
174 git push origin signed-tag
175 ) &&
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' '
181 (cd local &&
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
185 ) &&
186 compare_refs local signed-tag-2 server signed-tag-2
189 test_done