Blame


1 6dbf1e9e 2019-03-26 stsp #!/bin/sh
2 6dbf1e9e 2019-03-26 stsp #
3 6dbf1e9e 2019-03-26 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 6dbf1e9e 2019-03-26 stsp #
5 6dbf1e9e 2019-03-26 stsp # Permission to use, copy, modify, and distribute this software for any
6 6dbf1e9e 2019-03-26 stsp # purpose with or without fee is hereby granted, provided that the above
7 6dbf1e9e 2019-03-26 stsp # copyright notice and this permission notice appear in all copies.
8 6dbf1e9e 2019-03-26 stsp #
9 6dbf1e9e 2019-03-26 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 6dbf1e9e 2019-03-26 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 6dbf1e9e 2019-03-26 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 6dbf1e9e 2019-03-26 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 6dbf1e9e 2019-03-26 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 6dbf1e9e 2019-03-26 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 6dbf1e9e 2019-03-26 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 6dbf1e9e 2019-03-26 stsp
17 6dbf1e9e 2019-03-26 stsp . ./common.sh
18 6dbf1e9e 2019-03-26 stsp
19 f6cae3ed 2020-09-13 naddy test_add_basic() {
20 6dbf1e9e 2019-03-26 stsp local testroot=`test_init add_basic`
21 6dbf1e9e 2019-03-26 stsp
22 6dbf1e9e 2019-03-26 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 fc414659 2022-04-16 thomas ret=$?
24 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
25 6dbf1e9e 2019-03-26 stsp test_done "$testroot" "$ret"
26 6dbf1e9e 2019-03-26 stsp return 1
27 6dbf1e9e 2019-03-26 stsp fi
28 6dbf1e9e 2019-03-26 stsp
29 6dbf1e9e 2019-03-26 stsp echo "new file" > $testroot/wt/foo
30 6dbf1e9e 2019-03-26 stsp
31 6dbf1e9e 2019-03-26 stsp echo 'A foo' > $testroot/stdout.expected
32 6dbf1e9e 2019-03-26 stsp (cd $testroot/wt && got add foo > $testroot/stdout)
33 6dbf1e9e 2019-03-26 stsp
34 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
35 fc414659 2022-04-16 thomas ret=$?
36 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
37 6dbf1e9e 2019-03-26 stsp diff -u $testroot/stdout.expected $testroot/stdout
38 6dbf1e9e 2019-03-26 stsp fi
39 6dbf1e9e 2019-03-26 stsp test_done "$testroot" "$ret"
40 6dbf1e9e 2019-03-26 stsp }
41 6dbf1e9e 2019-03-26 stsp
42 f6cae3ed 2020-09-13 naddy test_double_add() {
43 5c99ca9f 2019-03-27 stsp local testroot=`test_init double_add`
44 5c99ca9f 2019-03-27 stsp
45 5c99ca9f 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
46 fc414659 2022-04-16 thomas ret=$?
47 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
48 5c99ca9f 2019-03-27 stsp test_done "$testroot" "$ret"
49 5c99ca9f 2019-03-27 stsp return 1
50 5c99ca9f 2019-03-27 stsp fi
51 5c99ca9f 2019-03-27 stsp
52 5c99ca9f 2019-03-27 stsp echo "new file" > $testroot/wt/foo
53 5c99ca9f 2019-03-27 stsp (cd $testroot/wt && got add foo > /dev/null)
54 5c99ca9f 2019-03-27 stsp
55 dbb83fbd 2019-12-12 stsp (cd $testroot/wt && got add foo > $testroot/stdout)
56 fc414659 2022-04-16 thomas ret=$?
57 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
58 723c305c 2019-05-11 jcs echo "got add failed unexpectedly" >&2
59 5c99ca9f 2019-03-27 stsp test_done "$testroot" 1
60 a7c182ac 2019-03-27 stsp return 1
61 5c99ca9f 2019-03-27 stsp fi
62 5c99ca9f 2019-03-27 stsp
63 dbb83fbd 2019-12-12 stsp echo -n > $testroot/stdout.expected
64 e0d77865 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
65 e0d77865 2023-06-22 thomas ret=$?
66 e0d77865 2023-06-22 thomas if [ $ret -ne 0 ]; then
67 e0d77865 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
68 e0d77865 2023-06-22 thomas test_done "$testroot" "$ret"
69 e0d77865 2023-06-22 thomas return 1
70 e0d77865 2023-06-22 thomas fi
71 e0d77865 2023-06-22 thomas
72 e0d77865 2023-06-22 thomas echo "new file" > $testroot/wt/epsilon/zeta2
73 e0d77865 2023-06-22 thomas (cd $testroot/wt && got add epsilon/zeta* > $testroot/stdout)
74 e0d77865 2023-06-22 thomas ret=$?
75 e0d77865 2023-06-22 thomas if [ $ret -ne 0 ]; then
76 e0d77865 2023-06-22 thomas echo "got add failed unexpectedly" >&2
77 e0d77865 2023-06-22 thomas test_done "$testroot" 1
78 e0d77865 2023-06-22 thomas return 1
79 e0d77865 2023-06-22 thomas fi
80 e0d77865 2023-06-22 thomas
81 e0d77865 2023-06-22 thomas echo 'A epsilon/zeta2' > $testroot/stdout.expected
82 dbb83fbd 2019-12-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
83 fc414659 2022-04-16 thomas ret=$?
84 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
85 dbb83fbd 2019-12-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
86 dbb83fbd 2019-12-12 stsp fi
87 723c305c 2019-05-11 jcs test_done "$testroot" "$ret"
88 723c305c 2019-05-11 jcs }
89 723c305c 2019-05-11 jcs
90 f6cae3ed 2020-09-13 naddy test_add_multiple() {
91 723c305c 2019-05-11 jcs local testroot=`test_init multiple_add`
92 723c305c 2019-05-11 jcs
93 723c305c 2019-05-11 jcs got checkout $testroot/repo $testroot/wt > /dev/null
94 fc414659 2022-04-16 thomas ret=$?
95 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
96 723c305c 2019-05-11 jcs test_done "$testroot" "$ret"
97 723c305c 2019-05-11 jcs return 1
98 5c99ca9f 2019-03-27 stsp fi
99 723c305c 2019-05-11 jcs
100 723c305c 2019-05-11 jcs echo "new file" > $testroot/wt/foo
101 723c305c 2019-05-11 jcs echo "new file" > $testroot/wt/bar
102 723c305c 2019-05-11 jcs echo "new file" > $testroot/wt/baz
103 2b01eb6c 2019-05-11 stsp (cd $testroot/wt && got add foo bar baz > $testroot/stdout)
104 fc414659 2022-04-16 thomas ret=$?
105 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
106 723c305c 2019-05-11 jcs echo "got add failed unexpectedly" >&2
107 723c305c 2019-05-11 jcs test_done "$testroot" 1
108 723c305c 2019-05-11 jcs return 1
109 723c305c 2019-05-11 jcs fi
110 723c305c 2019-05-11 jcs
111 f1417e9f 2021-10-12 thomas echo "A bar" > $testroot/stdout.expected
112 2b01eb6c 2019-05-11 stsp echo "A baz" >> $testroot/stdout.expected
113 f1417e9f 2021-10-12 thomas echo "A foo" >> $testroot/stdout.expected
114 aa174d08 2023-06-22 thomas
115 aa174d08 2023-06-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
116 aa174d08 2023-06-22 thomas ret=$?
117 aa174d08 2023-06-22 thomas if [ $ret -ne 0 ]; then
118 aa174d08 2023-06-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
119 aa174d08 2023-06-22 thomas test_done "$testroot" "$ret"
120 aa174d08 2023-06-22 thomas return 1
121 aa174d08 2023-06-22 thomas fi
122 aa174d08 2023-06-22 thomas
123 b21ebdb0 2023-06-22 thomas echo "changed file" > $testroot/wt/alpha
124 aa174d08 2023-06-22 thomas echo "new file" > $testroot/wt/bax
125 aa174d08 2023-06-22 thomas (cd $testroot/wt && got add -R * > $testroot/stdout)
126 aa174d08 2023-06-22 thomas ret=$?
127 aa174d08 2023-06-22 thomas if [ $ret -ne 0 ]; then
128 aa174d08 2023-06-22 thomas echo "got add failed unexpectedly" >&2
129 aa174d08 2023-06-22 thomas test_done "$testroot" 1
130 aa174d08 2023-06-22 thomas return 1
131 aa174d08 2023-06-22 thomas fi
132 aa174d08 2023-06-22 thomas
133 aa174d08 2023-06-22 thomas echo "A bax" > $testroot/stdout.expected
134 2b01eb6c 2019-05-11 stsp
135 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
136 fc414659 2022-04-16 thomas ret=$?
137 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
138 2b01eb6c 2019-05-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
139 2b01eb6c 2019-05-11 stsp fi
140 aa174d08 2023-06-22 thomas
141 5c99ca9f 2019-03-27 stsp test_done "$testroot" "$ret"
142 5c99ca9f 2019-03-27 stsp }
143 5c99ca9f 2019-03-27 stsp
144 f6cae3ed 2020-09-13 naddy test_add_file_in_new_subdir() {
145 a9fa2909 2019-07-27 stsp local testroot=`test_init add_file_in_new_subdir`
146 a9fa2909 2019-07-27 stsp
147 a9fa2909 2019-07-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
148 fc414659 2022-04-16 thomas ret=$?
149 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
150 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
151 a9fa2909 2019-07-27 stsp return 1
152 a9fa2909 2019-07-27 stsp fi
153 a9fa2909 2019-07-27 stsp
154 a9fa2909 2019-07-27 stsp mkdir -p $testroot/wt/new
155 a9fa2909 2019-07-27 stsp echo "new file" > $testroot/wt/new/foo
156 a9fa2909 2019-07-27 stsp
157 a9fa2909 2019-07-27 stsp echo 'A new/foo' > $testroot/stdout.expected
158 a9fa2909 2019-07-27 stsp (cd $testroot/wt && got add new/foo > $testroot/stdout)
159 a9fa2909 2019-07-27 stsp
160 a9fa2909 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
161 fc414659 2022-04-16 thomas ret=$?
162 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
163 a9fa2909 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
164 a9fa2909 2019-07-27 stsp fi
165 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
166 a9fa2909 2019-07-27 stsp }
167 a9fa2909 2019-07-27 stsp
168 f6cae3ed 2020-09-13 naddy test_add_deleted() {
169 6d022e97 2019-08-04 stsp local testroot=`test_init add_deleted`
170 6d022e97 2019-08-04 stsp
171 6d022e97 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
172 fc414659 2022-04-16 thomas ret=$?
173 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
174 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
175 6d022e97 2019-08-04 stsp return 1
176 6d022e97 2019-08-04 stsp fi
177 6d022e97 2019-08-04 stsp
178 6d022e97 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
179 6d022e97 2019-08-04 stsp
180 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
181 6d022e97 2019-08-04 stsp (cd $testroot/wt && got add beta > $testroot/stdout 2> $testroot/stderr)
182 fc414659 2022-04-16 thomas ret=$?
183 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
184 6d022e97 2019-08-04 stsp echo "got add command succeeded unexpectedly" >&2
185 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
186 6d022e97 2019-08-04 stsp test_done "$testroot" "1"
187 6d022e97 2019-08-04 stsp return 1
188 6d022e97 2019-08-04 stsp fi
189 6d022e97 2019-08-04 stsp
190 6d022e97 2019-08-04 stsp echo "got: beta: file has unexpected status" > $testroot/stderr.expected
191 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
192 fc414659 2022-04-16 thomas ret=$?
193 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
194 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
195 6d022e97 2019-08-04 stsp fi
196 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
197 6d022e97 2019-08-04 stsp }
198 6d022e97 2019-08-04 stsp
199 ce775af4 2023-08-29 thomas test_add_force_delete_commit() {
200 ce775af4 2023-08-29 thomas local testroot=`test_init add_force_delete_commit`
201 ce775af4 2023-08-29 thomas
202 ce775af4 2023-08-29 thomas got checkout $testroot/repo $testroot/wt > /dev/null
203 ce775af4 2023-08-29 thomas ret=$?
204 ce775af4 2023-08-29 thomas if [ $ret -ne 0 ]; then
205 ce775af4 2023-08-29 thomas test_done "$testroot" "$ret"
206 ce775af4 2023-08-29 thomas return 1
207 ce775af4 2023-08-29 thomas fi
208 ce775af4 2023-08-29 thomas
209 ce775af4 2023-08-29 thomas echo new > $testroot/wt/new
210 ce775af4 2023-08-29 thomas
211 ce775af4 2023-08-29 thomas echo -n > $testroot/stdout.expected
212 ce775af4 2023-08-29 thomas (cd $testroot/wt && got add new > $testroot/stdout 2> $testroot/stderr)
213 ce775af4 2023-08-29 thomas ret=$?
214 ce775af4 2023-08-29 thomas if [ $ret -ne 0 ]; then
215 ce775af4 2023-08-29 thomas echo "got add command failed unexpectedly" >&2
216 ce775af4 2023-08-29 thomas diff -u $testroot/stdout.expected $testroot/stdout
217 ce775af4 2023-08-29 thomas test_done "$testroot" "1"
218 ce775af4 2023-08-29 thomas return 1
219 ce775af4 2023-08-29 thomas fi
220 ce775af4 2023-08-29 thomas
221 ce775af4 2023-08-29 thomas (cd $testroot/wt && mv new new2 > $testroot/stdout 2> $testroot/stderr)
222 ce775af4 2023-08-29 thomas ret=$?
223 ce775af4 2023-08-29 thomas if [ $ret -ne 0 ]; then
224 ce775af4 2023-08-29 thomas echo "rename the file failed unexpectedly" >&2
225 ce775af4 2023-08-29 thomas ls beta2
226 ce775af4 2023-08-29 thomas test_done "$testroot" "1"
227 ce775af4 2023-08-29 thomas return 1
228 ce775af4 2023-08-29 thomas fi
229 ce775af4 2023-08-29 thomas
230 ce775af4 2023-08-29 thomas
231 ce775af4 2023-08-29 thomas (cd $testroot/wt && got add new2 > $testroot/stdout 2> $testroot/stderr)
232 ce775af4 2023-08-29 thomas ret=$?
233 ce775af4 2023-08-29 thomas if [ $ret -ne 0 ]; then
234 ce775af4 2023-08-29 thomas echo "got add command failed unexpectedly" >&2
235 ce775af4 2023-08-29 thomas test_done "$testroot" "1"
236 ce775af4 2023-08-29 thomas return 1
237 ce775af4 2023-08-29 thomas fi
238 ce775af4 2023-08-29 thomas
239 ce775af4 2023-08-29 thomas # File 'new' was once in A status (locally added) but is now
240 ce775af4 2023-08-29 thomas # in "!" (missing) status since it was never committed.
241 ce775af4 2023-08-29 thomas # Removing it effectively reverts the local addition.
242 ce775af4 2023-08-29 thomas (cd $testroot/wt && got remove -f new > $testroot/stdout \
243 ce775af4 2023-08-29 thomas 2> $testroot/stderr)
244 ce775af4 2023-08-29 thomas ret=$?
245 ce775af4 2023-08-29 thomas if [ $ret -ne 0 ]; then
246 ce775af4 2023-08-29 thomas echo "got remove -f command failed unexpectedly" >&2
247 ce775af4 2023-08-29 thomas test_done "$testroot" "1"
248 ce775af4 2023-08-29 thomas return 1
249 ce775af4 2023-08-29 thomas fi
250 ce775af4 2023-08-29 thomas
251 ce775af4 2023-08-29 thomas (cd $testroot/wt && got status > $testroot/stdout)
252 ce775af4 2023-08-29 thomas
253 ce775af4 2023-08-29 thomas echo 'A new2' > $testroot/stdout.expected
254 ce775af4 2023-08-29 thomas cmp -s $testroot/stdout.expected $testroot/stdout
255 ce775af4 2023-08-29 thomas ret=$?
256 ce775af4 2023-08-29 thomas if [ $ret -ne 0 ]; then
257 ce775af4 2023-08-29 thomas diff -u $testroot/stdout.expected $testroot/stdout
258 ce775af4 2023-08-29 thomas test_done "$testroot" "$ret"
259 ce775af4 2023-08-29 thomas return 1
260 ce775af4 2023-08-29 thomas fi
261 ce775af4 2023-08-29 thomas
262 ce775af4 2023-08-29 thomas (cd $testroot/wt && got commit -m "add force remove commit" \
263 ce775af4 2023-08-29 thomas > $testroot/stdout 2> $testroot/stderr)
264 ce775af4 2023-08-29 thomas ret=$?
265 ce775af4 2023-08-29 thomas if [ $ret -ne 0 ]; then
266 ce775af4 2023-08-29 thomas echo "got commit command failed unexpectedly" >&2
267 ce775af4 2023-08-29 thomas fi
268 ce775af4 2023-08-29 thomas test_done "$testroot" "$ret"
269 ce775af4 2023-08-29 thomas }
270 ce775af4 2023-08-29 thomas
271 f6cae3ed 2020-09-13 naddy test_add_directory() {
272 4e68cba3 2019-11-23 stsp local testroot=`test_init add_directory`
273 4e68cba3 2019-11-23 stsp
274 4e68cba3 2019-11-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
275 fc414659 2022-04-16 thomas ret=$?
276 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
277 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
278 4e68cba3 2019-11-23 stsp return 1
279 4e68cba3 2019-11-23 stsp fi
280 4e68cba3 2019-11-23 stsp
281 4e68cba3 2019-11-23 stsp (cd $testroot/wt && got add . > $testroot/stdout 2> $testroot/stderr)
282 fc414659 2022-04-16 thomas ret=$?
283 022fae89 2019-12-06 tracey echo "got: adding directories requires -R option" \
284 022fae89 2019-12-06 tracey > $testroot/stderr.expected
285 022fae89 2019-12-06 tracey cmp -s $testroot/stderr.expected $testroot/stderr
286 fc414659 2022-04-16 thomas ret=$?
287 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
288 022fae89 2019-12-06 tracey diff -u $testroot/stderr.expected $testroot/stderr
289 022fae89 2019-12-06 tracey test_done "$testroot" "$ret"
290 4e68cba3 2019-11-23 stsp return 1
291 4e68cba3 2019-11-23 stsp fi
292 022fae89 2019-12-06 tracey
293 022fae89 2019-12-06 tracey (cd $testroot/wt && got add -I . > $testroot/stdout 2> $testroot/stderr)
294 fc414659 2022-04-16 thomas ret=$?
295 ff56836b 2021-07-08 stsp echo "got: adding directories requires -R option" \
296 4e68cba3 2019-11-23 stsp > $testroot/stderr.expected
297 4e68cba3 2019-11-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
298 fc414659 2022-04-16 thomas ret=$?
299 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
300 4e68cba3 2019-11-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
301 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
302 4e68cba3 2019-11-23 stsp return 1
303 4e68cba3 2019-11-23 stsp fi
304 4e68cba3 2019-11-23 stsp
305 4e68cba3 2019-11-23 stsp echo -n > $testroot/stdout.expected
306 4e68cba3 2019-11-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
307 fc414659 2022-04-16 thomas ret=$?
308 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
309 4e68cba3 2019-11-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
310 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
311 4e68cba3 2019-11-23 stsp return 1
312 4e68cba3 2019-11-23 stsp fi
313 4e68cba3 2019-11-23 stsp
314 022fae89 2019-12-06 tracey mkdir -p $testroot/wt/tree1
315 022fae89 2019-12-06 tracey mkdir -p $testroot/wt/tree2
316 022fae89 2019-12-06 tracey echo "tree1/**" > $testroot/wt/.gitignore
317 022fae89 2019-12-06 tracey echo "tree2/**" >> $testroot/wt/.gitignore
318 022fae89 2019-12-06 tracey echo -n > $testroot/wt/tree1/foo
319 022fae89 2019-12-06 tracey echo -n > $testroot/wt/tree2/foo
320 022fae89 2019-12-06 tracey echo -n > $testroot/wt/epsilon/zeta1
321 022fae89 2019-12-06 tracey echo -n > $testroot/wt/epsilon/zeta2
322 4e68cba3 2019-11-23 stsp
323 4e68cba3 2019-11-23 stsp (cd $testroot/wt && got add -R . > $testroot/stdout)
324 4e68cba3 2019-11-23 stsp
325 022fae89 2019-12-06 tracey echo 'A .gitignore' > $testroot/stdout.expected
326 022fae89 2019-12-06 tracey echo 'A epsilon/zeta1' >> $testroot/stdout.expected
327 4e68cba3 2019-11-23 stsp echo 'A epsilon/zeta2' >> $testroot/stdout.expected
328 4e68cba3 2019-11-23 stsp
329 4e68cba3 2019-11-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
330 fc414659 2022-04-16 thomas ret=$?
331 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
332 4e68cba3 2019-11-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
333 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
334 4e68cba3 2019-11-23 stsp return 1
335 4e68cba3 2019-11-23 stsp fi
336 4e68cba3 2019-11-23 stsp
337 022fae89 2019-12-06 tracey (cd $testroot/wt && got add -RI tree1 > $testroot/stdout)
338 4e68cba3 2019-11-23 stsp
339 022fae89 2019-12-06 tracey echo 'A tree1/foo' > $testroot/stdout.expected
340 022fae89 2019-12-06 tracey
341 022fae89 2019-12-06 tracey cmp -s $testroot/stdout.expected $testroot/stdout
342 fc414659 2022-04-16 thomas ret=$?
343 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
344 022fae89 2019-12-06 tracey diff -u $testroot/stdout.expected $testroot/stdout
345 022fae89 2019-12-06 tracey test_done "$testroot" "$ret"
346 022fae89 2019-12-06 tracey return 1
347 4e68cba3 2019-11-23 stsp fi
348 022fae89 2019-12-06 tracey
349 022fae89 2019-12-06 tracey (cd $testroot/wt && got add tree2/foo > $testroot/stdout)
350 ff56836b 2021-07-08 stsp
351 ff56836b 2021-07-08 stsp echo -n '' > $testroot/stdout.expected
352 ff56836b 2021-07-08 stsp
353 ff56836b 2021-07-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
354 fc414659 2022-04-16 thomas ret=$?
355 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
356 ff56836b 2021-07-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
357 ff56836b 2021-07-08 stsp test_done "$testroot" "$ret"
358 ff56836b 2021-07-08 stsp return 1
359 ff56836b 2021-07-08 stsp fi
360 022fae89 2019-12-06 tracey
361 ff56836b 2021-07-08 stsp (cd $testroot/wt && got add -I tree2/foo > $testroot/stdout)
362 ff56836b 2021-07-08 stsp
363 022fae89 2019-12-06 tracey echo 'A tree2/foo' > $testroot/stdout.expected
364 e7303626 2020-05-14 stsp
365 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
366 fc414659 2022-04-16 thomas ret=$?
367 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
368 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
369 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
370 e7303626 2020-05-14 stsp return 1
371 e7303626 2020-05-14 stsp fi
372 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
373 e7303626 2020-05-14 stsp }
374 e7303626 2020-05-14 stsp
375 f6cae3ed 2020-09-13 naddy test_add_clashes_with_submodule() {
376 e7303626 2020-05-14 stsp local testroot=`test_init add_clashes_with_submodule`
377 e7303626 2020-05-14 stsp
378 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
379 e7303626 2020-05-14 stsp
380 d1e03b8c 2023-10-08 thomas git -C $testroot/repo -c protocol.file.allow=always \
381 d1e03b8c 2023-10-08 thomas submodule -q add ../repo2
382 d1e03b8c 2023-10-08 thomas git -C $testroot/repo commit -q -m 'adding submodule'
383 e7303626 2020-05-14 stsp
384 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
385 e7303626 2020-05-14 stsp
386 e7303626 2020-05-14 stsp # Atttempt to add a file clashes with a submodule
387 e7303626 2020-05-14 stsp echo "This is a file called repo2" > $testroot/wt/repo2
388 e7303626 2020-05-14 stsp (cd $testroot/wt && got add repo2 > /dev/null)
389 022fae89 2019-12-06 tracey
390 e7303626 2020-05-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
391 e7303626 2020-05-14 stsp echo "A repo2" > $testroot/stdout.expected
392 022fae89 2019-12-06 tracey cmp -s $testroot/stdout.expected $testroot/stdout
393 fc414659 2022-04-16 thomas ret=$?
394 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
395 022fae89 2019-12-06 tracey diff -u $testroot/stdout.expected $testroot/stdout
396 022fae89 2019-12-06 tracey test_done "$testroot" "$ret"
397 022fae89 2019-12-06 tracey return 1
398 022fae89 2019-12-06 tracey fi
399 e7303626 2020-05-14 stsp
400 e7303626 2020-05-14 stsp # Update for good measure; see the error below.
401 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > /dev/null)
402 e7303626 2020-05-14 stsp
403 e7303626 2020-05-14 stsp # This currently fails with "work tree must be updated"...
404 e7303626 2020-05-14 stsp (cd $testroot/wt && got commit -m 'add file repo2' \
405 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr)
406 fc414659 2022-04-16 thomas ret=$?
407 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
408 e7303626 2020-05-14 stsp echo "commit succeeded unexpectedly" >&2
409 e7303626 2020-05-14 stsp test_done "$testroot" "1"
410 e7303626 2020-05-14 stsp return 1
411 e7303626 2020-05-14 stsp fi
412 e7303626 2020-05-14 stsp
413 e7303626 2020-05-14 stsp echo -n "got: work tree must be updated " > $testroot/stderr.expected
414 e7303626 2020-05-14 stsp echo "before these changes can be committed" >> $testroot/stderr.expected
415 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
416 fc414659 2022-04-16 thomas ret=$?
417 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
418 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
419 00bb5ea0 2020-07-23 stsp fi
420 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
421 00bb5ea0 2020-07-23 stsp }
422 00bb5ea0 2020-07-23 stsp
423 f6cae3ed 2020-09-13 naddy test_add_symlink() {
424 00bb5ea0 2020-07-23 stsp local testroot=`test_init add_symlink`
425 00bb5ea0 2020-07-23 stsp
426 00bb5ea0 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
427 fc414659 2022-04-16 thomas ret=$?
428 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
429 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
430 00bb5ea0 2020-07-23 stsp return 1
431 00bb5ea0 2020-07-23 stsp fi
432 00bb5ea0 2020-07-23 stsp
433 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
434 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
435 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
436 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
437 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
438 00bb5ea0 2020-07-23 stsp
439 00bb5ea0 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
440 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add alpha.link > $testroot/stdout)
441 fc414659 2022-04-16 thomas ret=$?
442 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
443 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
444 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
445 00bb5ea0 2020-07-23 stsp return 1
446 00bb5ea0 2020-07-23 stsp fi
447 00bb5ea0 2020-07-23 stsp
448 00bb5ea0 2020-07-23 stsp echo "A epsilon.link" > $testroot/stdout.expected
449 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add epsilon.link > $testroot/stdout)
450 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
451 fc414659 2022-04-16 thomas ret=$?
452 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
453 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
454 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
455 00bb5ea0 2020-07-23 stsp return 1
456 e7303626 2020-05-14 stsp fi
457 00bb5ea0 2020-07-23 stsp
458 00bb5ea0 2020-07-23 stsp echo "A passwd.link" > $testroot/stdout.expected
459 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > $testroot/stdout)
460 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
461 fc414659 2022-04-16 thomas ret=$?
462 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
463 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
464 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
465 00bb5ea0 2020-07-23 stsp return 1
466 00bb5ea0 2020-07-23 stsp fi
467 00bb5ea0 2020-07-23 stsp
468 00bb5ea0 2020-07-23 stsp echo "A epsilon/beta.link" > $testroot/stdout.expected
469 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add epsilon/beta.link > $testroot/stdout)
470 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
471 fc414659 2022-04-16 thomas ret=$?
472 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
473 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
474 00bb5ea0 2020-07-23 stsp test_done "$testroot" "$ret"
475 00bb5ea0 2020-07-23 stsp return 1
476 00bb5ea0 2020-07-23 stsp fi
477 00bb5ea0 2020-07-23 stsp
478 00bb5ea0 2020-07-23 stsp echo "A nonexistent.link" > $testroot/stdout.expected
479 00bb5ea0 2020-07-23 stsp (cd $testroot/wt && got add nonexistent.link > $testroot/stdout)
480 00bb5ea0 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
481 fc414659 2022-04-16 thomas ret=$?
482 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
483 00bb5ea0 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
484 00bb5ea0 2020-07-23 stsp fi
485 4e68cba3 2019-11-23 stsp test_done "$testroot" "$ret"
486 4e68cba3 2019-11-23 stsp }
487 4e68cba3 2019-11-23 stsp
488 7fb414ae 2020-08-08 stsp test_parseargs "$@"
489 6dbf1e9e 2019-03-26 stsp run_test test_add_basic
490 5c99ca9f 2019-03-27 stsp run_test test_double_add
491 2b01eb6c 2019-05-11 stsp run_test test_add_multiple
492 a9fa2909 2019-07-27 stsp run_test test_add_file_in_new_subdir
493 6d022e97 2019-08-04 stsp run_test test_add_deleted
494 ce775af4 2023-08-29 thomas run_test test_add_force_delete_commit
495 4e68cba3 2019-11-23 stsp run_test test_add_directory
496 e7303626 2020-05-14 stsp run_test test_add_clashes_with_submodule
497 00bb5ea0 2020-07-23 stsp run_test test_add_symlink