3 c4296144 2019-05-09 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 c4296144 2019-05-09 stsp # Permission to use, copy, modify, and distribute this software for any
6 c4296144 2019-05-09 stsp # purpose with or without fee is hereby granted, provided that the above
7 c4296144 2019-05-09 stsp # copyright notice and this permission notice appear in all copies.
9 c4296144 2019-05-09 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c4296144 2019-05-09 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c4296144 2019-05-09 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c4296144 2019-05-09 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c4296144 2019-05-09 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c4296144 2019-05-09 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c4296144 2019-05-09 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 c4296144 2019-05-09 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_commit_basic() {
20 c4296144 2019-05-09 stsp local testroot=`test_init commit_basic`
22 c4296144 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
29 c4296144 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
30 c4296144 2019-05-09 stsp (cd $testroot/wt && got rm beta >/dev/null)
31 c4296144 2019-05-09 stsp echo "new file" > $testroot/wt/new
32 c4296144 2019-05-09 stsp (cd $testroot/wt && got add new >/dev/null)
34 83a7ae6d 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_basic' > $testroot/stdout)
36 c4296144 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
37 afa376bf 2019-05-09 stsp echo "A new" > $testroot/stdout.expected
38 afa376bf 2019-05-09 stsp echo "M alpha" >> $testroot/stdout.expected
39 afa376bf 2019-05-09 stsp echo "D beta" >> $testroot/stdout.expected
40 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
42 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
44 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
45 c4296144 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
47 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
50 f6cae3ed 2020-09-13 naddy test_commit_new_subdir() {
51 baa7dcfa 2019-05-09 stsp local testroot=`test_init commit_new_subdir`
53 baa7dcfa 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
55 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
56 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
60 baa7dcfa 2019-05-09 stsp mkdir -p $testroot/wt/d
61 baa7dcfa 2019-05-09 stsp echo "new file" > $testroot/wt/d/new
62 baa7dcfa 2019-05-09 stsp echo "another new file" > $testroot/wt/d/new2
63 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new >/dev/null)
64 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new2 >/dev/null)
66 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && \
67 baa7dcfa 2019-05-09 stsp got commit -m 'test commit_new_subdir' > $testroot/stdout)
69 baa7dcfa 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
70 baa7dcfa 2019-05-09 stsp echo "A d/new" > $testroot/stdout.expected
71 baa7dcfa 2019-05-09 stsp echo "A d/new2" >> $testroot/stdout.expected
72 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
74 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
76 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
77 baa7dcfa 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
79 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
82 f6cae3ed 2020-09-13 naddy test_commit_subdir() {
83 bc70eb79 2019-05-09 stsp local testroot=`test_init commit_subdir`
85 bc70eb79 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
87 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
88 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
92 bc70eb79 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
93 bc70eb79 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
95 bc70eb79 2019-05-09 stsp (cd $testroot/wt && \
96 bc70eb79 2019-05-09 stsp got commit -m 'test commit_subdir' epsilon > $testroot/stdout)
98 bc70eb79 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
99 bc70eb79 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
100 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
102 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
104 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
105 bc70eb79 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
107 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
110 f6cae3ed 2020-09-13 naddy test_commit_single_file() {
111 5bbcb68b 2019-05-09 stsp local testroot=`test_init commit_single_file`
113 5bbcb68b 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
115 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
116 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
120 5bbcb68b 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
121 5bbcb68b 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
123 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon/zeta \
124 5bbcb68b 2019-05-09 stsp > $testroot/stdout)
126 5bbcb68b 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
127 5bbcb68b 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
128 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
132 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
133 5bbcb68b 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
135 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
138 f6cae3ed 2020-09-13 naddy test_commit_out_of_date() {
139 819f385b 2019-05-10 stsp local testroot=`test_init commit_out_of_date`
140 f0b75401 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
142 819f385b 2019-05-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
144 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
145 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
149 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/repo/alpha
150 819f385b 2019-05-10 stsp git_commit $testroot/repo -m "modified alpha"
152 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/wt/alpha
154 819f385b 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_out_of_date' \
155 819f385b 2019-05-10 stsp > $testroot/stdout 2> $testroot/stderr)
157 819f385b 2019-05-10 stsp echo -n > $testroot/stdout.expected
158 819f385b 2019-05-10 stsp echo "got: work tree must be updated before these" \
159 819f385b 2019-05-10 stsp "changes can be committed" > $testroot/stderr.expected
161 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
163 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
164 819f385b 2019-05-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
165 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
169 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
172 819f385b 2019-05-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
173 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
177 f0b75401 2019-08-03 stsp echo "alpha" > $testroot/repo/alpha
178 f0b75401 2019-08-03 stsp git_commit $testroot/repo -m "reset alpha contents"
179 f0b75401 2019-08-03 stsp (cd $testroot/wt && got update -c $first_commit > /dev/null)
181 f0b75401 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
183 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m 'changed alpha ' > $testroot/stdout)
185 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
186 f0b75401 2019-08-03 stsp echo "commit failed unexpectedly" >&2
187 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
191 f0b75401 2019-08-03 stsp local head_rev=`git_show_head $testroot/repo`
192 f0b75401 2019-08-03 stsp echo "M alpha" > $testroot/stdout.expected
193 f0b75401 2019-08-03 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
194 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
196 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
197 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
199 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
202 f6cae3ed 2020-09-13 naddy test_commit_added_subdirs() {
203 8ba6ba2d 2019-05-14 stsp local testroot=`test_init commit_added_subdirs`
205 8ba6ba2d 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
207 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
208 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
212 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d
213 8ba6ba2d 2019-05-14 stsp echo "new file" > $testroot/wt/d/new
214 8ba6ba2d 2019-05-14 stsp echo "new file 2" > $testroot/wt/d/new2
215 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f
216 8ba6ba2d 2019-05-14 stsp echo "new file 3" > $testroot/wt/d/f/new3
217 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f/g
218 8ba6ba2d 2019-05-14 stsp echo "new file 4" > $testroot/wt/d/f/g/new4
220 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got add $testroot/wt/*/new* \
221 8ba6ba2d 2019-05-14 stsp $testroot/wt/*/*/new* $testroot/wt/*/*/*/new* > /dev/null)
223 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got commit -m 'test commit_added_subdirs' \
224 8ba6ba2d 2019-05-14 stsp > $testroot/stdout 2> $testroot/stderr)
226 8ba6ba2d 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
227 a3df2849 2019-05-20 stsp echo "A d/f/g/new4" > $testroot/stdout.expected
228 a3df2849 2019-05-20 stsp echo "A d/f/new3" >> $testroot/stdout.expected
229 8ba6ba2d 2019-05-14 stsp echo "A d/new" >> $testroot/stdout.expected
230 8ba6ba2d 2019-05-14 stsp echo "A d/new2" >> $testroot/stdout.expected
231 ba580f68 2020-03-22 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
233 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
235 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
236 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
238 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
241 f6cae3ed 2020-09-13 naddy test_commit_deleted_subdirs() {
242 ba580f68 2020-03-22 stsp local testroot=`test_init commit_deleted_subdirs`
244 ba580f68 2020-03-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
246 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
247 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
251 c8c7d149 2020-09-17 naddy (cd $testroot/wt && \
252 c8c7d149 2020-09-17 naddy got rm -R $testroot/wt/epsilon $testroot/wt/gamma >/dev/null)
254 ba580f68 2020-03-22 stsp (cd $testroot/wt && got commit -m 'test commit_deleted_subdirs' \
255 ba580f68 2020-03-22 stsp > $testroot/stdout 2> $testroot/stderr)
257 ba580f68 2020-03-22 stsp local head_rev=`git_show_head $testroot/repo`
258 ba580f68 2020-03-22 stsp echo "D epsilon/zeta" > $testroot/stdout.expected
259 ba580f68 2020-03-22 stsp echo "D gamma/delta" >> $testroot/stdout.expected
260 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
262 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
264 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
265 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
270 ba580f68 2020-03-22 stsp got tree -r $testroot/repo > $testroot/stdout
272 ba580f68 2020-03-22 stsp echo "alpha" > $testroot/stdout.expected
273 ba580f68 2020-03-22 stsp echo "beta" >> $testroot/stdout.expected
275 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
277 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
278 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
280 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
283 f6cae3ed 2020-09-13 naddy test_commit_rejects_conflicted_file() {
284 461aee03 2019-06-29 stsp local testroot=`test_init commit_rejects_conflicted_file`
286 f363d663 2019-05-23 stsp local initial_rev=`git_show_head $testroot/repo`
288 f363d663 2019-05-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
290 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
291 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
295 f363d663 2019-05-23 stsp echo "modified alpha" > $testroot/wt/alpha
296 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
298 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
300 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
302 f363d663 2019-05-23 stsp echo "C alpha" > $testroot/stdout.expected
303 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
304 f363d663 2019-05-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
305 f363d663 2019-05-23 stsp echo >> $testroot/stdout.expected
306 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
308 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
310 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
312 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
313 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
314 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
318 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
319 f363d663 2019-05-23 stsp 2> $testroot/stderr)
321 f363d663 2019-05-23 stsp echo -n > $testroot/stdout.expected
322 f363d663 2019-05-23 stsp echo "got: cannot commit file in conflicted status" \
323 f363d663 2019-05-23 stsp > $testroot/stderr.expected
325 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
327 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
328 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
329 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
332 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
334 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
335 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
337 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
340 f6cae3ed 2020-09-13 naddy test_commit_single_file_multiple() {
341 1a36436d 2019-06-10 stsp local testroot=`test_init commit_single_file_multiple`
343 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
345 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
346 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
350 1a36436d 2019-06-10 stsp for i in 1 2 3 4; do
351 1a36436d 2019-06-10 stsp echo "modified alpha" >> $testroot/wt/alpha
353 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
354 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
356 1a36436d 2019-06-10 stsp local head_rev=`git_show_head $testroot/repo`
357 1a36436d 2019-06-10 stsp echo "M alpha" > $testroot/stdout.expected
358 1a36436d 2019-06-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
360 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
362 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
363 1a36436d 2019-06-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
364 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
369 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
372 f6cae3ed 2020-09-13 naddy test_commit_added_and_modified_in_same_dir() {
373 4866d084 2019-07-10 stsp local testroot=`test_init commit_added_and_modified_in_same_dir`
375 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
377 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
378 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
382 4866d084 2019-07-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
383 4866d084 2019-07-10 stsp echo "new file" > $testroot/wt/epsilon/new
384 4866d084 2019-07-10 stsp (cd $testroot/wt && got add epsilon/new >/dev/null)
386 4866d084 2019-07-10 stsp (cd $testroot/wt && got commit \
387 4866d084 2019-07-10 stsp -m 'added and modified in same dir' > $testroot/stdout \
388 4866d084 2019-07-10 stsp 2> $testroot/stderr)
390 4866d084 2019-07-10 stsp local head_rev=`git_show_head $testroot/repo`
391 4866d084 2019-07-10 stsp echo "A epsilon/new" > $testroot/stdout.expected
392 4866d084 2019-07-10 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
393 4866d084 2019-07-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
395 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
397 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
398 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
400 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
403 f6cae3ed 2020-09-13 naddy test_commit_path_prefix() {
404 e0233cea 2019-07-25 stsp local testroot=`test_init commit_path_prefix`
405 e0233cea 2019-07-25 stsp local commit1=`git_show_head $testroot/repo`
407 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
409 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
410 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
414 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
416 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
418 e0233cea 2019-07-25 stsp local commit2=`git_show_head $testroot/repo`
419 e0233cea 2019-07-25 stsp echo "M delta" > $testroot/stdout.expected
420 e0233cea 2019-07-25 stsp echo "Created commit $commit2" >> $testroot/stdout.expected
422 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
424 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
425 2b496619 2019-07-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
426 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
430 e0233cea 2019-07-25 stsp echo "diff $commit1 $commit2" > $testroot/stdout.expected
431 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
432 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
433 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $testroot/stdout.expected
434 e0233cea 2019-07-25 stsp echo -n 'blob + ' >> $testroot/stdout.expected
435 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
436 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
437 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
438 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
439 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
440 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
441 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
443 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
444 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
446 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
447 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
452 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got rm delta > /dev/null)
453 f2b0a8b0 2020-07-31 stsp echo new > $testroot/wt/new
454 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got add new > /dev/null)
456 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
457 f2b0a8b0 2020-07-31 stsp > $testroot/stdout)
459 f2b0a8b0 2020-07-31 stsp local commit3=`git_show_head $testroot/repo`
460 f2b0a8b0 2020-07-31 stsp echo "A new" > $testroot/stdout.expected
461 f2b0a8b0 2020-07-31 stsp echo "D delta" >> $testroot/stdout.expected
462 f2b0a8b0 2020-07-31 stsp echo "Created commit $commit3" >> $testroot/stdout.expected
464 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
466 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
467 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
468 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
472 f2b0a8b0 2020-07-31 stsp echo "diff $commit2 $commit3" > $testroot/stdout.expected
473 f2b0a8b0 2020-07-31 stsp echo -n 'blob - ' >> $testroot/stdout.expected
474 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
475 f2b0a8b0 2020-07-31 stsp | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
476 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
477 f2b0a8b0 2020-07-31 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
478 f2b0a8b0 2020-07-31 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
479 f2b0a8b0 2020-07-31 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
480 f2b0a8b0 2020-07-31 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
481 f2b0a8b0 2020-07-31 stsp echo '-modified delta' >> $testroot/stdout.expected
482 f2b0a8b0 2020-07-31 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
483 f2b0a8b0 2020-07-31 stsp echo -n 'blob + ' >> $testroot/stdout.expected
484 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
485 f2b0a8b0 2020-07-31 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
486 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
487 f2b0a8b0 2020-07-31 stsp echo '--- /dev/null' >> $testroot/stdout.expected
488 f2b0a8b0 2020-07-31 stsp echo '+++ gamma/new' >> $testroot/stdout.expected
489 f2b0a8b0 2020-07-31 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
490 f2b0a8b0 2020-07-31 stsp echo '+new' >> $testroot/stdout.expected
492 f2b0a8b0 2020-07-31 stsp got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
493 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
495 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
496 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
498 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
499 f2b0a8b0 2020-07-31 stsp return "$ret"
502 f6cae3ed 2020-09-13 naddy test_commit_dir_path() {
503 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
505 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
507 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
508 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
512 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
513 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
515 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
516 90e8619e 2019-07-25 stsp > $testroot/stdout)
518 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
519 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
520 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
522 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
524 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
525 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
526 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
530 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
531 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
532 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
534 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
535 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
537 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
540 f6cae3ed 2020-09-13 naddy test_commit_selected_paths() {
541 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
543 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
545 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
546 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
550 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
551 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
552 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
553 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
554 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
555 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
557 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
558 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
560 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
561 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
562 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
565 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
567 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
569 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
570 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
571 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
575 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
576 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
578 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
579 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
580 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
581 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
582 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
584 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
586 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
587 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
589 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
592 f6cae3ed 2020-09-13 naddy test_commit_outside_refs_heads() {
593 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
595 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
597 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
598 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
600 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
601 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
605 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
607 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
608 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
610 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
611 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
612 916f288c 2019-07-30 stsp test_done "$testroot" "1"
616 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
617 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
619 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
620 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
621 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
625 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
626 916f288c 2019-07-30 stsp > $testroot/stderr.expected
627 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
628 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
629 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
631 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
632 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
634 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
637 f6cae3ed 2020-09-13 naddy test_commit_no_email() {
638 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
640 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
642 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
643 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
647 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
648 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
649 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
650 84792843 2019-08-09 stsp 2> $testroot/stderr)
652 1d918cf9 2022-02-06 op echo -n "got: :flan_hacker:: commit author's email address " \
653 84792843 2019-08-09 stsp > $testroot/stderr.expected
654 1d918cf9 2022-02-06 op echo "is required for compatibility with Git" \
655 84792843 2019-08-09 stsp >> $testroot/stderr.expected
656 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
658 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
659 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
660 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
664 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
665 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
667 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
668 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
670 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
673 f6cae3ed 2020-09-13 naddy test_commit_tree_entry_sorting() {
674 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
676 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
678 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
679 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
683 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
684 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
685 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
686 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
687 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
688 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
689 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
690 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
691 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
693 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
695 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
696 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
697 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
699 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
702 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_author() {
703 257add31 2020-09-09 stsp local testroot=`test_init commit_gotconfig_author`
705 257add31 2020-09-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
707 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
708 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
711 257add31 2020-09-09 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
712 257add31 2020-09-09 stsp > $testroot/repo/.git/got.conf
714 257add31 2020-09-09 stsp echo "modified alpha" > $testroot/wt/alpha
715 257add31 2020-09-09 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
717 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
718 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
722 257add31 2020-09-09 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
724 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
725 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
729 257add31 2020-09-09 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
730 50b0790e 2020-09-11 stsp > $testroot/stdout.expected
731 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
733 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
734 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
736 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
739 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_worktree_author() {
740 50b0790e 2020-09-11 stsp local testroot=`test_init commit_gotconfig_worktree_author`
742 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
744 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
745 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
748 50b0790e 2020-09-11 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
749 50b0790e 2020-09-11 stsp > $testroot/repo/.git/got.conf
750 50b0790e 2020-09-11 stsp echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
751 50b0790e 2020-09-11 stsp > $testroot/wt/.got/got.conf
753 50b0790e 2020-09-11 stsp echo "modified alpha" > $testroot/wt/alpha
754 50b0790e 2020-09-11 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
756 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
757 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
761 50b0790e 2020-09-11 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
763 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
764 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
768 50b0790e 2020-09-11 stsp echo "from: Flan Squee <flan_squee@openbsd.org>" \
769 257add31 2020-09-09 stsp > $testroot/stdout.expected
770 257add31 2020-09-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
772 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
773 257add31 2020-09-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
775 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
778 f6cae3ed 2020-09-13 naddy test_commit_gitconfig_author() {
779 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
781 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
783 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
784 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
788 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
789 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
791 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
792 aba9c984 2019-09-08 stsp (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
794 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
795 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
799 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
801 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
802 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
806 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
807 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
808 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
810 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
811 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
813 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
816 f6cae3ed 2020-09-13 naddy test_commit_xbit_change() {
817 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
819 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
821 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
822 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
826 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
828 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
829 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
831 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
833 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
834 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
835 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
839 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
841 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
842 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
843 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
847 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
848 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
849 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
850 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
852 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
853 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
854 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
858 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
860 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
861 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
863 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
864 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
865 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
869 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
871 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
872 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
874 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
876 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
877 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
878 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
882 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
884 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
885 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
886 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
890 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
891 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
892 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
893 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
895 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
896 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
897 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
901 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
903 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
904 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
906 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
908 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
909 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
911 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
914 f6cae3ed 2020-09-13 naddy commit_check_mode() {
915 f7b97ccb 2020-04-14 stsp local mode="$1"
916 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
918 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
919 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
920 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
922 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
924 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
925 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
926 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
930 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
931 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
932 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
933 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
935 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
936 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
937 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
941 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
942 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
943 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
944 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
945 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
946 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
947 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
949 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
950 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
952 f7b97ccb 2020-04-14 stsp return $ret
955 f6cae3ed 2020-09-13 naddy test_commit_normalizes_filemodes() {
956 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
958 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
960 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
961 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
965 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
966 f7b97ccb 2020-04-14 stsp for m in $modes; do
967 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
969 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
973 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
974 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
977 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
978 f7b97ccb 2020-04-14 stsp for m in $modes; do
979 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
981 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
985 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
986 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
989 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
992 f6cae3ed 2020-09-13 naddy test_commit_with_unrelated_submodule() {
993 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
995 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
997 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
998 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1000 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1002 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1003 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
1004 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1008 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
1010 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
1012 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1014 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1015 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
1016 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
1020 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
1021 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
1022 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1024 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1026 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1027 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1029 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1032 f6cae3ed 2020-09-13 naddy check_symlinks() {
1033 bd6aa359 2020-07-23 stsp local wtpath="$1"
1034 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
1035 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
1039 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
1040 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1041 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1043 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1044 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1048 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
1049 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
1053 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
1054 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1055 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1057 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1058 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1062 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
1063 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1064 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
1068 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1069 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
1071 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1072 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
1076 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1078 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1079 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1083 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
1084 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1085 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1087 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1088 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1092 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
1093 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1094 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1096 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1097 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1104 f6cae3ed 2020-09-13 naddy test_commit_symlink() {
1105 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
1107 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1109 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1110 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1114 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
1115 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
1116 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1117 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1118 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1119 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1120 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
1122 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1123 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1125 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1126 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1127 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1130 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1131 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1132 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1133 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1135 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1136 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1137 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1141 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1142 35213c7c 2020-07-23 stsp > $testroot/stdout)
1144 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1145 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1146 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1147 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1148 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1149 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1150 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1152 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1154 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1155 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1156 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1160 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1161 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1163 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1164 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1167 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1170 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1174 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1175 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1176 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1180 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1181 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1182 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1184 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1185 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1189 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1190 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
1191 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1192 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1193 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1194 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1195 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1196 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1197 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1198 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1200 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1201 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1203 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1204 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1205 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1208 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1209 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1210 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1211 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1213 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1214 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1215 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1219 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1220 35213c7c 2020-07-23 stsp > $testroot/stdout)
1222 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1223 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1224 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1225 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1226 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1227 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1228 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1229 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1231 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1233 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1234 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1235 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1239 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1240 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1242 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1244 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1246 88fb31d4 2020-07-23 stsp epsilon/beta.link
1247 88fb31d4 2020-07-23 stsp epsilon/zeta
1248 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1250 88fb31d4 2020-07-23 stsp gamma/delta
1251 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1252 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1254 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1256 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1257 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1259 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1262 f6cae3ed 2020-09-13 naddy test_commit_fix_bad_symlink() {
1263 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1265 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1267 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1268 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1269 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1273 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1274 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1276 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1277 35213c7c 2020-07-23 stsp > $testroot/stdout)
1279 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1280 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1281 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1284 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1285 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1286 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1287 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1291 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1292 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1294 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1295 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1296 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1300 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1301 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -sfh alpha passwd.link)
1303 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1304 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1306 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1307 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1308 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1310 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1312 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1313 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1314 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1318 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1319 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1320 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1324 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1325 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1326 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1328 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1329 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1333 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1334 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1336 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1337 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1338 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1342 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1343 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1344 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1348 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1349 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1350 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1352 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1353 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1357 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1360 28cf319f 2021-01-28 stsp test_commit_prepared_logmsg() {
1361 28cf319f 2021-01-28 stsp local testroot=`test_init commit_prepared_logmsg`
1363 28cf319f 2021-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1365 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1366 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1370 28cf319f 2021-01-28 stsp echo "modified alpha" > $testroot/wt/alpha
1371 28cf319f 2021-01-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
1372 28cf319f 2021-01-28 stsp echo "new file" > $testroot/wt/new
1373 28cf319f 2021-01-28 stsp (cd $testroot/wt && got add new >/dev/null)
1375 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg' > $testroot/logmsg
1377 28cf319f 2021-01-28 stsp cat > $testroot/editor.sh <<EOF
1379 28cf319f 2021-01-28 stsp sed -i 's/foo/bar/' "\$1"
1381 28cf319f 2021-01-28 stsp chmod +x $testroot/editor.sh
1383 8e09a168 2021-06-17 tracey (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1384 28cf319f 2021-01-28 stsp got commit -F "$testroot/logmsg" > $testroot/stdout)
1386 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1387 28cf319f 2021-01-28 stsp echo "A new" > $testroot/stdout.expected
1388 28cf319f 2021-01-28 stsp echo "M alpha" >> $testroot/stdout.expected
1389 28cf319f 2021-01-28 stsp echo "D beta" >> $testroot/stdout.expected
1390 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1392 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1394 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1395 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1396 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1400 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1401 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1402 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" > $testroot/stdout.expected
1403 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1404 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1405 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1406 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1407 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1408 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1410 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1411 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1413 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1414 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1415 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1419 28cf319f 2021-01-28 stsp echo "modified alpha again" > $testroot/wt/alpha
1421 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg non-interactive' \
1422 28cf319f 2021-01-28 stsp > $testroot/logmsg
1424 28cf319f 2021-01-28 stsp (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1425 28cf319f 2021-01-28 stsp > $testroot/stdout)
1427 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1428 28cf319f 2021-01-28 stsp echo "M alpha" > $testroot/stdout.expected
1429 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1431 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1433 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1434 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1435 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1439 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1440 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1441 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" \
1442 28cf319f 2021-01-28 stsp > $testroot/stdout.expected
1443 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1444 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1445 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1446 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1447 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg non-interactive" \
1448 28cf319f 2021-01-28 stsp >> $testroot/stdout.expected
1449 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1451 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1452 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1454 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1455 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1457 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1460 72840534 2022-01-19 stsp test_commit_large_file() {
1461 72840534 2022-01-19 stsp local testroot=`test_init commit_large_file`
1463 72840534 2022-01-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1465 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1466 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1470 72840534 2022-01-19 stsp dd status=none if=/dev/zero of=$testroot/wt/new bs=1m count=64
1471 72840534 2022-01-19 stsp (cd $testroot/wt && got add new >/dev/null)
1473 72840534 2022-01-19 stsp (cd $testroot/wt && got commit -m 'test commit_large_file' \
1474 72840534 2022-01-19 stsp > $testroot/stdout)
1476 72840534 2022-01-19 stsp local head_rev=`git_show_head $testroot/repo`
1477 72840534 2022-01-19 stsp echo "A new" > $testroot/stdout.expected
1478 72840534 2022-01-19 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1480 72840534 2022-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1482 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1483 72840534 2022-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1484 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1488 72840534 2022-01-19 stsp new_id=`get_blob_id $testroot/repo "" new`
1489 72840534 2022-01-19 stsp got cat -r $testroot/repo $new_id > $testroot/new
1491 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1492 72840534 2022-01-19 stsp echo "commit failed unexpectedly" >&2
1493 72840534 2022-01-19 stsp test_done "$testroot" "1"
1497 72840534 2022-01-19 stsp cmp -s $testroot/new $testroot/wt/new
1499 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1500 72840534 2022-01-19 stsp diff -u $testroot/new $testroot/wt/new
1502 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1508 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1509 c4296144 2019-05-09 stsp run_test test_commit_basic
1510 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
1511 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
1512 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
1513 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
1514 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
1515 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
1516 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
1517 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
1518 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
1519 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
1520 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
1521 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
1522 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
1523 84792843 2019-08-09 stsp run_test test_commit_no_email
1524 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
1525 257add31 2020-09-09 stsp run_test test_commit_gotconfig_author
1526 50b0790e 2020-09-11 stsp run_test test_commit_gotconfig_worktree_author
1527 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
1528 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
1529 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
1530 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
1531 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
1532 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink
1533 28cf319f 2021-01-28 stsp run_test test_commit_prepared_logmsg
1534 72840534 2022-01-19 stsp run_test test_commit_large_file