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 8469d821 2022-06-25 stsp echo "commit - $commit1" >> $testroot/stdout.expected
432 8469d821 2022-06-25 stsp echo "commit + $commit2" >> $testroot/stdout.expected
433 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
434 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
435 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $testroot/stdout.expected
436 e0233cea 2019-07-25 stsp echo -n 'blob + ' >> $testroot/stdout.expected
437 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
438 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
439 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
440 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
441 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
442 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
443 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
445 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
446 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
448 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
449 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
450 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
454 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got rm delta > /dev/null)
455 f2b0a8b0 2020-07-31 stsp echo new > $testroot/wt/new
456 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got add new > /dev/null)
458 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
459 f2b0a8b0 2020-07-31 stsp > $testroot/stdout)
461 f2b0a8b0 2020-07-31 stsp local commit3=`git_show_head $testroot/repo`
462 f2b0a8b0 2020-07-31 stsp echo "A new" > $testroot/stdout.expected
463 f2b0a8b0 2020-07-31 stsp echo "D delta" >> $testroot/stdout.expected
464 f2b0a8b0 2020-07-31 stsp echo "Created commit $commit3" >> $testroot/stdout.expected
466 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
468 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
469 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
470 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
474 f2b0a8b0 2020-07-31 stsp echo "diff $commit2 $commit3" > $testroot/stdout.expected
475 8469d821 2022-06-25 stsp echo "commit - $commit2" >> $testroot/stdout.expected
476 8469d821 2022-06-25 stsp echo "commit + $commit3" >> $testroot/stdout.expected
477 f2b0a8b0 2020-07-31 stsp echo -n 'blob - ' >> $testroot/stdout.expected
478 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
479 f2b0a8b0 2020-07-31 stsp | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
480 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
481 f2b0a8b0 2020-07-31 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
482 f2b0a8b0 2020-07-31 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
483 f2b0a8b0 2020-07-31 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
484 f2b0a8b0 2020-07-31 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
485 f2b0a8b0 2020-07-31 stsp echo '-modified delta' >> $testroot/stdout.expected
486 f2b0a8b0 2020-07-31 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
487 f2b0a8b0 2020-07-31 stsp echo -n 'blob + ' >> $testroot/stdout.expected
488 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
489 f2b0a8b0 2020-07-31 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
490 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
491 f2b0a8b0 2020-07-31 stsp echo '--- /dev/null' >> $testroot/stdout.expected
492 f2b0a8b0 2020-07-31 stsp echo '+++ gamma/new' >> $testroot/stdout.expected
493 f2b0a8b0 2020-07-31 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
494 f2b0a8b0 2020-07-31 stsp echo '+new' >> $testroot/stdout.expected
496 f2b0a8b0 2020-07-31 stsp got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
497 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
499 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
500 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
502 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
503 f2b0a8b0 2020-07-31 stsp return "$ret"
506 f6cae3ed 2020-09-13 naddy test_commit_dir_path() {
507 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
509 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
511 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
512 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
516 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
517 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
519 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
520 90e8619e 2019-07-25 stsp > $testroot/stdout)
522 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
523 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
524 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
526 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
528 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
529 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
530 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
534 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
535 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
536 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
538 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
539 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
541 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
544 f6cae3ed 2020-09-13 naddy test_commit_selected_paths() {
545 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
547 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
549 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
550 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
554 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
555 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
556 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
557 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
558 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
559 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
561 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
562 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
564 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
565 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
566 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
569 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
571 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
573 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
574 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
575 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
579 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
580 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
582 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
583 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
584 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
585 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
586 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
588 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
590 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
591 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
593 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
596 f6cae3ed 2020-09-13 naddy test_commit_outside_refs_heads() {
597 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
599 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
601 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
602 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
604 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
605 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
609 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
611 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
612 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
614 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
615 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
616 916f288c 2019-07-30 stsp test_done "$testroot" "1"
620 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
621 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
623 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
624 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
625 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
629 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
630 916f288c 2019-07-30 stsp > $testroot/stderr.expected
631 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
632 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
633 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
635 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
636 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
638 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
641 f6cae3ed 2020-09-13 naddy test_commit_no_email() {
642 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
643 cf208ddd 2022-07-19 op local errmsg=""
645 cf208ddd 2022-07-19 op errmsg="commit author's email address is required for"
646 cf208ddd 2022-07-19 op errmsg="$errmsg compatibility with Git"
648 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
650 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
651 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
655 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
656 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
657 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
658 84792843 2019-08-09 stsp 2> $testroot/stderr)
660 cf208ddd 2022-07-19 op printf "got: :flan_hacker:: %s\n" "$errmsg" > $testroot/stderr.expected
661 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
663 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
664 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
665 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
669 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
670 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
672 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
673 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
674 cf208ddd 2022-07-19 op test_done "$testroot" $ret
678 cf208ddd 2022-07-19 op # try again with a newline inside the email
679 cf208ddd 2022-07-19 op (cd $testroot/wt \
680 cf208ddd 2022-07-19 op && FS=' ' env GOT_AUTHOR="$(printf "Flan <hack\ner>")" \
681 cf208ddd 2022-07-19 op got commit -m 'test invalid email' > $testroot/stdout \
682 cf208ddd 2022-07-19 op 2> $testroot/stderr)
684 cf208ddd 2022-07-19 op printf "got: Flan <hack\ner>: %s\n" "$errmsg" \
685 cf208ddd 2022-07-19 op > $testroot/stderr.expected
686 cf208ddd 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
688 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
689 cf208ddd 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
690 cf208ddd 2022-07-19 op test_done "$testroot" $ret
694 cf208ddd 2022-07-19 op echo -n > $testroot/stdout.expected
695 cf208ddd 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
697 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
698 cf208ddd 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
699 cf208ddd 2022-07-19 op test_done "$testroot" $ret
703 cf208ddd 2022-07-19 op # try again with a < inside the email
704 cf208ddd 2022-07-19 op (cd $testroot/wt && env GOT_AUTHOR="$(printf "Flan <ha<ker>")" \
705 cf208ddd 2022-07-19 op got commit -m 'test invalid email' > $testroot/stdout \
706 cf208ddd 2022-07-19 op 2> $testroot/stderr)
708 cf208ddd 2022-07-19 op printf "got: Flan <ha<ker>: %s\n" "$errmsg" > $testroot/stderr.expected
709 cf208ddd 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
711 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
712 cf208ddd 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
713 cf208ddd 2022-07-19 op test_done "$testroot" $ret
717 cf208ddd 2022-07-19 op echo -n > $testroot/stdout.expected
718 cf208ddd 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
720 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
721 cf208ddd 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
723 cf208ddd 2022-07-19 op test_done "$testroot" $ret
726 f6cae3ed 2020-09-13 naddy test_commit_tree_entry_sorting() {
727 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
729 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
731 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
732 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
736 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
737 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
738 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
739 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
740 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
741 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
742 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
743 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
744 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
746 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
748 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
749 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
750 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
752 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
755 62b21d33 2022-07-19 op test_commit_cmdline_author() {
756 62b21d33 2022-07-19 op local testroot=`test_init commit_cmdline_author`
758 62b21d33 2022-07-19 op got checkout $testroot/repo $testroot/wt > /dev/null
760 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
761 62b21d33 2022-07-19 op test_done "$testroot" $ret
765 62b21d33 2022-07-19 op echo "modified alpha" > $testroot/wt/alpha
767 62b21d33 2022-07-19 op # first try with a -A equals to $GOT_AUTHOR
768 62b21d33 2022-07-19 op (cd $testroot/wt && got commit -A "$GOT_AUTHOR" -m 'edit alpha') \
769 62b21d33 2022-07-19 op > /dev/null 2> $testroot/stderr
771 62b21d33 2022-07-19 op if [ $ret -eq 0 ]; then
772 62b21d33 2022-07-19 op test_done "$testroot" 1
776 62b21d33 2022-07-19 op echo 'got: specified author is equal to the default one' \
777 62b21d33 2022-07-19 op > $testroot/stderr.expected
778 62b21d33 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
780 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
781 62b21d33 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
782 62b21d33 2022-07-19 op test_done "$testroot" $ret
786 62b21d33 2022-07-19 op # try again with a different author
787 62b21d33 2022-07-19 op local author="Foo <foo@example.com>"
788 62b21d33 2022-07-19 op (cd $testroot/wt && got commit -A "$author" -m 'edit alpha') \
791 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
792 62b21d33 2022-07-19 op test_done "$testroot" $ret
796 62b21d33 2022-07-19 op (cd $testroot/repo && got log -l1 | egrep '^(from|via):') \
797 62b21d33 2022-07-19 op > $testroot/stdout
799 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
800 62b21d33 2022-07-19 op test_done "$testroot" $ret
804 62b21d33 2022-07-19 op echo "from: $author" > $testroot/stdout.expected
805 62b21d33 2022-07-19 op echo "via: $GOT_AUTHOR" >> $testroot/stdout.expected
806 62b21d33 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
808 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
809 62b21d33 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
811 62b21d33 2022-07-19 op test_done "$testroot" $ret
814 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_author() {
815 257add31 2020-09-09 stsp local testroot=`test_init commit_gotconfig_author`
817 257add31 2020-09-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
819 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
820 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
823 257add31 2020-09-09 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
824 257add31 2020-09-09 stsp > $testroot/repo/.git/got.conf
826 257add31 2020-09-09 stsp echo "modified alpha" > $testroot/wt/alpha
827 257add31 2020-09-09 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
829 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
830 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
834 257add31 2020-09-09 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
836 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
837 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
841 257add31 2020-09-09 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
842 50b0790e 2020-09-11 stsp > $testroot/stdout.expected
843 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
845 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
846 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
848 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
851 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_worktree_author() {
852 50b0790e 2020-09-11 stsp local testroot=`test_init commit_gotconfig_worktree_author`
854 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
856 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
857 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
860 50b0790e 2020-09-11 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
861 50b0790e 2020-09-11 stsp > $testroot/repo/.git/got.conf
862 50b0790e 2020-09-11 stsp echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
863 50b0790e 2020-09-11 stsp > $testroot/wt/.got/got.conf
865 50b0790e 2020-09-11 stsp echo "modified alpha" > $testroot/wt/alpha
866 50b0790e 2020-09-11 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
868 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
869 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
873 50b0790e 2020-09-11 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
875 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
876 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
880 50b0790e 2020-09-11 stsp echo "from: Flan Squee <flan_squee@openbsd.org>" \
881 257add31 2020-09-09 stsp > $testroot/stdout.expected
882 257add31 2020-09-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
884 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
885 257add31 2020-09-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
887 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
890 f6cae3ed 2020-09-13 naddy test_commit_gitconfig_author() {
891 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
893 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
895 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
896 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
900 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
901 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
903 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
905 7370f802 2022-07-24 op # unset in a subshell to avoid affecting our environment
906 7370f802 2022-07-24 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
907 7370f802 2022-07-24 op got commit -m 'test gitconfig author' > /dev/null)
909 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
910 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
914 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
916 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
917 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
921 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
922 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
923 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
925 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
926 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
928 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
931 f6cae3ed 2020-09-13 naddy test_commit_xbit_change() {
932 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
934 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
936 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
937 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
941 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
943 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
944 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
946 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
948 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
949 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
950 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
954 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
956 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
957 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
958 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
962 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
963 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
964 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
965 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
967 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
968 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
969 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
973 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
975 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
976 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
978 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
979 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
980 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
984 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
986 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
987 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
989 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
991 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
992 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
993 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
997 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
999 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1000 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
1001 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1005 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
1006 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1007 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1008 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1010 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1011 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1012 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1016 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
1018 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1019 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1021 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1023 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1024 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1026 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1029 f6cae3ed 2020-09-13 naddy commit_check_mode() {
1030 f7b97ccb 2020-04-14 stsp local mode="$1"
1031 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
1033 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
1034 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
1035 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
1037 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
1039 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1040 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
1041 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1045 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
1046 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
1047 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1048 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1050 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1051 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1052 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1056 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
1057 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
1058 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
1059 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
1060 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
1061 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
1062 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1064 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1065 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1067 f7b97ccb 2020-04-14 stsp return $ret
1070 f6cae3ed 2020-09-13 naddy test_commit_normalizes_filemodes() {
1071 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
1073 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1075 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1076 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1080 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
1081 f7b97ccb 2020-04-14 stsp for m in $modes; do
1082 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
1084 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1088 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1089 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1092 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
1093 f7b97ccb 2020-04-14 stsp for m in $modes; do
1094 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
1096 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1100 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1101 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1104 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1107 f6cae3ed 2020-09-13 naddy test_commit_with_unrelated_submodule() {
1108 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
1110 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1112 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
1113 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1115 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1117 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1118 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
1119 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1123 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
1125 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
1127 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1129 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1130 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
1131 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
1135 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
1136 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
1137 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1139 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1141 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1142 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1144 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1147 f6cae3ed 2020-09-13 naddy check_symlinks() {
1148 bd6aa359 2020-07-23 stsp local wtpath="$1"
1149 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
1150 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
1154 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
1155 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1156 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1158 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1159 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1163 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
1164 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
1168 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
1169 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1170 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1172 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1173 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1177 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
1178 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1179 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
1183 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1184 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
1186 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1187 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
1191 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1193 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1194 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1198 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
1199 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1200 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1202 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1203 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1207 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
1208 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1209 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1211 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1212 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1219 f6cae3ed 2020-09-13 naddy test_commit_symlink() {
1220 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
1222 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1224 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1225 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1229 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
1230 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
1231 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1232 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1233 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1234 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1235 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
1237 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1238 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1240 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1241 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1242 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1245 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1246 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1247 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1248 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1250 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1251 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1252 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1256 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1257 35213c7c 2020-07-23 stsp > $testroot/stdout)
1259 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1260 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1261 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1262 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1263 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1264 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1265 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1267 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1269 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1270 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1271 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1275 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1276 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1278 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1279 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1282 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1284 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1285 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1289 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1290 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1291 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1295 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1296 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1297 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1299 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1300 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1304 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1305 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
1306 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1307 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1308 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1309 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1310 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1311 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1312 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1313 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1315 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1316 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1318 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1319 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1320 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1323 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1324 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1325 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1326 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1328 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1329 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1330 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1334 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1335 35213c7c 2020-07-23 stsp > $testroot/stdout)
1337 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1338 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1339 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1340 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1341 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1342 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1343 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1344 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1346 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1348 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1349 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1350 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1354 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1355 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1357 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1359 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1361 88fb31d4 2020-07-23 stsp epsilon/beta.link
1362 88fb31d4 2020-07-23 stsp epsilon/zeta
1363 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1365 88fb31d4 2020-07-23 stsp gamma/delta
1366 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1367 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1369 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1371 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1372 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1374 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1377 f6cae3ed 2020-09-13 naddy test_commit_fix_bad_symlink() {
1378 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1380 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1382 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1383 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1384 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1388 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1389 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1391 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1392 35213c7c 2020-07-23 stsp > $testroot/stdout)
1394 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1395 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1396 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1399 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1400 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1401 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1402 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1406 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1407 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1409 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1410 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1411 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1415 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1416 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -sfh alpha passwd.link)
1418 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1419 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1421 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1422 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1423 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1425 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1427 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1428 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1429 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1433 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1434 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1435 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1439 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1440 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1441 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1443 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1444 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1448 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1449 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1451 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1452 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1453 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1457 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1458 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1459 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1463 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1464 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1465 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1467 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1468 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1472 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1475 28cf319f 2021-01-28 stsp test_commit_prepared_logmsg() {
1476 28cf319f 2021-01-28 stsp local testroot=`test_init commit_prepared_logmsg`
1478 28cf319f 2021-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1480 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1481 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1485 28cf319f 2021-01-28 stsp echo "modified alpha" > $testroot/wt/alpha
1486 28cf319f 2021-01-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
1487 28cf319f 2021-01-28 stsp echo "new file" > $testroot/wt/new
1488 28cf319f 2021-01-28 stsp (cd $testroot/wt && got add new >/dev/null)
1490 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg' > $testroot/logmsg
1492 28cf319f 2021-01-28 stsp cat > $testroot/editor.sh <<EOF
1494 28cf319f 2021-01-28 stsp sed -i 's/foo/bar/' "\$1"
1496 28cf319f 2021-01-28 stsp chmod +x $testroot/editor.sh
1498 8e09a168 2021-06-17 tracey (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1499 28cf319f 2021-01-28 stsp got commit -F "$testroot/logmsg" > $testroot/stdout)
1501 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1502 28cf319f 2021-01-28 stsp echo "A new" > $testroot/stdout.expected
1503 28cf319f 2021-01-28 stsp echo "M alpha" >> $testroot/stdout.expected
1504 28cf319f 2021-01-28 stsp echo "D beta" >> $testroot/stdout.expected
1505 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1507 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1509 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1510 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1511 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1515 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1516 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1517 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" > $testroot/stdout.expected
1518 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1519 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1520 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1521 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1522 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1523 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1525 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1526 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1528 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1529 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1530 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1534 28cf319f 2021-01-28 stsp echo "modified alpha again" > $testroot/wt/alpha
1536 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg non-interactive' \
1537 28cf319f 2021-01-28 stsp > $testroot/logmsg
1539 28cf319f 2021-01-28 stsp (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1540 28cf319f 2021-01-28 stsp > $testroot/stdout)
1542 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1543 28cf319f 2021-01-28 stsp echo "M alpha" > $testroot/stdout.expected
1544 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1546 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1548 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1549 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1550 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1554 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1555 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1556 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" \
1557 28cf319f 2021-01-28 stsp > $testroot/stdout.expected
1558 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1559 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1560 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1561 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1562 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg non-interactive" \
1563 28cf319f 2021-01-28 stsp >> $testroot/stdout.expected
1564 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1566 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1567 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1569 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1570 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1572 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1575 72840534 2022-01-19 stsp test_commit_large_file() {
1576 72840534 2022-01-19 stsp local testroot=`test_init commit_large_file`
1578 72840534 2022-01-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1580 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1581 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1585 230e1f1b 2022-07-05 stsp dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1586 72840534 2022-01-19 stsp (cd $testroot/wt && got add new >/dev/null)
1588 72840534 2022-01-19 stsp (cd $testroot/wt && got commit -m 'test commit_large_file' \
1589 72840534 2022-01-19 stsp > $testroot/stdout)
1591 72840534 2022-01-19 stsp local head_rev=`git_show_head $testroot/repo`
1592 72840534 2022-01-19 stsp echo "A new" > $testroot/stdout.expected
1593 72840534 2022-01-19 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1595 72840534 2022-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1597 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1598 72840534 2022-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1599 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1603 72840534 2022-01-19 stsp new_id=`get_blob_id $testroot/repo "" new`
1604 72840534 2022-01-19 stsp got cat -r $testroot/repo $new_id > $testroot/new
1606 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1607 72840534 2022-01-19 stsp echo "commit failed unexpectedly" >&2
1608 72840534 2022-01-19 stsp test_done "$testroot" "1"
1612 72840534 2022-01-19 stsp cmp -s $testroot/new $testroot/wt/new
1614 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1615 72840534 2022-01-19 stsp diff -u $testroot/new $testroot/wt/new
1617 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1623 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1624 c4296144 2019-05-09 stsp run_test test_commit_basic
1625 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
1626 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
1627 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
1628 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
1629 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
1630 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
1631 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
1632 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
1633 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
1634 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
1635 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
1636 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
1637 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
1638 84792843 2019-08-09 stsp run_test test_commit_no_email
1639 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
1640 62b21d33 2022-07-19 op run_test test_commit_cmdline_author
1641 257add31 2020-09-09 stsp run_test test_commit_gotconfig_author
1642 50b0790e 2020-09-11 stsp run_test test_commit_gotconfig_worktree_author
1643 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
1644 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
1645 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
1646 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
1647 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
1648 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink
1649 28cf319f 2021-01-28 stsp run_test test_commit_prepared_logmsg
1650 72840534 2022-01-19 stsp run_test test_commit_large_file