]>
Commit | Line | Data |
---|---|---|
fc407f98 FC |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2010 Sverre Rabbelier | |
4 | # | |
5 | ||
6 | test_description='Test remote-helper import and export commands' | |
7 | ||
8 | . ./test-lib.sh | |
b8bd826f | 9 | . "$TEST_DIRECTORY"/lib-gpg.sh |
fc407f98 FC |
10 | |
11 | if ! type "${BASH-bash}" >/dev/null 2>&1; then | |
12 | skip_all='skipping remote-testgit tests, bash not available' | |
13 | test_done | |
14 | fi | |
15 | ||
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 | |
20 | } | |
21 | ||
22 | test_expect_success 'setup repository' ' | |
3808b851 FC |
23 | git init server && |
24 | (cd server && | |
fc407f98 FC |
25 | echo content >file && |
26 | git add file && | |
3808b851 | 27 | git commit -m one) |
fc407f98 FC |
28 | ' |
29 | ||
30 | test_expect_success 'cloning from local repo' ' | |
3808b851 FC |
31 | git clone "testgit::${PWD}/server" local && |
32 | test_cmp server/file local/file | |
fc407f98 FC |
33 | ' |
34 | ||
fc407f98 | 35 | test_expect_success 'create new commit on remote' ' |
3808b851 | 36 | (cd server && |
fc407f98 | 37 | echo content >>file && |
3808b851 | 38 | git commit -a -m two) |
fc407f98 FC |
39 | ' |
40 | ||
41 | test_expect_success 'pulling from local repo' ' | |
3808b851 FC |
42 | (cd local && git pull) && |
43 | test_cmp server/file local/file | |
fc407f98 FC |
44 | ' |
45 | ||
fc407f98 | 46 | test_expect_success 'pushing to local repo' ' |
3808b851 | 47 | (cd local && |
fc407f98 FC |
48 | echo content >>file && |
49 | git commit -a -m three && | |
50 | git push) && | |
3808b851 | 51 | compare_refs local HEAD server HEAD |
fc407f98 FC |
52 | ' |
53 | ||
fc407f98 | 54 | test_expect_success 'fetch new branch' ' |
3808b851 FC |
55 | (cd server && |
56 | git reset --hard && | |
fc407f98 FC |
57 | git checkout -b new && |
58 | echo content >>file && | |
3808b851 | 59 | git commit -a -m five |
fc407f98 | 60 | ) && |
3808b851 | 61 | (cd local && |
fc407f98 FC |
62 | git fetch origin new |
63 | ) && | |
3808b851 | 64 | compare_refs server HEAD local FETCH_HEAD |
fc407f98 FC |
65 | ' |
66 | ||
67 | test_expect_success 'fetch multiple branches' ' | |
3808b851 | 68 | (cd local && |
fc407f98 FC |
69 | git fetch |
70 | ) && | |
3808b851 FC |
71 | compare_refs server master local refs/remotes/origin/master && |
72 | compare_refs server new local refs/remotes/origin/new | |
fc407f98 FC |
73 | ' |
74 | ||
75 | test_expect_success 'push when remote has extra refs' ' | |
3808b851 | 76 | (cd local && |
984f3768 | 77 | git reset --hard origin/master && |
fc407f98 FC |
78 | echo content >>file && |
79 | git commit -a -m six && | |
80 | git push | |
81 | ) && | |
3808b851 | 82 | compare_refs local master server master |
fc407f98 FC |
83 | ' |
84 | ||
85 | test_expect_success 'push new branch by name' ' | |
3808b851 | 86 | (cd local && |
fc407f98 FC |
87 | git checkout -b new-name && |
88 | echo content >>file && | |
89 | git commit -a -m seven && | |
90 | git push origin new-name | |
91 | ) && | |
3808b851 | 92 | compare_refs local HEAD server refs/heads/new-name |
fc407f98 FC |
93 | ' |
94 | ||
95 | test_expect_failure 'push new branch with old:new refspec' ' | |
3808b851 | 96 | (cd local && |
fc407f98 FC |
97 | git push origin new-name:new-refspec |
98 | ) && | |
3808b851 | 99 | compare_refs local HEAD server refs/heads/new-refspec |
fc407f98 FC |
100 | ' |
101 | ||
ee10fbf9 FC |
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 | |
106 | ' | |
107 | ||
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 | |
113 | ' | |
114 | ||
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 | |
122 | ' | |
123 | ||
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 | |
128 | ' | |
129 | ||
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 | |
137 | ' | |
138 | ||
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 | |
143 | ' | |
144 | ||
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 | |
152 | ' | |
153 | ||
49266e8a FC |
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 | |
160 | ' | |
161 | ||
f28e7c90 FC |
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 | |
168 | ' | |
169 | ||
b8bd826f JK |
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 | ' | |
178 | ||
fc407f98 | 179 | test_done |