3 3ce1b845 2019-07-15 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 3ce1b845 2019-07-15 stsp # Permission to use, copy, modify, and distribute this software for any
6 3ce1b845 2019-07-15 stsp # purpose with or without fee is hereby granted, provided that the above
7 3ce1b845 2019-07-15 stsp # copyright notice and this permission notice appear in all copies.
9 3ce1b845 2019-07-15 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 3ce1b845 2019-07-15 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 3ce1b845 2019-07-15 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 3ce1b845 2019-07-15 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 3ce1b845 2019-07-15 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 3ce1b845 2019-07-15 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 3ce1b845 2019-07-15 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 3ce1b845 2019-07-15 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_import_basic() {
20 71db5e8c 2019-08-08 stsp local testname=import_basic
21 743f0d3e 2020-10-01 stsp local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
23 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo
25 3ce1b845 2019-07-15 stsp mkdir $testroot/tree
26 3ce1b845 2019-07-15 stsp make_test_tree $testroot/tree
28 3ce1b845 2019-07-15 stsp got import -m 'init' -r $testroot/repo $testroot/tree \
29 3ce1b845 2019-07-15 stsp > $testroot/stdout
31 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
32 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
36 3ce1b845 2019-07-15 stsp local head_commit=`git_show_head $testroot/repo`
37 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/gamma/delta" > $testroot/stdout.expected
38 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/epsilon/zeta" >> $testroot/stdout.expected
39 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/alpha" >> $testroot/stdout.expected
40 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/beta" >> $testroot/stdout.expected
41 5d67f40d 2019-11-08 stsp echo "Created branch refs/heads/main with commit $head_commit" \
42 3ce1b845 2019-07-15 stsp >> $testroot/stdout.expected
44 3ce1b845 2019-07-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
46 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
47 3ce1b845 2019-07-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
48 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
52 3ce1b845 2019-07-15 stsp (cd $testroot/repo && got log -p | grep -v ^date: > $testroot/stdout)
54 3ce1b845 2019-07-15 stsp id_alpha=`get_blob_id $testroot/repo "" alpha`
55 3ce1b845 2019-07-15 stsp id_beta=`get_blob_id $testroot/repo "" beta`
56 3ce1b845 2019-07-15 stsp id_zeta=`get_blob_id $testroot/repo epsilon zeta`
57 3ce1b845 2019-07-15 stsp id_delta=`get_blob_id $testroot/repo gamma delta`
58 44392932 2019-08-25 stsp tree_id=`(cd $testroot/repo && got cat $head_commit | \
59 44392932 2019-08-25 stsp grep ^tree | cut -d ' ' -f 2)`
61 3ce1b845 2019-07-15 stsp echo "-----------------------------------------------" \
62 3ce1b845 2019-07-15 stsp > $testroot/stdout.expected
63 5d67f40d 2019-11-08 stsp echo "commit $head_commit (main)" >> $testroot/stdout.expected
64 3ce1b845 2019-07-15 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
65 3ce1b845 2019-07-15 stsp echo " " >> $testroot/stdout.expected
66 3ce1b845 2019-07-15 stsp echo " init" >> $testroot/stdout.expected
67 3ce1b845 2019-07-15 stsp echo " " >> $testroot/stdout.expected
68 8469d821 2022-06-25 stsp echo "diff /dev/null $head_commit" >> $testroot/stdout.expected
69 8469d821 2022-06-25 stsp echo "commit - /dev/null" >> $testroot/stdout.expected
70 8469d821 2022-06-25 stsp echo "commit + $head_commit" >> $testroot/stdout.expected
71 3ce1b845 2019-07-15 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
72 46f68b20 2019-10-19 stsp echo "blob + $id_alpha (mode 644)" >> $testroot/stdout.expected
73 3ce1b845 2019-07-15 stsp echo "--- /dev/null" >> $testroot/stdout.expected
74 3ce1b845 2019-07-15 stsp echo "+++ alpha" >> $testroot/stdout.expected
75 3ce1b845 2019-07-15 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
76 3ce1b845 2019-07-15 stsp echo "+alpha" >> $testroot/stdout.expected
77 3ce1b845 2019-07-15 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
78 46f68b20 2019-10-19 stsp echo "blob + $id_beta (mode 644)" >> $testroot/stdout.expected
79 3ce1b845 2019-07-15 stsp echo "--- /dev/null" >> $testroot/stdout.expected
80 3ce1b845 2019-07-15 stsp echo "+++ beta" >> $testroot/stdout.expected
81 3ce1b845 2019-07-15 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
82 3ce1b845 2019-07-15 stsp echo "+beta" >> $testroot/stdout.expected
83 3ce1b845 2019-07-15 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
84 46f68b20 2019-10-19 stsp echo "blob + $id_zeta (mode 644)" >> $testroot/stdout.expected
85 3ce1b845 2019-07-15 stsp echo "--- /dev/null" >> $testroot/stdout.expected
86 3ce1b845 2019-07-15 stsp echo "+++ epsilon/zeta" >> $testroot/stdout.expected
87 3ce1b845 2019-07-15 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
88 3ce1b845 2019-07-15 stsp echo "+zeta" >> $testroot/stdout.expected
89 3ce1b845 2019-07-15 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
90 46f68b20 2019-10-19 stsp echo "blob + $id_delta (mode 644)" >> $testroot/stdout.expected
91 3ce1b845 2019-07-15 stsp echo "--- /dev/null" >> $testroot/stdout.expected
92 3ce1b845 2019-07-15 stsp echo "+++ gamma/delta" >> $testroot/stdout.expected
93 3ce1b845 2019-07-15 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
94 3ce1b845 2019-07-15 stsp echo "+delta" >> $testroot/stdout.expected
95 3ce1b845 2019-07-15 stsp echo "" >> $testroot/stdout.expected
97 3ce1b845 2019-07-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
99 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
100 3ce1b845 2019-07-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
101 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
105 3ce1b845 2019-07-15 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
106 3ce1b845 2019-07-15 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
107 3ce1b845 2019-07-15 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
108 3ce1b845 2019-07-15 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
109 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/main: $head_commit" \
110 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
111 3ce1b845 2019-07-15 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
113 3ce1b845 2019-07-15 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
115 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
116 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
120 3ce1b845 2019-07-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
122 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
123 3ce1b845 2019-07-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
124 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
128 3ce1b845 2019-07-15 stsp echo "alpha" > $testroot/content.expected
129 3ce1b845 2019-07-15 stsp echo "beta" >> $testroot/content.expected
130 3ce1b845 2019-07-15 stsp echo "zeta" >> $testroot/content.expected
131 3ce1b845 2019-07-15 stsp echo "delta" >> $testroot/content.expected
132 3ce1b845 2019-07-15 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
133 3ce1b845 2019-07-15 stsp $testroot/wt/gamma/delta > $testroot/content
135 3ce1b845 2019-07-15 stsp cmp -s $testroot/content.expected $testroot/content
137 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
138 3ce1b845 2019-07-15 stsp diff -u $testroot/content.expected $testroot/content
140 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
143 6f04a73d 2022-09-20 mark test_import_specified_head() {
144 6f04a73d 2022-09-20 mark local testname=import_specified_head
145 6f04a73d 2022-09-20 mark local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
146 6f04a73d 2022-09-20 mark local headref=trunk
148 6f04a73d 2022-09-20 mark gotadmin init -b $headref $testroot/repo
150 6f04a73d 2022-09-20 mark mkdir $testroot/tree
151 6f04a73d 2022-09-20 mark make_test_tree $testroot/tree
153 6f04a73d 2022-09-20 mark got import -m init -r $testroot/repo $testroot/tree > $testroot/stdout
155 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
156 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
160 6f04a73d 2022-09-20 mark local head_commit=`git_show_head $testroot/repo`
161 6f04a73d 2022-09-20 mark echo "A $testroot/tree/gamma/delta" > $testroot/stdout.expected
162 6f04a73d 2022-09-20 mark echo "A $testroot/tree/epsilon/zeta" >> $testroot/stdout.expected
163 6f04a73d 2022-09-20 mark echo "A $testroot/tree/alpha" >> $testroot/stdout.expected
164 6f04a73d 2022-09-20 mark echo "A $testroot/tree/beta" >> $testroot/stdout.expected
165 6f04a73d 2022-09-20 mark echo "Created branch refs/heads/$headref with commit $head_commit" \
166 6f04a73d 2022-09-20 mark >> $testroot/stdout.expected
168 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
170 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
171 6f04a73d 2022-09-20 mark echo "fail"
172 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
173 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
177 6f04a73d 2022-09-20 mark (cd $testroot/repo && got log -p | grep -v ^date: > $testroot/stdout)
179 6f04a73d 2022-09-20 mark id_alpha=`get_blob_id $testroot/repo "" alpha`
180 6f04a73d 2022-09-20 mark id_beta=`get_blob_id $testroot/repo "" beta`
181 6f04a73d 2022-09-20 mark id_zeta=`get_blob_id $testroot/repo epsilon zeta`
182 6f04a73d 2022-09-20 mark id_delta=`get_blob_id $testroot/repo gamma delta`
183 6f04a73d 2022-09-20 mark tree_id=`(cd $testroot/repo && got cat $head_commit | \
184 6f04a73d 2022-09-20 mark grep ^tree | cut -d ' ' -f 2)`
186 6f04a73d 2022-09-20 mark echo "-----------------------------------------------" \
187 6f04a73d 2022-09-20 mark > $testroot/stdout.expected
188 6f04a73d 2022-09-20 mark echo "commit $head_commit ($headref)" >> $testroot/stdout.expected
189 6f04a73d 2022-09-20 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
190 6f04a73d 2022-09-20 mark echo " " >> $testroot/stdout.expected
191 6f04a73d 2022-09-20 mark echo " init" >> $testroot/stdout.expected
192 6f04a73d 2022-09-20 mark echo " " >> $testroot/stdout.expected
193 6f04a73d 2022-09-20 mark echo "diff /dev/null $head_commit" >> $testroot/stdout.expected
194 6f04a73d 2022-09-20 mark echo "commit - /dev/null" >> $testroot/stdout.expected
195 6f04a73d 2022-09-20 mark echo "commit + $head_commit" >> $testroot/stdout.expected
196 6f04a73d 2022-09-20 mark echo "blob - /dev/null" >> $testroot/stdout.expected
197 6f04a73d 2022-09-20 mark echo "blob + $id_alpha (mode 644)" >> $testroot/stdout.expected
198 6f04a73d 2022-09-20 mark echo "--- /dev/null" >> $testroot/stdout.expected
199 6f04a73d 2022-09-20 mark echo "+++ alpha" >> $testroot/stdout.expected
200 6f04a73d 2022-09-20 mark echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
201 6f04a73d 2022-09-20 mark echo "+alpha" >> $testroot/stdout.expected
202 6f04a73d 2022-09-20 mark echo "blob - /dev/null" >> $testroot/stdout.expected
203 6f04a73d 2022-09-20 mark echo "blob + $id_beta (mode 644)" >> $testroot/stdout.expected
204 6f04a73d 2022-09-20 mark echo "--- /dev/null" >> $testroot/stdout.expected
205 6f04a73d 2022-09-20 mark echo "+++ beta" >> $testroot/stdout.expected
206 6f04a73d 2022-09-20 mark echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
207 6f04a73d 2022-09-20 mark echo "+beta" >> $testroot/stdout.expected
208 6f04a73d 2022-09-20 mark echo "blob - /dev/null" >> $testroot/stdout.expected
209 6f04a73d 2022-09-20 mark echo "blob + $id_zeta (mode 644)" >> $testroot/stdout.expected
210 6f04a73d 2022-09-20 mark echo "--- /dev/null" >> $testroot/stdout.expected
211 6f04a73d 2022-09-20 mark echo "+++ epsilon/zeta" >> $testroot/stdout.expected
212 6f04a73d 2022-09-20 mark echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
213 6f04a73d 2022-09-20 mark echo "+zeta" >> $testroot/stdout.expected
214 6f04a73d 2022-09-20 mark echo "blob - /dev/null" >> $testroot/stdout.expected
215 6f04a73d 2022-09-20 mark echo "blob + $id_delta (mode 644)" >> $testroot/stdout.expected
216 6f04a73d 2022-09-20 mark echo "--- /dev/null" >> $testroot/stdout.expected
217 6f04a73d 2022-09-20 mark echo "+++ gamma/delta" >> $testroot/stdout.expected
218 6f04a73d 2022-09-20 mark echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
219 6f04a73d 2022-09-20 mark echo "+delta" >> $testroot/stdout.expected
220 6f04a73d 2022-09-20 mark echo "" >> $testroot/stdout.expected
222 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
224 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
225 6f04a73d 2022-09-20 mark echo "fail"
226 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
227 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
231 6f04a73d 2022-09-20 mark echo "A $testroot/wt/alpha" > $testroot/stdout.expected
232 6f04a73d 2022-09-20 mark echo "A $testroot/wt/beta" >> $testroot/stdout.expected
233 6f04a73d 2022-09-20 mark echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
234 6f04a73d 2022-09-20 mark echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
235 6f04a73d 2022-09-20 mark echo "Checked out refs/heads/$headref: $head_commit" \
236 6f04a73d 2022-09-20 mark >> $testroot/stdout.expected
237 6f04a73d 2022-09-20 mark echo "Now shut up and hack" >> $testroot/stdout.expected
239 6f04a73d 2022-09-20 mark got checkout $testroot/repo $testroot/wt > $testroot/stdout
240 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
242 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
243 6f04a73d 2022-09-20 mark echo "fail"
244 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
245 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
249 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
251 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
252 6f04a73d 2022-09-20 mark echo "fail"
253 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
254 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
258 6f04a73d 2022-09-20 mark echo "alpha" > $testroot/content.expected
259 6f04a73d 2022-09-20 mark echo "beta" >> $testroot/content.expected
260 6f04a73d 2022-09-20 mark echo "zeta" >> $testroot/content.expected
261 6f04a73d 2022-09-20 mark echo "delta" >> $testroot/content.expected
262 6f04a73d 2022-09-20 mark cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
263 6f04a73d 2022-09-20 mark $testroot/wt/gamma/delta > $testroot/content
265 6f04a73d 2022-09-20 mark cmp -s $testroot/content.expected $testroot/content
267 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
268 6f04a73d 2022-09-20 mark echo "fail"
269 6f04a73d 2022-09-20 mark diff -u $testroot/content.expected $testroot/content
271 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
274 6f04a73d 2022-09-20 mark test_import_detached_head() {
275 6f04a73d 2022-09-20 mark local testroot=`test_init import_detached_head`
277 6f04a73d 2022-09-20 mark # mute verbose 'detached HEAD' warning
278 6f04a73d 2022-09-20 mark (cd $testroot/repo && git config --local advice.detachedHead false)
280 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
281 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
285 6f04a73d 2022-09-20 mark # enter detached HEAD state
286 6f04a73d 2022-09-20 mark local head_commit=`git_show_head $testroot/repo | cut -c1-7`
287 6f04a73d 2022-09-20 mark (cd $testroot/repo && \
288 6f04a73d 2022-09-20 mark git checkout $head_commit > $testroot/stdout 2> $testroot/stderr)
290 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
291 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
295 6f04a73d 2022-09-20 mark echo "HEAD is now at $head_commit adding the test tree" >> \
296 6f04a73d 2022-09-20 mark $testroot/stderr.expected
298 6f04a73d 2022-09-20 mark cmp -s $testroot/stderr.expected $testroot/stderr
300 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
301 6f04a73d 2022-09-20 mark echo "fail"
302 6f04a73d 2022-09-20 mark diff -u $testroot/stderr.expected $testroot/stderr
303 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
307 6f04a73d 2022-09-20 mark mkdir $testroot/import
308 6f04a73d 2022-09-20 mark make_test_tree $testroot/import
310 6f04a73d 2022-09-20 mark # detached HEAD (i.e., not symbolic) so import should fallback to "main"
311 6f04a73d 2022-09-20 mark got import -r $testroot/repo -m init $testroot/import > $testroot/stdout
313 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
314 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
318 6f04a73d 2022-09-20 mark local main_commit=`(cd $testroot/repo && \
319 6f04a73d 2022-09-20 mark git show-ref main | cut -d ' ' -f 1)`
320 6f04a73d 2022-09-20 mark echo "A $testroot/import/gamma/delta" > $testroot/stdout.expected
321 6f04a73d 2022-09-20 mark echo "A $testroot/import/epsilon/zeta" >> $testroot/stdout.expected
322 6f04a73d 2022-09-20 mark echo "A $testroot/import/alpha" >> $testroot/stdout.expected
323 6f04a73d 2022-09-20 mark echo "A $testroot/import/beta" >> $testroot/stdout.expected
324 6f04a73d 2022-09-20 mark echo "Created branch refs/heads/main with commit $main_commit" \
325 6f04a73d 2022-09-20 mark >> $testroot/stdout.expected
327 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
329 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
330 6f04a73d 2022-09-20 mark echo "fail"
331 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
333 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
336 f6cae3ed 2020-09-13 naddy test_import_requires_new_branch() {
337 3ce1b845 2019-07-15 stsp local testroot=`test_init import_requires_new_branch`
339 3ce1b845 2019-07-15 stsp mkdir $testroot/tree
340 3ce1b845 2019-07-15 stsp make_test_tree $testroot/tree
342 5d67f40d 2019-11-08 stsp got import -b master -m 'init' -r $testroot/repo $testroot/tree \
343 3ce1b845 2019-07-15 stsp > $testroot/stdout 2> $testroot/stderr
345 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
346 3ce1b845 2019-07-15 stsp echo "import command should have failed but did not"
347 3ce1b845 2019-07-15 stsp test_done "$testroot" "1"
351 3ce1b845 2019-07-15 stsp echo "got: import target branch already exists" \
352 3ce1b845 2019-07-15 stsp > $testroot/stderr.expected
353 3ce1b845 2019-07-15 stsp cmp -s $testroot/stderr.expected $testroot/stderr
355 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
356 3ce1b845 2019-07-15 stsp diff -u $testroot/stderr.expected $testroot/stderr
357 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
361 3ce1b845 2019-07-15 stsp got import -b newbranch -m 'init' -r $testroot/repo $testroot/tree \
362 3ce1b845 2019-07-15 stsp > $testroot/stdout
364 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
368 f6cae3ed 2020-09-13 naddy test_import_ignores() {
369 71db5e8c 2019-08-08 stsp local testname=import_ignores
370 743f0d3e 2020-10-01 stsp local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
372 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo
374 3ce1b845 2019-07-15 stsp mkdir $testroot/tree
375 3ce1b845 2019-07-15 stsp make_test_tree $testroot/tree
377 d0f874e0 2023-02-19 stsp touch $testroot/tree/upsilon
378 d0f874e0 2023-02-19 stsp mkdir $testroot/tree/ysilon
379 49351f3b 2023-02-06 stsp got import -I alpha -I 'beta/' -I '*lta*' -I '*silon/' \
380 3ce1b845 2019-07-15 stsp -m 'init' -r $testroot/repo $testroot/tree > $testroot/stdout
382 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
383 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
387 3ce1b845 2019-07-15 stsp local head_commit=`git_show_head $testroot/repo`
388 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/beta" >> $testroot/stdout.expected
389 d0f874e0 2023-02-19 stsp echo "A $testroot/tree/upsilon" >> $testroot/stdout.expected
390 5d67f40d 2019-11-08 stsp echo "Created branch refs/heads/main with commit $head_commit" \
391 3ce1b845 2019-07-15 stsp >> $testroot/stdout.expected
393 3ce1b845 2019-07-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
395 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
396 3ce1b845 2019-07-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
398 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
401 f6cae3ed 2020-09-13 naddy test_import_empty_dir() {
402 db1d3576 2019-10-04 stsp local testname=import_empty_dir
403 743f0d3e 2020-10-01 stsp local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
405 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo
407 db1d3576 2019-10-04 stsp mkdir $testroot/tree
408 db1d3576 2019-10-04 stsp mkdir -p $testroot/tree/empty $testroot/tree/notempty
409 db1d3576 2019-10-04 stsp echo "alpha" > $testroot/tree/notempty/alpha
411 db1d3576 2019-10-04 stsp got import -m 'init' -r $testroot/repo $testroot/tree > $testroot/stdout
413 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
414 db1d3576 2019-10-04 stsp test_done "$testroot" "$ret"
418 db1d3576 2019-10-04 stsp local head_commit=`git_show_head $testroot/repo`
419 db1d3576 2019-10-04 stsp echo "A $testroot/tree/notempty/alpha" >> $testroot/stdout.expected
420 5d67f40d 2019-11-08 stsp echo "Created branch refs/heads/main with commit $head_commit" \
421 db1d3576 2019-10-04 stsp >> $testroot/stdout.expected
423 db1d3576 2019-10-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
425 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
426 db1d3576 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
427 db1d3576 2019-10-04 stsp test_done "$testroot" "$ret"
431 db1d3576 2019-10-04 stsp # Verify that Got did not import the empty directory
432 db1d3576 2019-10-04 stsp echo "notempty/" > $testroot/stdout.expected
433 db1d3576 2019-10-04 stsp echo "notempty/alpha" >> $testroot/stdout.expected
435 db1d3576 2019-10-04 stsp got tree -r $testroot/repo -R > $testroot/stdout
436 db1d3576 2019-10-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
438 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
439 db1d3576 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
441 db1d3576 2019-10-04 stsp test_done "$testroot" "$ret"
444 f6cae3ed 2020-09-13 naddy test_import_symlink() {
445 e8863bdc 2020-07-23 stsp local testname=import_symlink
446 743f0d3e 2020-10-01 stsp local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
448 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo
450 e8863bdc 2020-07-23 stsp mkdir $testroot/tree
451 e8863bdc 2020-07-23 stsp echo 'this is file alpha' > $testroot/tree/alpha
452 e8863bdc 2020-07-23 stsp ln -s alpha $testroot/tree/alpha.link
454 e8863bdc 2020-07-23 stsp got import -m 'init' -r $testroot/repo $testroot/tree \
455 e8863bdc 2020-07-23 stsp > $testroot/stdout
457 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
458 e8863bdc 2020-07-23 stsp test_done "$testroot" "$ret"
462 e8863bdc 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
463 e8863bdc 2020-07-23 stsp echo "A $testroot/tree/alpha" > $testroot/stdout.expected
464 e8863bdc 2020-07-23 stsp echo "A $testroot/tree/alpha.link" >> $testroot/stdout.expected
465 e8863bdc 2020-07-23 stsp echo "Created branch refs/heads/main with commit $head_commit" \
466 e8863bdc 2020-07-23 stsp >> $testroot/stdout.expected
468 e8863bdc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
470 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
471 e8863bdc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
472 e8863bdc 2020-07-23 stsp test_done "$testroot" "$ret"
476 e8863bdc 2020-07-23 stsp id_alpha=`get_blob_id $testroot/repo "" alpha`
477 e8863bdc 2020-07-23 stsp id_alpha_link=$(got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | cut -d' ' -f 1)
478 e8863bdc 2020-07-23 stsp tree_id=`(cd $testroot/repo && got cat $head_commit | \
479 e8863bdc 2020-07-23 stsp grep ^tree | cut -d ' ' -f 2)`
481 e8863bdc 2020-07-23 stsp got tree -i -r $testroot/repo -c $head_commit > $testroot/stdout
483 e8863bdc 2020-07-23 stsp echo "$id_alpha alpha" > $testroot/stdout.expected
484 e8863bdc 2020-07-23 stsp echo "$id_alpha_link alpha.link@ -> alpha" >> $testroot/stdout.expected
486 e8863bdc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
488 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
489 e8863bdc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
491 e8863bdc 2020-07-23 stsp test_done "$testroot" "$ret"
494 7fb414ae 2020-08-08 stsp test_parseargs "$@"
495 3ce1b845 2019-07-15 stsp run_test test_import_basic
496 6f04a73d 2022-09-20 mark run_test test_import_specified_head
497 6f04a73d 2022-09-20 mark run_test test_import_detached_head
498 3ce1b845 2019-07-15 stsp run_test test_import_requires_new_branch
499 3ce1b845 2019-07-15 stsp run_test test_import_ignores
500 db1d3576 2019-10-04 stsp run_test test_import_empty_dir
501 e8863bdc 2020-07-23 stsp run_test test_import_symlink