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 ea2819be 2023-05-29 op local testroot=`mktemp -d \
22 ea2819be 2023-05-29 op "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXXXX"`
24 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo
26 3ce1b845 2019-07-15 stsp mkdir $testroot/tree
27 3ce1b845 2019-07-15 stsp make_test_tree $testroot/tree
29 3ce1b845 2019-07-15 stsp got import -m 'init' -r $testroot/repo $testroot/tree \
30 3ce1b845 2019-07-15 stsp > $testroot/stdout
32 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
33 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
37 3ce1b845 2019-07-15 stsp local head_commit=`git_show_head $testroot/repo`
38 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/gamma/delta" > $testroot/stdout.expected
39 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/epsilon/zeta" >> $testroot/stdout.expected
40 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/alpha" >> $testroot/stdout.expected
41 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/beta" >> $testroot/stdout.expected
42 5d67f40d 2019-11-08 stsp echo "Created branch refs/heads/main with commit $head_commit" \
43 3ce1b845 2019-07-15 stsp >> $testroot/stdout.expected
45 3ce1b845 2019-07-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
47 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
48 3ce1b845 2019-07-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
49 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
53 3ce1b845 2019-07-15 stsp (cd $testroot/repo && got log -p | grep -v ^date: > $testroot/stdout)
55 3ce1b845 2019-07-15 stsp id_alpha=`get_blob_id $testroot/repo "" alpha`
56 3ce1b845 2019-07-15 stsp id_beta=`get_blob_id $testroot/repo "" beta`
57 3ce1b845 2019-07-15 stsp id_zeta=`get_blob_id $testroot/repo epsilon zeta`
58 3ce1b845 2019-07-15 stsp id_delta=`get_blob_id $testroot/repo gamma delta`
59 44392932 2019-08-25 stsp tree_id=`(cd $testroot/repo && got cat $head_commit | \
60 44392932 2019-08-25 stsp grep ^tree | cut -d ' ' -f 2)`
62 3ce1b845 2019-07-15 stsp echo "-----------------------------------------------" \
63 3ce1b845 2019-07-15 stsp > $testroot/stdout.expected
64 5d67f40d 2019-11-08 stsp echo "commit $head_commit (main)" >> $testroot/stdout.expected
65 3ce1b845 2019-07-15 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
66 3ce1b845 2019-07-15 stsp echo " " >> $testroot/stdout.expected
67 3ce1b845 2019-07-15 stsp echo " init" >> $testroot/stdout.expected
68 3ce1b845 2019-07-15 stsp echo " " >> $testroot/stdout.expected
69 8469d821 2022-06-25 stsp echo "diff /dev/null $head_commit" >> $testroot/stdout.expected
70 8469d821 2022-06-25 stsp echo "commit - /dev/null" >> $testroot/stdout.expected
71 8469d821 2022-06-25 stsp echo "commit + $head_commit" >> $testroot/stdout.expected
72 3ce1b845 2019-07-15 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
73 46f68b20 2019-10-19 stsp echo "blob + $id_alpha (mode 644)" >> $testroot/stdout.expected
74 3ce1b845 2019-07-15 stsp echo "--- /dev/null" >> $testroot/stdout.expected
75 3ce1b845 2019-07-15 stsp echo "+++ alpha" >> $testroot/stdout.expected
76 3ce1b845 2019-07-15 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
77 3ce1b845 2019-07-15 stsp echo "+alpha" >> $testroot/stdout.expected
78 3ce1b845 2019-07-15 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
79 46f68b20 2019-10-19 stsp echo "blob + $id_beta (mode 644)" >> $testroot/stdout.expected
80 3ce1b845 2019-07-15 stsp echo "--- /dev/null" >> $testroot/stdout.expected
81 3ce1b845 2019-07-15 stsp echo "+++ beta" >> $testroot/stdout.expected
82 3ce1b845 2019-07-15 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
83 3ce1b845 2019-07-15 stsp echo "+beta" >> $testroot/stdout.expected
84 3ce1b845 2019-07-15 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
85 46f68b20 2019-10-19 stsp echo "blob + $id_zeta (mode 644)" >> $testroot/stdout.expected
86 3ce1b845 2019-07-15 stsp echo "--- /dev/null" >> $testroot/stdout.expected
87 3ce1b845 2019-07-15 stsp echo "+++ epsilon/zeta" >> $testroot/stdout.expected
88 3ce1b845 2019-07-15 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
89 3ce1b845 2019-07-15 stsp echo "+zeta" >> $testroot/stdout.expected
90 3ce1b845 2019-07-15 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
91 46f68b20 2019-10-19 stsp echo "blob + $id_delta (mode 644)" >> $testroot/stdout.expected
92 3ce1b845 2019-07-15 stsp echo "--- /dev/null" >> $testroot/stdout.expected
93 3ce1b845 2019-07-15 stsp echo "+++ gamma/delta" >> $testroot/stdout.expected
94 3ce1b845 2019-07-15 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
95 3ce1b845 2019-07-15 stsp echo "+delta" >> $testroot/stdout.expected
96 3ce1b845 2019-07-15 stsp echo "" >> $testroot/stdout.expected
98 3ce1b845 2019-07-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
100 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
101 3ce1b845 2019-07-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
102 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
106 3ce1b845 2019-07-15 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
107 3ce1b845 2019-07-15 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
108 3ce1b845 2019-07-15 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
109 3ce1b845 2019-07-15 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
110 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/main: $head_commit" \
111 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
112 3ce1b845 2019-07-15 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
114 3ce1b845 2019-07-15 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
116 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
117 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
121 3ce1b845 2019-07-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
123 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
124 3ce1b845 2019-07-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
125 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
129 3ce1b845 2019-07-15 stsp echo "alpha" > $testroot/content.expected
130 3ce1b845 2019-07-15 stsp echo "beta" >> $testroot/content.expected
131 3ce1b845 2019-07-15 stsp echo "zeta" >> $testroot/content.expected
132 3ce1b845 2019-07-15 stsp echo "delta" >> $testroot/content.expected
133 3ce1b845 2019-07-15 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
134 3ce1b845 2019-07-15 stsp $testroot/wt/gamma/delta > $testroot/content
136 3ce1b845 2019-07-15 stsp cmp -s $testroot/content.expected $testroot/content
138 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
139 3ce1b845 2019-07-15 stsp diff -u $testroot/content.expected $testroot/content
141 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
144 6f04a73d 2022-09-20 mark test_import_specified_head() {
145 6f04a73d 2022-09-20 mark local testname=import_specified_head
146 ea2819be 2023-05-29 op local testroot=`mktemp -d \
147 ea2819be 2023-05-29 op "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXXXX"`
148 6f04a73d 2022-09-20 mark local headref=trunk
150 6f04a73d 2022-09-20 mark gotadmin init -b $headref $testroot/repo
152 6f04a73d 2022-09-20 mark mkdir $testroot/tree
153 6f04a73d 2022-09-20 mark make_test_tree $testroot/tree
155 6f04a73d 2022-09-20 mark got import -m init -r $testroot/repo $testroot/tree > $testroot/stdout
157 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
158 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
162 6f04a73d 2022-09-20 mark local head_commit=`git_show_head $testroot/repo`
163 6f04a73d 2022-09-20 mark echo "A $testroot/tree/gamma/delta" > $testroot/stdout.expected
164 6f04a73d 2022-09-20 mark echo "A $testroot/tree/epsilon/zeta" >> $testroot/stdout.expected
165 6f04a73d 2022-09-20 mark echo "A $testroot/tree/alpha" >> $testroot/stdout.expected
166 6f04a73d 2022-09-20 mark echo "A $testroot/tree/beta" >> $testroot/stdout.expected
167 6f04a73d 2022-09-20 mark echo "Created branch refs/heads/$headref with commit $head_commit" \
168 6f04a73d 2022-09-20 mark >> $testroot/stdout.expected
170 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
172 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
173 6f04a73d 2022-09-20 mark echo "fail"
174 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
175 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
179 6f04a73d 2022-09-20 mark (cd $testroot/repo && got log -p | grep -v ^date: > $testroot/stdout)
181 6f04a73d 2022-09-20 mark id_alpha=`get_blob_id $testroot/repo "" alpha`
182 6f04a73d 2022-09-20 mark id_beta=`get_blob_id $testroot/repo "" beta`
183 6f04a73d 2022-09-20 mark id_zeta=`get_blob_id $testroot/repo epsilon zeta`
184 6f04a73d 2022-09-20 mark id_delta=`get_blob_id $testroot/repo gamma delta`
185 6f04a73d 2022-09-20 mark tree_id=`(cd $testroot/repo && got cat $head_commit | \
186 6f04a73d 2022-09-20 mark grep ^tree | cut -d ' ' -f 2)`
188 6f04a73d 2022-09-20 mark echo "-----------------------------------------------" \
189 6f04a73d 2022-09-20 mark > $testroot/stdout.expected
190 6f04a73d 2022-09-20 mark echo "commit $head_commit ($headref)" >> $testroot/stdout.expected
191 6f04a73d 2022-09-20 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
192 6f04a73d 2022-09-20 mark echo " " >> $testroot/stdout.expected
193 6f04a73d 2022-09-20 mark echo " init" >> $testroot/stdout.expected
194 6f04a73d 2022-09-20 mark echo " " >> $testroot/stdout.expected
195 6f04a73d 2022-09-20 mark echo "diff /dev/null $head_commit" >> $testroot/stdout.expected
196 6f04a73d 2022-09-20 mark echo "commit - /dev/null" >> $testroot/stdout.expected
197 6f04a73d 2022-09-20 mark echo "commit + $head_commit" >> $testroot/stdout.expected
198 6f04a73d 2022-09-20 mark echo "blob - /dev/null" >> $testroot/stdout.expected
199 6f04a73d 2022-09-20 mark echo "blob + $id_alpha (mode 644)" >> $testroot/stdout.expected
200 6f04a73d 2022-09-20 mark echo "--- /dev/null" >> $testroot/stdout.expected
201 6f04a73d 2022-09-20 mark echo "+++ alpha" >> $testroot/stdout.expected
202 6f04a73d 2022-09-20 mark echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
203 6f04a73d 2022-09-20 mark echo "+alpha" >> $testroot/stdout.expected
204 6f04a73d 2022-09-20 mark echo "blob - /dev/null" >> $testroot/stdout.expected
205 6f04a73d 2022-09-20 mark echo "blob + $id_beta (mode 644)" >> $testroot/stdout.expected
206 6f04a73d 2022-09-20 mark echo "--- /dev/null" >> $testroot/stdout.expected
207 6f04a73d 2022-09-20 mark echo "+++ beta" >> $testroot/stdout.expected
208 6f04a73d 2022-09-20 mark echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
209 6f04a73d 2022-09-20 mark echo "+beta" >> $testroot/stdout.expected
210 6f04a73d 2022-09-20 mark echo "blob - /dev/null" >> $testroot/stdout.expected
211 6f04a73d 2022-09-20 mark echo "blob + $id_zeta (mode 644)" >> $testroot/stdout.expected
212 6f04a73d 2022-09-20 mark echo "--- /dev/null" >> $testroot/stdout.expected
213 6f04a73d 2022-09-20 mark echo "+++ epsilon/zeta" >> $testroot/stdout.expected
214 6f04a73d 2022-09-20 mark echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
215 6f04a73d 2022-09-20 mark echo "+zeta" >> $testroot/stdout.expected
216 6f04a73d 2022-09-20 mark echo "blob - /dev/null" >> $testroot/stdout.expected
217 6f04a73d 2022-09-20 mark echo "blob + $id_delta (mode 644)" >> $testroot/stdout.expected
218 6f04a73d 2022-09-20 mark echo "--- /dev/null" >> $testroot/stdout.expected
219 6f04a73d 2022-09-20 mark echo "+++ gamma/delta" >> $testroot/stdout.expected
220 6f04a73d 2022-09-20 mark echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
221 6f04a73d 2022-09-20 mark echo "+delta" >> $testroot/stdout.expected
222 6f04a73d 2022-09-20 mark echo "" >> $testroot/stdout.expected
224 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
226 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
227 6f04a73d 2022-09-20 mark echo "fail"
228 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
229 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
233 6f04a73d 2022-09-20 mark echo "A $testroot/wt/alpha" > $testroot/stdout.expected
234 6f04a73d 2022-09-20 mark echo "A $testroot/wt/beta" >> $testroot/stdout.expected
235 6f04a73d 2022-09-20 mark echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
236 6f04a73d 2022-09-20 mark echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
237 6f04a73d 2022-09-20 mark echo "Checked out refs/heads/$headref: $head_commit" \
238 6f04a73d 2022-09-20 mark >> $testroot/stdout.expected
239 6f04a73d 2022-09-20 mark echo "Now shut up and hack" >> $testroot/stdout.expected
241 6f04a73d 2022-09-20 mark got checkout $testroot/repo $testroot/wt > $testroot/stdout
242 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
244 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
245 6f04a73d 2022-09-20 mark echo "fail"
246 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
247 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
251 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
253 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
254 6f04a73d 2022-09-20 mark echo "fail"
255 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
256 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
260 6f04a73d 2022-09-20 mark echo "alpha" > $testroot/content.expected
261 6f04a73d 2022-09-20 mark echo "beta" >> $testroot/content.expected
262 6f04a73d 2022-09-20 mark echo "zeta" >> $testroot/content.expected
263 6f04a73d 2022-09-20 mark echo "delta" >> $testroot/content.expected
264 6f04a73d 2022-09-20 mark cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
265 6f04a73d 2022-09-20 mark $testroot/wt/gamma/delta > $testroot/content
267 6f04a73d 2022-09-20 mark cmp -s $testroot/content.expected $testroot/content
269 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
270 6f04a73d 2022-09-20 mark echo "fail"
271 6f04a73d 2022-09-20 mark diff -u $testroot/content.expected $testroot/content
273 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
276 6f04a73d 2022-09-20 mark test_import_detached_head() {
277 6f04a73d 2022-09-20 mark local testroot=`test_init import_detached_head`
279 6f04a73d 2022-09-20 mark # mute verbose 'detached HEAD' warning
280 6f04a73d 2022-09-20 mark (cd $testroot/repo && git config --local advice.detachedHead false)
282 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
283 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
287 6f04a73d 2022-09-20 mark # enter detached HEAD state
288 6f04a73d 2022-09-20 mark local head_commit=`git_show_head $testroot/repo | cut -c1-7`
289 6f04a73d 2022-09-20 mark (cd $testroot/repo && \
290 6f04a73d 2022-09-20 mark git checkout $head_commit > $testroot/stdout 2> $testroot/stderr)
292 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
293 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
297 6f04a73d 2022-09-20 mark echo "HEAD is now at $head_commit adding the test tree" >> \
298 6f04a73d 2022-09-20 mark $testroot/stderr.expected
300 6f04a73d 2022-09-20 mark cmp -s $testroot/stderr.expected $testroot/stderr
302 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
303 6f04a73d 2022-09-20 mark echo "fail"
304 6f04a73d 2022-09-20 mark diff -u $testroot/stderr.expected $testroot/stderr
305 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
309 6f04a73d 2022-09-20 mark mkdir $testroot/import
310 6f04a73d 2022-09-20 mark make_test_tree $testroot/import
312 6f04a73d 2022-09-20 mark # detached HEAD (i.e., not symbolic) so import should fallback to "main"
313 6f04a73d 2022-09-20 mark got import -r $testroot/repo -m init $testroot/import > $testroot/stdout
315 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
316 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
320 6f04a73d 2022-09-20 mark local main_commit=`(cd $testroot/repo && \
321 6f04a73d 2022-09-20 mark git show-ref main | cut -d ' ' -f 1)`
322 6f04a73d 2022-09-20 mark echo "A $testroot/import/gamma/delta" > $testroot/stdout.expected
323 6f04a73d 2022-09-20 mark echo "A $testroot/import/epsilon/zeta" >> $testroot/stdout.expected
324 6f04a73d 2022-09-20 mark echo "A $testroot/import/alpha" >> $testroot/stdout.expected
325 6f04a73d 2022-09-20 mark echo "A $testroot/import/beta" >> $testroot/stdout.expected
326 6f04a73d 2022-09-20 mark echo "Created branch refs/heads/main with commit $main_commit" \
327 6f04a73d 2022-09-20 mark >> $testroot/stdout.expected
329 6f04a73d 2022-09-20 mark cmp -s $testroot/stdout.expected $testroot/stdout
331 6f04a73d 2022-09-20 mark if [ $ret -ne 0 ]; then
332 6f04a73d 2022-09-20 mark echo "fail"
333 6f04a73d 2022-09-20 mark diff -u $testroot/stdout.expected $testroot/stdout
335 6f04a73d 2022-09-20 mark test_done "$testroot" "$ret"
338 f6cae3ed 2020-09-13 naddy test_import_requires_new_branch() {
339 3ce1b845 2019-07-15 stsp local testroot=`test_init import_requires_new_branch`
341 3ce1b845 2019-07-15 stsp mkdir $testroot/tree
342 3ce1b845 2019-07-15 stsp make_test_tree $testroot/tree
344 5d67f40d 2019-11-08 stsp got import -b master -m 'init' -r $testroot/repo $testroot/tree \
345 3ce1b845 2019-07-15 stsp > $testroot/stdout 2> $testroot/stderr
347 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
348 3ce1b845 2019-07-15 stsp echo "import command should have failed but did not"
349 3ce1b845 2019-07-15 stsp test_done "$testroot" "1"
353 3ce1b845 2019-07-15 stsp echo "got: import target branch already exists" \
354 3ce1b845 2019-07-15 stsp > $testroot/stderr.expected
355 3ce1b845 2019-07-15 stsp cmp -s $testroot/stderr.expected $testroot/stderr
357 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
358 3ce1b845 2019-07-15 stsp diff -u $testroot/stderr.expected $testroot/stderr
359 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
363 3ce1b845 2019-07-15 stsp got import -b newbranch -m 'init' -r $testroot/repo $testroot/tree \
364 3ce1b845 2019-07-15 stsp > $testroot/stdout
366 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
370 f6cae3ed 2020-09-13 naddy test_import_ignores() {
371 71db5e8c 2019-08-08 stsp local testname=import_ignores
372 ea2819be 2023-05-29 op local testroot=`mktemp -d \
373 ea2819be 2023-05-29 op "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXXXX"`
375 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo
377 3ce1b845 2019-07-15 stsp mkdir $testroot/tree
378 3ce1b845 2019-07-15 stsp make_test_tree $testroot/tree
380 d0f874e0 2023-02-19 stsp touch $testroot/tree/upsilon
381 d0f874e0 2023-02-19 stsp mkdir $testroot/tree/ysilon
382 49351f3b 2023-02-06 stsp got import -I alpha -I 'beta/' -I '*lta*' -I '*silon/' \
383 3ce1b845 2019-07-15 stsp -m 'init' -r $testroot/repo $testroot/tree > $testroot/stdout
385 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
386 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
390 3ce1b845 2019-07-15 stsp local head_commit=`git_show_head $testroot/repo`
391 3ce1b845 2019-07-15 stsp echo "A $testroot/tree/beta" >> $testroot/stdout.expected
392 d0f874e0 2023-02-19 stsp echo "A $testroot/tree/upsilon" >> $testroot/stdout.expected
393 5d67f40d 2019-11-08 stsp echo "Created branch refs/heads/main with commit $head_commit" \
394 3ce1b845 2019-07-15 stsp >> $testroot/stdout.expected
396 3ce1b845 2019-07-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
398 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
399 3ce1b845 2019-07-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
401 3ce1b845 2019-07-15 stsp test_done "$testroot" "$ret"
404 f6cae3ed 2020-09-13 naddy test_import_empty_dir() {
405 db1d3576 2019-10-04 stsp local testname=import_empty_dir
406 ea2819be 2023-05-29 op local testroot=`mktemp -d \
407 ea2819be 2023-05-29 op "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXXXX"`
409 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo
411 db1d3576 2019-10-04 stsp mkdir $testroot/tree
412 db1d3576 2019-10-04 stsp mkdir -p $testroot/tree/empty $testroot/tree/notempty
413 db1d3576 2019-10-04 stsp echo "alpha" > $testroot/tree/notempty/alpha
415 db1d3576 2019-10-04 stsp got import -m 'init' -r $testroot/repo $testroot/tree > $testroot/stdout
417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
418 db1d3576 2019-10-04 stsp test_done "$testroot" "$ret"
422 db1d3576 2019-10-04 stsp local head_commit=`git_show_head $testroot/repo`
423 db1d3576 2019-10-04 stsp echo "A $testroot/tree/notempty/alpha" >> $testroot/stdout.expected
424 5d67f40d 2019-11-08 stsp echo "Created branch refs/heads/main with commit $head_commit" \
425 db1d3576 2019-10-04 stsp >> $testroot/stdout.expected
427 db1d3576 2019-10-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
429 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
430 db1d3576 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
431 db1d3576 2019-10-04 stsp test_done "$testroot" "$ret"
435 db1d3576 2019-10-04 stsp # Verify that Got did not import the empty directory
436 db1d3576 2019-10-04 stsp echo "notempty/" > $testroot/stdout.expected
437 db1d3576 2019-10-04 stsp echo "notempty/alpha" >> $testroot/stdout.expected
439 db1d3576 2019-10-04 stsp got tree -r $testroot/repo -R > $testroot/stdout
440 db1d3576 2019-10-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
442 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
443 db1d3576 2019-10-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
445 db1d3576 2019-10-04 stsp test_done "$testroot" "$ret"
448 f6cae3ed 2020-09-13 naddy test_import_symlink() {
449 e8863bdc 2020-07-23 stsp local testname=import_symlink
450 ea2819be 2023-05-29 op local testroot=`mktemp -d \
451 ea2819be 2023-05-29 op "$GOT_TEST_ROOT/got-test-$testname-XXXXXXXXXX"`
453 02a5c5d0 2022-07-04 stsp gotadmin init $testroot/repo
455 e8863bdc 2020-07-23 stsp mkdir $testroot/tree
456 e8863bdc 2020-07-23 stsp echo 'this is file alpha' > $testroot/tree/alpha
457 e8863bdc 2020-07-23 stsp ln -s alpha $testroot/tree/alpha.link
459 e8863bdc 2020-07-23 stsp got import -m 'init' -r $testroot/repo $testroot/tree \
460 e8863bdc 2020-07-23 stsp > $testroot/stdout
462 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
463 e8863bdc 2020-07-23 stsp test_done "$testroot" "$ret"
467 e8863bdc 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
468 e8863bdc 2020-07-23 stsp echo "A $testroot/tree/alpha" > $testroot/stdout.expected
469 e8863bdc 2020-07-23 stsp echo "A $testroot/tree/alpha.link" >> $testroot/stdout.expected
470 e8863bdc 2020-07-23 stsp echo "Created branch refs/heads/main with commit $head_commit" \
471 e8863bdc 2020-07-23 stsp >> $testroot/stdout.expected
473 e8863bdc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
475 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
476 e8863bdc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
477 e8863bdc 2020-07-23 stsp test_done "$testroot" "$ret"
481 e8863bdc 2020-07-23 stsp id_alpha=`get_blob_id $testroot/repo "" alpha`
482 e8863bdc 2020-07-23 stsp id_alpha_link=$(got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | cut -d' ' -f 1)
483 e8863bdc 2020-07-23 stsp tree_id=`(cd $testroot/repo && got cat $head_commit | \
484 e8863bdc 2020-07-23 stsp grep ^tree | cut -d ' ' -f 2)`
486 e8863bdc 2020-07-23 stsp got tree -i -r $testroot/repo -c $head_commit > $testroot/stdout
488 e8863bdc 2020-07-23 stsp echo "$id_alpha alpha" > $testroot/stdout.expected
489 e8863bdc 2020-07-23 stsp echo "$id_alpha_link alpha.link@ -> alpha" >> $testroot/stdout.expected
491 e8863bdc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
493 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
494 e8863bdc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
496 e8863bdc 2020-07-23 stsp test_done "$testroot" "$ret"
499 7fb414ae 2020-08-08 stsp test_parseargs "$@"
500 3ce1b845 2019-07-15 stsp run_test test_import_basic
501 6f04a73d 2022-09-20 mark run_test test_import_specified_head
502 6f04a73d 2022-09-20 mark run_test test_import_detached_head
503 3ce1b845 2019-07-15 stsp run_test test_import_requires_new_branch
504 3ce1b845 2019-07-15 stsp run_test test_import_ignores
505 db1d3576 2019-10-04 stsp run_test test_import_empty_dir
506 e8863bdc 2020-07-23 stsp run_test test_import_symlink