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 27b10c3c 2022-07-04 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 9b4458b4 2022-06-26 thomas echo "diff /dev/null $head_commit" >> $testroot/stdout.expected
69 9b4458b4 2022-06-26 thomas echo "commit - /dev/null" >> $testroot/stdout.expected
70 9b4458b4 2022-06-26 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 e9424ba1 2022-09-20 thomas test_import_specified_head() {
144 e9424ba1 2022-09-20 thomas local testname=import_specified_head
145 e9424ba1 2022-09-20 thomas local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
146 e9424ba1 2022-09-20 thomas local headref=trunk
148 e9424ba1 2022-09-20 thomas gotadmin init -b $headref $testroot/repo
150 e9424ba1 2022-09-20 thomas mkdir $testroot/tree
151 e9424ba1 2022-09-20 thomas make_test_tree $testroot/tree
153 e9424ba1 2022-09-20 thomas got import -m init -r $testroot/repo $testroot/tree > $testroot/stdout
155 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
156 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
160 e9424ba1 2022-09-20 thomas local head_commit=`git_show_head $testroot/repo`
161 e9424ba1 2022-09-20 thomas echo "A $testroot/tree/gamma/delta" > $testroot/stdout.expected
162 e9424ba1 2022-09-20 thomas echo "A $testroot/tree/epsilon/zeta" >> $testroot/stdout.expected
163 e9424ba1 2022-09-20 thomas echo "A $testroot/tree/alpha" >> $testroot/stdout.expected
164 e9424ba1 2022-09-20 thomas echo "A $testroot/tree/beta" >> $testroot/stdout.expected
165 e9424ba1 2022-09-20 thomas echo "Created branch refs/heads/$headref with commit $head_commit" \
166 e9424ba1 2022-09-20 thomas >> $testroot/stdout.expected
168 e9424ba1 2022-09-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
170 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
171 e9424ba1 2022-09-20 thomas echo "fail"
172 e9424ba1 2022-09-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
173 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
177 e9424ba1 2022-09-20 thomas (cd $testroot/repo && got log -p | grep -v ^date: > $testroot/stdout)
179 e9424ba1 2022-09-20 thomas id_alpha=`get_blob_id $testroot/repo "" alpha`
180 e9424ba1 2022-09-20 thomas id_beta=`get_blob_id $testroot/repo "" beta`
181 e9424ba1 2022-09-20 thomas id_zeta=`get_blob_id $testroot/repo epsilon zeta`
182 e9424ba1 2022-09-20 thomas id_delta=`get_blob_id $testroot/repo gamma delta`
183 e9424ba1 2022-09-20 thomas tree_id=`(cd $testroot/repo && got cat $head_commit | \
184 e9424ba1 2022-09-20 thomas grep ^tree | cut -d ' ' -f 2)`
186 e9424ba1 2022-09-20 thomas echo "-----------------------------------------------" \
187 e9424ba1 2022-09-20 thomas > $testroot/stdout.expected
188 e9424ba1 2022-09-20 thomas echo "commit $head_commit ($headref)" >> $testroot/stdout.expected
189 e9424ba1 2022-09-20 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
190 e9424ba1 2022-09-20 thomas echo " " >> $testroot/stdout.expected
191 e9424ba1 2022-09-20 thomas echo " init" >> $testroot/stdout.expected
192 e9424ba1 2022-09-20 thomas echo " " >> $testroot/stdout.expected
193 e9424ba1 2022-09-20 thomas echo "diff /dev/null $head_commit" >> $testroot/stdout.expected
194 e9424ba1 2022-09-20 thomas echo "commit - /dev/null" >> $testroot/stdout.expected
195 e9424ba1 2022-09-20 thomas echo "commit + $head_commit" >> $testroot/stdout.expected
196 e9424ba1 2022-09-20 thomas echo "blob - /dev/null" >> $testroot/stdout.expected
197 e9424ba1 2022-09-20 thomas echo "blob + $id_alpha (mode 644)" >> $testroot/stdout.expected
198 e9424ba1 2022-09-20 thomas echo "--- /dev/null" >> $testroot/stdout.expected
199 e9424ba1 2022-09-20 thomas echo "+++ alpha" >> $testroot/stdout.expected
200 e9424ba1 2022-09-20 thomas echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
201 e9424ba1 2022-09-20 thomas echo "+alpha" >> $testroot/stdout.expected
202 e9424ba1 2022-09-20 thomas echo "blob - /dev/null" >> $testroot/stdout.expected
203 e9424ba1 2022-09-20 thomas echo "blob + $id_beta (mode 644)" >> $testroot/stdout.expected
204 e9424ba1 2022-09-20 thomas echo "--- /dev/null" >> $testroot/stdout.expected
205 e9424ba1 2022-09-20 thomas echo "+++ beta" >> $testroot/stdout.expected
206 e9424ba1 2022-09-20 thomas echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
207 e9424ba1 2022-09-20 thomas echo "+beta" >> $testroot/stdout.expected
208 e9424ba1 2022-09-20 thomas echo "blob - /dev/null" >> $testroot/stdout.expected
209 e9424ba1 2022-09-20 thomas echo "blob + $id_zeta (mode 644)" >> $testroot/stdout.expected
210 e9424ba1 2022-09-20 thomas echo "--- /dev/null" >> $testroot/stdout.expected
211 e9424ba1 2022-09-20 thomas echo "+++ epsilon/zeta" >> $testroot/stdout.expected
212 e9424ba1 2022-09-20 thomas echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
213 e9424ba1 2022-09-20 thomas echo "+zeta" >> $testroot/stdout.expected
214 e9424ba1 2022-09-20 thomas echo "blob - /dev/null" >> $testroot/stdout.expected
215 e9424ba1 2022-09-20 thomas echo "blob + $id_delta (mode 644)" >> $testroot/stdout.expected
216 e9424ba1 2022-09-20 thomas echo "--- /dev/null" >> $testroot/stdout.expected
217 e9424ba1 2022-09-20 thomas echo "+++ gamma/delta" >> $testroot/stdout.expected
218 e9424ba1 2022-09-20 thomas echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
219 e9424ba1 2022-09-20 thomas echo "+delta" >> $testroot/stdout.expected
220 e9424ba1 2022-09-20 thomas echo "" >> $testroot/stdout.expected
222 e9424ba1 2022-09-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
224 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
225 e9424ba1 2022-09-20 thomas echo "fail"
226 e9424ba1 2022-09-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
227 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
231 e9424ba1 2022-09-20 thomas echo "A $testroot/wt/alpha" > $testroot/stdout.expected
232 e9424ba1 2022-09-20 thomas echo "A $testroot/wt/beta" >> $testroot/stdout.expected
233 e9424ba1 2022-09-20 thomas echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
234 e9424ba1 2022-09-20 thomas echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
235 e9424ba1 2022-09-20 thomas echo "Checked out refs/heads/$headref: $head_commit" \
236 e9424ba1 2022-09-20 thomas >> $testroot/stdout.expected
237 e9424ba1 2022-09-20 thomas echo "Now shut up and hack" >> $testroot/stdout.expected
239 e9424ba1 2022-09-20 thomas got checkout $testroot/repo $testroot/wt > $testroot/stdout
240 e9424ba1 2022-09-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
242 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
243 e9424ba1 2022-09-20 thomas echo "fail"
244 e9424ba1 2022-09-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
245 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
249 e9424ba1 2022-09-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
251 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
252 e9424ba1 2022-09-20 thomas echo "fail"
253 e9424ba1 2022-09-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
254 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
258 e9424ba1 2022-09-20 thomas echo "alpha" > $testroot/content.expected
259 e9424ba1 2022-09-20 thomas echo "beta" >> $testroot/content.expected
260 e9424ba1 2022-09-20 thomas echo "zeta" >> $testroot/content.expected
261 e9424ba1 2022-09-20 thomas echo "delta" >> $testroot/content.expected
262 e9424ba1 2022-09-20 thomas cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
263 e9424ba1 2022-09-20 thomas $testroot/wt/gamma/delta > $testroot/content
265 e9424ba1 2022-09-20 thomas cmp -s $testroot/content.expected $testroot/content
267 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
268 e9424ba1 2022-09-20 thomas echo "fail"
269 e9424ba1 2022-09-20 thomas diff -u $testroot/content.expected $testroot/content
271 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
274 e9424ba1 2022-09-20 thomas test_import_detached_head() {
275 e9424ba1 2022-09-20 thomas local testroot=`test_init import_detached_head`
277 e9424ba1 2022-09-20 thomas # mute verbose 'detached HEAD' warning
278 e9424ba1 2022-09-20 thomas (cd $testroot/repo && git config --local advice.detachedHead false)
280 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
281 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
285 e9424ba1 2022-09-20 thomas # enter detached HEAD state
286 e9424ba1 2022-09-20 thomas local head_commit=`git_show_head $testroot/repo | cut -c1-7`
287 e9424ba1 2022-09-20 thomas (cd $testroot/repo && \
288 e9424ba1 2022-09-20 thomas git checkout $head_commit > $testroot/stdout 2> $testroot/stderr)
290 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
291 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
295 e9424ba1 2022-09-20 thomas echo "HEAD is now at $head_commit adding the test tree" >> \
296 e9424ba1 2022-09-20 thomas $testroot/stderr.expected
298 e9424ba1 2022-09-20 thomas cmp -s $testroot/stderr.expected $testroot/stderr
300 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
301 e9424ba1 2022-09-20 thomas echo "fail"
302 e9424ba1 2022-09-20 thomas diff -u $testroot/stderr.expected $testroot/stderr
303 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
307 e9424ba1 2022-09-20 thomas mkdir $testroot/import
308 e9424ba1 2022-09-20 thomas make_test_tree $testroot/import
310 e9424ba1 2022-09-20 thomas # detached HEAD (i.e., not symbolic) so import should fallback to "main"
311 e9424ba1 2022-09-20 thomas got import -r $testroot/repo -m init $testroot/import > $testroot/stdout
313 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
314 e9424ba1 2022-09-20 thomas test_done "$testroot" "$ret"
318 e9424ba1 2022-09-20 thomas local main_commit=`(cd $testroot/repo && \
319 e9424ba1 2022-09-20 thomas git show-ref main | cut -d ' ' -f 1)`
320 e9424ba1 2022-09-20 thomas echo "A $testroot/import/gamma/delta" > $testroot/stdout.expected
321 e9424ba1 2022-09-20 thomas echo "A $testroot/import/epsilon/zeta" >> $testroot/stdout.expected
322 e9424ba1 2022-09-20 thomas echo "A $testroot/import/alpha" >> $testroot/stdout.expected
323 e9424ba1 2022-09-20 thomas echo "A $testroot/import/beta" >> $testroot/stdout.expected
324 e9424ba1 2022-09-20 thomas echo "Created branch refs/heads/main with commit $main_commit" \
325 e9424ba1 2022-09-20 thomas >> $testroot/stdout.expected
327 e9424ba1 2022-09-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
329 e9424ba1 2022-09-20 thomas if [ $ret -ne 0 ]; then
330 e9424ba1 2022-09-20 thomas echo "fail"
331 e9424ba1 2022-09-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
333 e9424ba1 2022-09-20 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 27b10c3c 2022-07-04 thomas 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 3ce1b845 2019-07-15 stsp got import -I alpha -I '*lta*' -I '*silon' \
378 3ce1b845 2019-07-15 stsp -m 'init' -r $testroot/repo $testroot/tree > $testroot/stdout
380 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
381 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
385 3ce1b845 2019-07-15 stsp local head_commit=`git_show_head $testroot/repo`
386 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/beta" >> $testroot/stdout.expected
387 5d67f40d 2019-11-08 stsp echo "Created branch refs/heads/main with commit $head_commit" \
388 3ce1b845 2019-07-15 stsp >> $testroot/stdout.expected
390 3ce1b845 2019-07-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
392 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
393 3ce1b845 2019-07-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
395 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
398 f6cae3ed 2020-09-13 naddy test_import_empty_dir() {
399 db1d3576 2019-10-04 stsp local testname=import_empty_dir
400 743f0d3e 2020-10-01 stsp local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
402 27b10c3c 2022-07-04 thomas gotadmin init $testroot/repo
404 db1d3576 2019-10-04 stsp mkdir $testroot/tree
405 db1d3576 2019-10-04 stsp mkdir -p $testroot/tree/empty $testroot/tree/notempty
406 db1d3576 2019-10-04 stsp echo "alpha" > $testroot/tree/notempty/alpha
408 db1d3576 2019-10-04 stsp got import -m 'init' -r $testroot/repo $testroot/tree > $testroot/stdout
410 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
411 db1d3576 2019-10-04 stsp test_done "$testroot" "$ret"
415 db1d3576 2019-10-04 stsp local head_commit=`git_show_head $testroot/repo`
416 db1d3576 2019-10-04 stsp echo "A $testroot/tree/notempty/alpha" >> $testroot/stdout.expected
417 5d67f40d 2019-11-08 stsp echo "Created branch refs/heads/main with commit $head_commit" \
418 db1d3576 2019-10-04 stsp >> $testroot/stdout.expected
420 db1d3576 2019-10-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
422 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
423 db1d3576 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
424 db1d3576 2019-10-04 stsp test_done "$testroot" "$ret"
428 db1d3576 2019-10-04 stsp # Verify that Got did not import the empty directory
429 db1d3576 2019-10-04 stsp echo "notempty/" > $testroot/stdout.expected
430 db1d3576 2019-10-04 stsp echo "notempty/alpha" >> $testroot/stdout.expected
432 db1d3576 2019-10-04 stsp got tree -r $testroot/repo -R > $testroot/stdout
433 db1d3576 2019-10-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
435 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
436 db1d3576 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
438 db1d3576 2019-10-04 stsp test_done "$testroot" "$ret"
441 f6cae3ed 2020-09-13 naddy test_import_symlink() {
442 e8863bdc 2020-07-23 stsp local testname=import_symlink
443 743f0d3e 2020-10-01 stsp local testroot=`mktemp -d "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXX"`
445 27b10c3c 2022-07-04 thomas gotadmin init $testroot/repo
447 e8863bdc 2020-07-23 stsp mkdir $testroot/tree
448 e8863bdc 2020-07-23 stsp echo 'this is file alpha' > $testroot/tree/alpha
449 e8863bdc 2020-07-23 stsp ln -s alpha $testroot/tree/alpha.link
451 e8863bdc 2020-07-23 stsp got import -m 'init' -r $testroot/repo $testroot/tree \
452 e8863bdc 2020-07-23 stsp > $testroot/stdout
454 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
455 e8863bdc 2020-07-23 stsp test_done "$testroot" "$ret"
459 e8863bdc 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
460 e8863bdc 2020-07-23 stsp echo "A $testroot/tree/alpha" > $testroot/stdout.expected
461 e8863bdc 2020-07-23 stsp echo "A $testroot/tree/alpha.link" >> $testroot/stdout.expected
462 e8863bdc 2020-07-23 stsp echo "Created branch refs/heads/main with commit $head_commit" \
463 e8863bdc 2020-07-23 stsp >> $testroot/stdout.expected
465 e8863bdc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
467 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
468 e8863bdc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
469 e8863bdc 2020-07-23 stsp test_done "$testroot" "$ret"
473 e8863bdc 2020-07-23 stsp id_alpha=`get_blob_id $testroot/repo "" alpha`
474 e8863bdc 2020-07-23 stsp id_alpha_link=$(got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | cut -d' ' -f 1)
475 e8863bdc 2020-07-23 stsp tree_id=`(cd $testroot/repo && got cat $head_commit | \
476 e8863bdc 2020-07-23 stsp grep ^tree | cut -d ' ' -f 2)`
478 e8863bdc 2020-07-23 stsp got tree -i -r $testroot/repo -c $head_commit > $testroot/stdout
480 e8863bdc 2020-07-23 stsp echo "$id_alpha alpha" > $testroot/stdout.expected
481 e8863bdc 2020-07-23 stsp echo "$id_alpha_link alpha.link@ -> alpha" >> $testroot/stdout.expected
483 e8863bdc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
485 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
486 e8863bdc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
488 e8863bdc 2020-07-23 stsp test_done "$testroot" "$ret"
491 7fb414ae 2020-08-08 stsp test_parseargs "$@"
492 3ce1b845 2019-07-15 stsp run_test test_import_basic
493 e9424ba1 2022-09-20 thomas run_test test_import_specified_head
494 e9424ba1 2022-09-20 thomas run_test test_import_detached_head
495 3ce1b845 2019-07-15 stsp run_test test_import_requires_new_branch
496 3ce1b845 2019-07-15 stsp run_test test_import_ignores
497 db1d3576 2019-10-04 stsp run_test test_import_empty_dir
498 e8863bdc 2020-07-23 stsp run_test test_import_symlink