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)
297 12383673 2023-02-18 mark local commit_id1=`git_show_head $testroot/repo`
299 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
301 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
303 f363d663 2019-05-23 stsp echo "C alpha" > $testroot/stdout.expected
304 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
305 f363d663 2019-05-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
306 f363d663 2019-05-23 stsp echo >> $testroot/stdout.expected
307 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
309 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
311 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
313 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
314 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
315 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
319 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
320 f363d663 2019-05-23 stsp 2> $testroot/stderr)
322 12383673 2023-02-18 mark if [ $ret -eq 0 ]; then
323 12383673 2023-02-18 mark echo "got commit succeeded unexpectedly"
324 12383673 2023-02-18 mark test_done "$testroot" "$ret"
328 12383673 2023-02-18 mark echo "C alpha" > $testroot/stdout.expected
329 f363d663 2019-05-23 stsp echo "got: cannot commit file in conflicted status" \
330 f363d663 2019-05-23 stsp > $testroot/stderr.expected
332 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
334 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
335 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
336 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
339 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
341 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
342 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
343 12383673 2023-02-18 mark test_done "$testroot" "$ret"
347 12383673 2023-02-18 mark (cd $testroot/wt && got commit -C -m 'commit it' > $testroot/stdout \
348 12383673 2023-02-18 mark 2> $testroot/stderr)
350 12383673 2023-02-18 mark if [ $ret -ne 0 ]; then
351 12383673 2023-02-18 mark echo "got commit failed unexpectedly"
352 12383673 2023-02-18 mark test_done "$testroot" "$ret"
356 12383673 2023-02-18 mark # make sure the conflicted commit produces a diff
357 12383673 2023-02-18 mark local conflict_commit=`git_show_head $testroot/repo`
358 12383673 2023-02-18 mark local blob_minus=`got tree -r $testroot/repo -c $commit_id1 -i | \
359 12383673 2023-02-18 mark grep 'alpha$' | cut -d' ' -f1`
360 12383673 2023-02-18 mark local blob_plus=`got tree -r $testroot/repo -c $conflict_commit -i | \
361 12383673 2023-02-18 mark grep 'alpha$' | cut -d' ' -f1`
363 12383673 2023-02-18 mark echo -n > $testroot/stderr.expected
364 12383673 2023-02-18 mark cmp -s $testroot/stderr.expected $testroot/stderr
366 12383673 2023-02-18 mark if [ $ret -ne 0 ]; then
367 12383673 2023-02-18 mark diff -u $testroot/stderr.expected $testroot/stderr
368 12383673 2023-02-18 mark test_done "$testroot" "$ret"
372 12383673 2023-02-18 mark (cd $testroot/wt && got diff -c master > $testroot/stdout)
374 12383673 2023-02-18 mark echo -n > $testroot/stdout.expected
375 12383673 2023-02-18 mark cat > $testroot/stdout.expected <<EOF
376 12383673 2023-02-18 mark diff $commit_id1 refs/heads/master
377 12383673 2023-02-18 mark commit - $commit_id1
378 12383673 2023-02-18 mark commit + $conflict_commit
379 12383673 2023-02-18 mark blob - $blob_minus
380 12383673 2023-02-18 mark blob + $blob_plus
383 12383673 2023-02-18 mark @@ -1 +1,7 @@
384 12383673 2023-02-18 mark +<<<<<<< merged change: commit $commit_id1
385 12383673 2023-02-18 mark modified alpha
386 12383673 2023-02-18 mark +||||||| 3-way merge base: commit $initial_rev
389 12383673 2023-02-18 mark +modified alpha, too
393 12383673 2023-02-18 mark cmp -s $testroot/stdout.expected $testroot/stdout
395 12383673 2023-02-18 mark if [ $ret -ne 0 ]; then
396 12383673 2023-02-18 mark diff -u $testroot/stdout.expected $testroot/stdout
397 12383673 2023-02-18 mark test_done "$testroot" "$ret"
401 12383673 2023-02-18 mark (cd $testroot/wt && got status > $testroot/stdout)
403 12383673 2023-02-18 mark echo -n > $testroot/stdout.expected
404 12383673 2023-02-18 mark cmp -s $testroot/stdout.expected $testroot/stdout
406 12383673 2023-02-18 mark if [ $ret -ne 0 ]; then
407 12383673 2023-02-18 mark diff -u $testroot/stdout.expected $testroot/stdout
409 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
412 f6cae3ed 2020-09-13 naddy test_commit_single_file_multiple() {
413 1a36436d 2019-06-10 stsp local testroot=`test_init commit_single_file_multiple`
415 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
418 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
422 1a36436d 2019-06-10 stsp for i in 1 2 3 4; do
423 1a36436d 2019-06-10 stsp echo "modified alpha" >> $testroot/wt/alpha
425 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
426 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
428 1a36436d 2019-06-10 stsp local head_rev=`git_show_head $testroot/repo`
429 1a36436d 2019-06-10 stsp echo "M alpha" > $testroot/stdout.expected
430 1a36436d 2019-06-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
432 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
434 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
435 1a36436d 2019-06-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
436 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
441 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
444 f6cae3ed 2020-09-13 naddy test_commit_added_and_modified_in_same_dir() {
445 4866d084 2019-07-10 stsp local testroot=`test_init commit_added_and_modified_in_same_dir`
447 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
449 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
450 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
454 4866d084 2019-07-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
455 4866d084 2019-07-10 stsp echo "new file" > $testroot/wt/epsilon/new
456 4866d084 2019-07-10 stsp (cd $testroot/wt && got add epsilon/new >/dev/null)
458 4866d084 2019-07-10 stsp (cd $testroot/wt && got commit \
459 4866d084 2019-07-10 stsp -m 'added and modified in same dir' > $testroot/stdout \
460 4866d084 2019-07-10 stsp 2> $testroot/stderr)
462 4866d084 2019-07-10 stsp local head_rev=`git_show_head $testroot/repo`
463 4866d084 2019-07-10 stsp echo "A epsilon/new" > $testroot/stdout.expected
464 4866d084 2019-07-10 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
465 4866d084 2019-07-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
467 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
469 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
470 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
472 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
475 f6cae3ed 2020-09-13 naddy test_commit_path_prefix() {
476 e0233cea 2019-07-25 stsp local testroot=`test_init commit_path_prefix`
477 e0233cea 2019-07-25 stsp local commit1=`git_show_head $testroot/repo`
479 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
481 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
482 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
486 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
488 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
490 e0233cea 2019-07-25 stsp local commit2=`git_show_head $testroot/repo`
491 e0233cea 2019-07-25 stsp echo "M delta" > $testroot/stdout.expected
492 e0233cea 2019-07-25 stsp echo "Created commit $commit2" >> $testroot/stdout.expected
494 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
496 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
497 2b496619 2019-07-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
498 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
502 e0233cea 2019-07-25 stsp echo "diff $commit1 $commit2" > $testroot/stdout.expected
503 8469d821 2022-06-25 stsp echo "commit - $commit1" >> $testroot/stdout.expected
504 8469d821 2022-06-25 stsp echo "commit + $commit2" >> $testroot/stdout.expected
505 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
506 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
507 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $testroot/stdout.expected
508 e0233cea 2019-07-25 stsp echo -n 'blob + ' >> $testroot/stdout.expected
509 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
510 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
511 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
512 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
513 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
514 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
515 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
517 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
518 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
520 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
521 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
522 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
526 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got rm delta > /dev/null)
527 f2b0a8b0 2020-07-31 stsp echo new > $testroot/wt/new
528 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got add new > /dev/null)
530 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
531 f2b0a8b0 2020-07-31 stsp > $testroot/stdout)
533 f2b0a8b0 2020-07-31 stsp local commit3=`git_show_head $testroot/repo`
534 f2b0a8b0 2020-07-31 stsp echo "A new" > $testroot/stdout.expected
535 f2b0a8b0 2020-07-31 stsp echo "D delta" >> $testroot/stdout.expected
536 f2b0a8b0 2020-07-31 stsp echo "Created commit $commit3" >> $testroot/stdout.expected
538 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
540 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
541 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
542 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
546 f2b0a8b0 2020-07-31 stsp echo "diff $commit2 $commit3" > $testroot/stdout.expected
547 8469d821 2022-06-25 stsp echo "commit - $commit2" >> $testroot/stdout.expected
548 8469d821 2022-06-25 stsp echo "commit + $commit3" >> $testroot/stdout.expected
549 f2b0a8b0 2020-07-31 stsp echo -n 'blob - ' >> $testroot/stdout.expected
550 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
551 f2b0a8b0 2020-07-31 stsp | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
552 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
553 f2b0a8b0 2020-07-31 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
554 f2b0a8b0 2020-07-31 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
555 f2b0a8b0 2020-07-31 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
556 f2b0a8b0 2020-07-31 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
557 f2b0a8b0 2020-07-31 stsp echo '-modified delta' >> $testroot/stdout.expected
558 f2b0a8b0 2020-07-31 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
559 f2b0a8b0 2020-07-31 stsp echo -n 'blob + ' >> $testroot/stdout.expected
560 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
561 f2b0a8b0 2020-07-31 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
562 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
563 f2b0a8b0 2020-07-31 stsp echo '--- /dev/null' >> $testroot/stdout.expected
564 f2b0a8b0 2020-07-31 stsp echo '+++ gamma/new' >> $testroot/stdout.expected
565 f2b0a8b0 2020-07-31 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
566 f2b0a8b0 2020-07-31 stsp echo '+new' >> $testroot/stdout.expected
568 f2b0a8b0 2020-07-31 stsp got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
569 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
571 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
572 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
574 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
575 f2b0a8b0 2020-07-31 stsp return "$ret"
578 f6cae3ed 2020-09-13 naddy test_commit_dir_path() {
579 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
581 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
583 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
584 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
588 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
589 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
591 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
592 90e8619e 2019-07-25 stsp > $testroot/stdout)
594 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
595 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
596 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
598 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
600 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
601 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
602 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
606 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
607 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
608 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
610 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
611 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
613 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
616 f6cae3ed 2020-09-13 naddy test_commit_selected_paths() {
617 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
619 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
621 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
622 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
626 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
627 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
628 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
629 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
630 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
631 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
633 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
634 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
636 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
637 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
638 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
641 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
643 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
645 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
646 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
647 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
651 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
652 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
654 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
655 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
656 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
657 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
658 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
660 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
662 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
663 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
665 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
668 f6cae3ed 2020-09-13 naddy test_commit_outside_refs_heads() {
669 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
671 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
673 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
674 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
676 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
677 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
681 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
683 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
684 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
686 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
687 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
688 916f288c 2019-07-30 stsp test_done "$testroot" "1"
692 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
693 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
695 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
696 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
697 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
701 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
702 916f288c 2019-07-30 stsp > $testroot/stderr.expected
703 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
704 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
705 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
707 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
708 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
710 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
713 f6cae3ed 2020-09-13 naddy test_commit_no_email() {
714 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
715 cf208ddd 2022-07-19 op local errmsg=""
717 cf208ddd 2022-07-19 op errmsg="commit author's email address is required for"
718 cf208ddd 2022-07-19 op errmsg="$errmsg compatibility with Git"
720 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
722 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
723 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
727 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
728 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
729 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
730 84792843 2019-08-09 stsp 2> $testroot/stderr)
732 cf208ddd 2022-07-19 op printf "got: :flan_hacker:: %s\n" "$errmsg" > $testroot/stderr.expected
733 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
735 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
736 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
737 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
741 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
742 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
744 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
745 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
746 cf208ddd 2022-07-19 op test_done "$testroot" $ret
750 cf208ddd 2022-07-19 op # try again with a newline inside the email
751 cf208ddd 2022-07-19 op (cd $testroot/wt \
752 cf208ddd 2022-07-19 op && FS=' ' env GOT_AUTHOR="$(printf "Flan <hack\ner>")" \
753 cf208ddd 2022-07-19 op got commit -m 'test invalid email' > $testroot/stdout \
754 cf208ddd 2022-07-19 op 2> $testroot/stderr)
756 cf208ddd 2022-07-19 op printf "got: Flan <hack\ner>: %s\n" "$errmsg" \
757 cf208ddd 2022-07-19 op > $testroot/stderr.expected
758 cf208ddd 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
760 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
761 cf208ddd 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
762 cf208ddd 2022-07-19 op test_done "$testroot" $ret
766 cf208ddd 2022-07-19 op echo -n > $testroot/stdout.expected
767 cf208ddd 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
769 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
770 cf208ddd 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
771 cf208ddd 2022-07-19 op test_done "$testroot" $ret
775 cf208ddd 2022-07-19 op # try again with a < inside the email
776 cf208ddd 2022-07-19 op (cd $testroot/wt && env GOT_AUTHOR="$(printf "Flan <ha<ker>")" \
777 cf208ddd 2022-07-19 op got commit -m 'test invalid email' > $testroot/stdout \
778 cf208ddd 2022-07-19 op 2> $testroot/stderr)
780 cf208ddd 2022-07-19 op printf "got: Flan <ha<ker>: %s\n" "$errmsg" > $testroot/stderr.expected
781 cf208ddd 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
783 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
784 cf208ddd 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
785 cf208ddd 2022-07-19 op test_done "$testroot" $ret
789 cf208ddd 2022-07-19 op echo -n > $testroot/stdout.expected
790 cf208ddd 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
792 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
793 cf208ddd 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
795 cf208ddd 2022-07-19 op test_done "$testroot" $ret
798 f6cae3ed 2020-09-13 naddy test_commit_tree_entry_sorting() {
799 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
801 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
803 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
804 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
808 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
809 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
810 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
811 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
812 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
813 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
814 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
815 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
816 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
818 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
820 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
821 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
822 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
824 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
827 62b21d33 2022-07-19 op test_commit_cmdline_author() {
828 62b21d33 2022-07-19 op local testroot=`test_init commit_cmdline_author`
830 62b21d33 2022-07-19 op got checkout $testroot/repo $testroot/wt > /dev/null
832 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
833 62b21d33 2022-07-19 op test_done "$testroot" $ret
837 62b21d33 2022-07-19 op echo "modified alpha" > $testroot/wt/alpha
839 62b21d33 2022-07-19 op local author="Foo <foo@example.com>"
840 62b21d33 2022-07-19 op (cd $testroot/wt && got commit -A "$author" -m 'edit alpha') \
843 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
844 62b21d33 2022-07-19 op test_done "$testroot" $ret
848 62b21d33 2022-07-19 op (cd $testroot/repo && got log -l1 | egrep '^(from|via):') \
849 62b21d33 2022-07-19 op > $testroot/stdout
851 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
852 62b21d33 2022-07-19 op test_done "$testroot" $ret
856 62b21d33 2022-07-19 op echo "from: $author" > $testroot/stdout.expected
857 62b21d33 2022-07-19 op echo "via: $GOT_AUTHOR" >> $testroot/stdout.expected
858 62b21d33 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
860 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
861 62b21d33 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
863 62b21d33 2022-07-19 op test_done "$testroot" $ret
866 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_author() {
867 257add31 2020-09-09 stsp local testroot=`test_init commit_gotconfig_author`
869 257add31 2020-09-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
871 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
872 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
875 257add31 2020-09-09 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
876 257add31 2020-09-09 stsp > $testroot/repo/.git/got.conf
878 257add31 2020-09-09 stsp echo "modified alpha" > $testroot/wt/alpha
879 257add31 2020-09-09 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
881 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
882 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
886 257add31 2020-09-09 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
888 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
889 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
893 257add31 2020-09-09 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
894 50b0790e 2020-09-11 stsp > $testroot/stdout.expected
895 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
897 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
898 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
900 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
903 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_worktree_author() {
904 50b0790e 2020-09-11 stsp local testroot=`test_init commit_gotconfig_worktree_author`
906 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
908 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
909 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
912 50b0790e 2020-09-11 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
913 50b0790e 2020-09-11 stsp > $testroot/repo/.git/got.conf
914 50b0790e 2020-09-11 stsp echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
915 50b0790e 2020-09-11 stsp > $testroot/wt/.got/got.conf
917 50b0790e 2020-09-11 stsp echo "modified alpha" > $testroot/wt/alpha
918 50b0790e 2020-09-11 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
920 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
921 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
925 50b0790e 2020-09-11 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
927 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
928 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
932 50b0790e 2020-09-11 stsp echo "from: Flan Squee <flan_squee@openbsd.org>" \
933 257add31 2020-09-09 stsp > $testroot/stdout.expected
934 257add31 2020-09-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
936 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
937 257add31 2020-09-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
939 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
942 f6cae3ed 2020-09-13 naddy test_commit_gitconfig_author() {
943 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
945 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
947 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
948 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
952 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
953 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
955 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
957 7370f802 2022-07-24 op # unset in a subshell to avoid affecting our environment
958 7370f802 2022-07-24 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
959 7370f802 2022-07-24 op got commit -m 'test gitconfig author' > /dev/null)
961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
962 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
966 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
968 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
969 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
973 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
974 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
975 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
977 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
978 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
979 2b5b5879 2023-02-19 op test_done "$testroot" "$ret"
983 2b5b5879 2023-02-19 op # retry with spaces in the git config
984 2b5b5879 2023-02-19 op ed -s "$testroot/repo/.git/config" <<EOF
988 2b5b5879 2023-02-19 op echo "modified again" > $testroot/wt/alpha
990 2b5b5879 2023-02-19 op # unset in a subshell to avoid affecting our environment
991 2b5b5879 2023-02-19 op (unset GOT_IGNORE_GITCONFIG && cd "$testroot/wt" && \
992 2b5b5879 2023-02-19 op got commit -m 'test gitconfig author again' >/dev/null)
994 2b5b5879 2023-02-19 op if [ $ret -ne 0 ]; then
995 2b5b5879 2023-02-19 op test_done "$testroot" "$ret"
999 2b5b5879 2023-02-19 op (cd "$testroot/repo" && got log -l1 | grep ^from: > $testroot/stdout)
1001 2b5b5879 2023-02-19 op if [ $ret -ne 0 ]; then
1002 2b5b5879 2023-02-19 op test_done "$testroot" "$ret"
1006 2b5b5879 2023-02-19 op echo "from: Flan Luck <flan_luck@openbsd.org>" \
1007 2b5b5879 2023-02-19 op > $testroot/stdout.expected
1008 2b5b5879 2023-02-19 op cmp -s $testroot/stdout.expected $testroot/stdout
1010 2b5b5879 2023-02-19 op if [ $ret -ne 0 ]; then
1011 2b5b5879 2023-02-19 op diff -u $testroot/stdout.expected $testroot/stdout
1013 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
1016 f6cae3ed 2020-09-13 naddy test_commit_xbit_change() {
1017 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
1019 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1021 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1022 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1026 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
1028 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1029 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1031 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1033 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1034 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1035 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1039 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
1041 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1042 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
1043 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1047 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
1048 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1049 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1050 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1052 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1053 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1054 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1058 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1060 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
1061 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1063 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1064 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1065 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1069 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
1071 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1072 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1074 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1076 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1077 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1078 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1082 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
1084 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1085 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
1086 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1090 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
1091 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1092 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1093 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1095 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1096 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1097 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1101 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
1103 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1104 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1106 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1108 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1109 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1111 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1114 f6cae3ed 2020-09-13 naddy commit_check_mode() {
1115 f7b97ccb 2020-04-14 stsp local mode="$1"
1116 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
1118 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
1119 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
1120 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
1122 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
1124 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1125 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
1126 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1130 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
1131 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
1132 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1133 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1135 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1136 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1137 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1141 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
1142 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
1143 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
1144 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
1145 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
1146 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
1147 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1149 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1150 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1152 f7b97ccb 2020-04-14 stsp return $ret
1155 f6cae3ed 2020-09-13 naddy test_commit_normalizes_filemodes() {
1156 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
1158 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1160 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1161 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1165 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
1166 f7b97ccb 2020-04-14 stsp for m in $modes; do
1167 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
1169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1173 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1174 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1177 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
1178 f7b97ccb 2020-04-14 stsp for m in $modes; do
1179 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
1181 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1185 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1186 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1189 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1192 f6cae3ed 2020-09-13 naddy test_commit_with_unrelated_submodule() {
1193 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
1195 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1197 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
1198 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
1199 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1201 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1203 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1204 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
1205 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1209 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
1211 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
1213 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1215 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1216 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
1217 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
1221 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
1222 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
1223 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1225 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1227 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1228 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1230 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1233 f6cae3ed 2020-09-13 naddy check_symlinks() {
1234 bd6aa359 2020-07-23 stsp local wtpath="$1"
1235 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
1236 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
1240 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
1241 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1242 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1244 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1245 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1249 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
1250 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
1254 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
1255 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1256 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1258 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1259 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1263 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
1264 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1265 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
1269 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1270 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
1272 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1273 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
1277 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1279 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1280 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1284 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
1285 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1286 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1288 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1289 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1293 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
1294 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1295 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1297 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1298 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1305 f6cae3ed 2020-09-13 naddy test_commit_symlink() {
1306 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
1308 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1310 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1311 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1315 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
1316 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
1317 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1318 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1319 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1320 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1321 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
1323 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1324 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1326 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1327 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1328 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1331 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1332 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1333 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1334 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1336 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1337 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1338 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1342 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1343 35213c7c 2020-07-23 stsp > $testroot/stdout)
1345 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1346 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1347 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1348 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1349 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1350 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1351 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1353 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1355 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1356 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1357 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1361 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1362 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1364 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1365 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1368 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1370 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1371 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1375 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1376 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1377 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1381 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1382 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1383 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1385 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1386 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1390 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1391 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
1392 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1393 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1394 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1395 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1396 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1397 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1398 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1399 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1401 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1402 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1404 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1405 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1406 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1409 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1410 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1411 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1412 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1414 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1415 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1416 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1420 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1421 35213c7c 2020-07-23 stsp > $testroot/stdout)
1423 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1424 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1425 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1426 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1427 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1428 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1429 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1430 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1432 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1434 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1435 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1436 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1440 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1441 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1443 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1445 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1447 88fb31d4 2020-07-23 stsp epsilon/beta.link
1448 88fb31d4 2020-07-23 stsp epsilon/zeta
1449 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1451 88fb31d4 2020-07-23 stsp gamma/delta
1452 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1453 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1455 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1457 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1458 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1460 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1463 f6cae3ed 2020-09-13 naddy test_commit_fix_bad_symlink() {
1464 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1466 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1468 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1469 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1470 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1474 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1475 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1477 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1478 35213c7c 2020-07-23 stsp > $testroot/stdout)
1480 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1481 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1482 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1485 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1486 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1487 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1488 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1492 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1493 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1495 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1496 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1497 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1501 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1502 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -sfh alpha passwd.link)
1504 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1505 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1507 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1508 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1509 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1511 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1513 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1514 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1515 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1519 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1520 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1521 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1525 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1526 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1527 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1529 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1530 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1534 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1535 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1537 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1538 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1539 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1543 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1544 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1545 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1549 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1550 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1551 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1553 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1554 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1558 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1561 28cf319f 2021-01-28 stsp test_commit_prepared_logmsg() {
1562 28cf319f 2021-01-28 stsp local testroot=`test_init commit_prepared_logmsg`
1564 28cf319f 2021-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1566 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1567 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1571 28cf319f 2021-01-28 stsp echo "modified alpha" > $testroot/wt/alpha
1572 28cf319f 2021-01-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
1573 28cf319f 2021-01-28 stsp echo "new file" > $testroot/wt/new
1574 28cf319f 2021-01-28 stsp (cd $testroot/wt && got add new >/dev/null)
1576 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg' > $testroot/logmsg
1578 28cf319f 2021-01-28 stsp cat > $testroot/editor.sh <<EOF
1580 28cf319f 2021-01-28 stsp sed -i 's/foo/bar/' "\$1"
1582 28cf319f 2021-01-28 stsp chmod +x $testroot/editor.sh
1584 8e09a168 2021-06-17 tracey (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1585 28cf319f 2021-01-28 stsp got commit -F "$testroot/logmsg" > $testroot/stdout)
1587 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1588 28cf319f 2021-01-28 stsp echo "A new" > $testroot/stdout.expected
1589 28cf319f 2021-01-28 stsp echo "M alpha" >> $testroot/stdout.expected
1590 28cf319f 2021-01-28 stsp echo "D beta" >> $testroot/stdout.expected
1591 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1593 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1595 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1596 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1597 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1601 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1602 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1603 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" > $testroot/stdout.expected
1604 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1605 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1606 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1607 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1608 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1609 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1611 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1612 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1614 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1615 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1616 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1620 28cf319f 2021-01-28 stsp echo "modified alpha again" > $testroot/wt/alpha
1622 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg non-interactive' \
1623 28cf319f 2021-01-28 stsp > $testroot/logmsg
1625 28cf319f 2021-01-28 stsp (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1626 28cf319f 2021-01-28 stsp > $testroot/stdout)
1628 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1629 28cf319f 2021-01-28 stsp echo "M alpha" > $testroot/stdout.expected
1630 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1632 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1634 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1635 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1636 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1640 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1641 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1642 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" \
1643 28cf319f 2021-01-28 stsp > $testroot/stdout.expected
1644 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1645 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1646 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1647 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1648 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg non-interactive" \
1649 28cf319f 2021-01-28 stsp >> $testroot/stdout.expected
1650 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1652 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1653 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1655 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1656 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1658 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1661 72840534 2022-01-19 stsp test_commit_large_file() {
1662 72840534 2022-01-19 stsp local testroot=`test_init commit_large_file`
1664 72840534 2022-01-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1666 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1667 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1671 230e1f1b 2022-07-05 stsp dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1672 72840534 2022-01-19 stsp (cd $testroot/wt && got add new >/dev/null)
1674 72840534 2022-01-19 stsp (cd $testroot/wt && got commit -m 'test commit_large_file' \
1675 72840534 2022-01-19 stsp > $testroot/stdout)
1677 72840534 2022-01-19 stsp local head_rev=`git_show_head $testroot/repo`
1678 72840534 2022-01-19 stsp echo "A new" > $testroot/stdout.expected
1679 72840534 2022-01-19 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1681 72840534 2022-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1683 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1684 72840534 2022-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1685 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1689 72840534 2022-01-19 stsp new_id=`get_blob_id $testroot/repo "" new`
1690 72840534 2022-01-19 stsp got cat -r $testroot/repo $new_id > $testroot/new
1692 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1693 72840534 2022-01-19 stsp echo "commit failed unexpectedly" >&2
1694 72840534 2022-01-19 stsp test_done "$testroot" "1"
1698 72840534 2022-01-19 stsp cmp -s $testroot/new $testroot/wt/new
1700 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1701 72840534 2022-01-19 stsp diff -u $testroot/new $testroot/wt/new
1703 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1708 4ba2e955 2022-09-02 sh+got test_commit_gitignore() {
1709 4ba2e955 2022-09-02 sh+got local testroot=`test_init commit_gitignores`
1711 4ba2e955 2022-09-02 sh+got got checkout $testroot/repo $testroot/wt > /dev/null
1713 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1714 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1715 4ba2e955 2022-09-02 sh+got return 1
1718 4ba2e955 2022-09-02 sh+got mkdir -p $testroot/wt/tree1/foo
1719 4ba2e955 2022-09-02 sh+got mkdir -p $testroot/wt/tree2/foo
1720 4ba2e955 2022-09-02 sh+got echo "tree1/**" > $testroot/wt/.gitignore
1721 4ba2e955 2022-09-02 sh+got echo "tree2/**" >> $testroot/wt/.gitignore
1722 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree1/bar
1723 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree1/foo/baz
1724 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree2/bar
1725 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree2/foo/baz
1726 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/epsilon/zeta1
1727 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/epsilon/zeta2
1729 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got add -I -R tree1 > /dev/null)
1730 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got add -I tree2/foo/baz > /dev/null)
1731 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got commit -m "gitignore add" > /dev/null)
1732 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1734 4ba2e955 2022-09-02 sh+got echo ' gitignore add' > $testroot/stdout.expected
1735 4ba2e955 2022-09-02 sh+got echo ' A tree1/bar' >> $testroot/stdout.expected
1736 4ba2e955 2022-09-02 sh+got echo ' A tree1/foo/baz' >> $testroot/stdout.expected
1737 4ba2e955 2022-09-02 sh+got echo ' A tree2/foo/baz' >> $testroot/stdout.expected
1739 4ba2e955 2022-09-02 sh+got cmp -s $testroot/stdout.expected $testroot/stdout
1741 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1742 4ba2e955 2022-09-02 sh+got diff -u $testroot/stdout.expected $testroot/stdout
1743 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1744 4ba2e955 2022-09-02 sh+got return 1
1747 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/tree1/bar
1748 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/tree1/foo/baz
1749 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/epsilon/zeta1
1751 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got commit -m "gitignore change" > /dev/null)
1752 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1754 4ba2e955 2022-09-02 sh+got echo ' gitignore change' > $testroot/stdout.expected
1755 4ba2e955 2022-09-02 sh+got echo ' M tree1/bar' >> $testroot/stdout.expected
1756 4ba2e955 2022-09-02 sh+got echo ' M tree1/foo/baz' >> $testroot/stdout.expected
1758 4ba2e955 2022-09-02 sh+got cmp -s $testroot/stdout.expected $testroot/stdout
1760 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1761 4ba2e955 2022-09-02 sh+got diff -u $testroot/stdout.expected $testroot/stdout
1762 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1763 4ba2e955 2022-09-02 sh+got return 1
1766 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1769 21f07726 2022-10-31 stsp test_commit_bad_author() {
1770 21f07726 2022-10-31 stsp local testroot=`test_init commit_bad_author`
1772 21f07726 2022-10-31 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1774 21f07726 2022-10-31 stsp if [ $ret -ne 0 ]; then
1775 21f07726 2022-10-31 stsp test_done "$testroot" $ret
1779 21f07726 2022-10-31 stsp echo "modified alpha" > $testroot/wt/alpha
1781 21f07726 2022-10-31 stsp (cd $testroot/wt && got commit \
1782 21f07726 2022-10-31 stsp -A "${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>" -m 'edit alpha') \
1783 21f07726 2022-10-31 stsp > /dev/null 2> $testroot/stderr
1785 21f07726 2022-10-31 stsp if [ $ret -eq 0 ]; then
1786 21f07726 2022-10-31 stsp test_done "$testroot" 1
1790 21f07726 2022-10-31 stsp echo -n "got: ${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>: " \
1791 21f07726 2022-10-31 stsp > $testroot/stderr.expected
1792 21f07726 2022-10-31 stsp echo -n 'space between author name and email required: ' \
1793 21f07726 2022-10-31 stsp >> $testroot/stderr.expected
1794 21f07726 2022-10-31 stsp echo 'commit author formatting would make Git unhappy' \
1795 21f07726 2022-10-31 stsp >> $testroot/stderr.expected
1796 21f07726 2022-10-31 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1798 21f07726 2022-10-31 stsp if [ $ret -ne 0 ]; then
1799 21f07726 2022-10-31 stsp diff -u $testroot/stderr.expected $testroot/stderr
1800 21f07726 2022-10-31 stsp test_done "$testroot" $ret
1804 21f07726 2022-10-31 stsp test_done "$testroot" 0
1807 def2bea2 2023-01-30 mark test_commit_logmsg_ref() {
1808 def2bea2 2023-01-30 mark local testroot=`test_init commit_logmsg_ref`
1810 def2bea2 2023-01-30 mark got checkout $testroot/repo $testroot/wt > /dev/null
1812 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1813 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1817 def2bea2 2023-01-30 mark (cd $testroot/repo && git checkout -q -b newbranch)
1819 def2bea2 2023-01-30 mark local bo_logmsg_prefix="log message of backed-out commit"
1820 def2bea2 2023-01-30 mark local cy_logmsg_prefix="log message of cherrypicked commit"
1821 def2bea2 2023-01-30 mark local branch_rev_logmsg="changes on newbranch to cherrypick"
1822 def2bea2 2023-01-30 mark local branch_rev2_logmsg="modified zeta on newbranch to cherrypick"
1824 def2bea2 2023-01-30 mark echo "modified delta on branch" > $testroot/repo/gamma/delta
1825 def2bea2 2023-01-30 mark echo "modified alpha on branch" > $testroot/repo/alpha
1826 def2bea2 2023-01-30 mark (cd $testroot/repo && git rm -q beta)
1827 def2bea2 2023-01-30 mark echo "new file on branch" > $testroot/repo/epsilon/new
1828 def2bea2 2023-01-30 mark (cd $testroot/repo && git add epsilon/new)
1830 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev_logmsg"
1831 def2bea2 2023-01-30 mark local branch_rev=`git_show_head $testroot/repo`
1833 def2bea2 2023-01-30 mark echo "modified zeta on branch" > $testroot/repo/epsilon/zeta
1835 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev2_logmsg"
1836 def2bea2 2023-01-30 mark local branch_rev2=`git_show_head $testroot/repo`
1838 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1839 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev2 > /dev/null)
1841 def2bea2 2023-01-30 mark cat > $testroot/editor.sh <<EOF
1843 def2bea2 2023-01-30 mark sed -i 's/# l/l/' "\$1"
1845 def2bea2 2023-01-30 mark chmod +x $testroot/editor.sh
1847 def2bea2 2023-01-30 mark (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1848 def2bea2 2023-01-30 mark got commit > /dev/null)
1850 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1851 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1852 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1856 def2bea2 2023-01-30 mark # check that multiple cherrypicked log messages populate the editor
1857 def2bea2 2023-01-30 mark local first=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | head -1`
1858 def2bea2 2023-01-30 mark local second=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | tail -1`
1860 def2bea2 2023-01-30 mark if [ $branch_rev == $first ]; then
1861 def2bea2 2023-01-30 mark local first_msg=$branch_rev_logmsg
1862 def2bea2 2023-01-30 mark local second_msg=$branch_rev2_logmsg
1864 def2bea2 2023-01-30 mark local first_msg=$branch_rev2_logmsg
1865 def2bea2 2023-01-30 mark local second_msg=$branch_rev_logmsg
1868 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $first:" > $testroot/stdout.expected
1869 def2bea2 2023-01-30 mark echo " $first_msg" >> $testroot/stdout.expected
1870 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1871 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $second:" >> $testroot/stdout.expected
1872 def2bea2 2023-01-30 mark echo " $second_msg" >> $testroot/stdout.expected
1873 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1875 def2bea2 2023-01-30 mark (cd $testroot/wt && got log -l2 | \
1876 def2bea2 2023-01-30 mark grep -A2 'log message' | sed '/^--/d' > $testroot/stdout)
1878 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1880 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1881 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1882 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1886 def2bea2 2023-01-30 mark # check that only the relevant log message populates the editor
1887 def2bea2 2023-01-30 mark # when the changes from one of two backout commits are reverted
1888 def2bea2 2023-01-30 mark got checkout $testroot/repo $testroot/wt2 > /dev/null
1890 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1891 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1895 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got backout $branch_rev > /dev/null)
1896 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got backout $branch_rev2 > /dev/null)
1897 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got revert epsilon/zeta > /dev/null)
1899 def2bea2 2023-01-30 mark (cd $testroot/wt2 && env VISUAL="$testroot/editor.sh" \
1900 def2bea2 2023-01-30 mark got commit > /dev/null)
1902 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1903 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1904 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1908 def2bea2 2023-01-30 mark echo " $bo_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1909 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1910 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1912 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got log -l1 | \
1913 def2bea2 2023-01-30 mark grep -A2 'log message' > $testroot/stdout)
1915 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1917 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1918 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1919 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1923 def2bea2 2023-01-30 mark # check that a cherrypicked log message is still
1924 def2bea2 2023-01-30 mark # used when its changes are only partially reverted
1925 def2bea2 2023-01-30 mark branch_rev_logmsg="changes to cherrypick and partially revert"
1927 def2bea2 2023-01-30 mark echo "newline in alpha" >> $testroot/repo/alpha
1928 def2bea2 2023-01-30 mark echo "modified epsilon/zeta on branch" > $testroot/repo/epsilon/zeta
1930 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev_logmsg"
1931 def2bea2 2023-01-30 mark branch_rev=`git_show_head $testroot/repo`
1933 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1934 def2bea2 2023-01-30 mark (cd $testroot/wt && got revert alpha > /dev/null)
1936 def2bea2 2023-01-30 mark (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1937 def2bea2 2023-01-30 mark got commit > /dev/null)
1939 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1940 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1941 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1945 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1946 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1947 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1949 def2bea2 2023-01-30 mark (cd $testroot/wt && got log -l1 | \
1950 def2bea2 2023-01-30 mark grep -A2 'log message' > $testroot/stdout)
1952 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1954 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1955 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1956 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1960 def2bea2 2023-01-30 mark # check we don't use and consequently delete the logmsg ref of a
1961 def2bea2 2023-01-30 mark # cherrypicked commit when omitting its changed path from the commit
1962 def2bea2 2023-01-30 mark branch_rev_logmsg="changes to cherrypick but omit from the commit"
1964 def2bea2 2023-01-30 mark echo "changed delta" >> $testroot/repo/gamma/delta
1966 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev_logmsg"
1967 def2bea2 2023-01-30 mark local author_time=`git_show_author_time $testroot/repo`
1968 def2bea2 2023-01-30 mark local d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1969 def2bea2 2023-01-30 mark branch_rev=`git_show_head $testroot/repo`
1971 def2bea2 2023-01-30 mark (cd $testroot/wt && got update > /dev/null)
1973 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1974 def2bea2 2023-01-30 mark echo "got update failed unexpectedly" >&2
1975 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1979 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1981 def2bea2 2023-01-30 mark echo "changed alpha" >> $testroot/wt/alpha
1983 def2bea2 2023-01-30 mark (cd $testroot/wt && got commit -m \
1984 def2bea2 2023-01-30 mark "don't commit cy change to gamma/delta" alpha > /dev/null)
1986 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1987 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1988 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1992 def2bea2 2023-01-30 mark # confirm logmsg ref was not deleted with got cherrypick -l
1993 def2bea2 2023-01-30 mark echo "-----------------------------------------------" \
1994 def2bea2 2023-01-30 mark > $testroot/stdout.expected
1995 b584caa3 2023-01-30 mark echo "cherrypick $branch_rev (newbranch)" >> $testroot/stdout.expected
1996 def2bea2 2023-01-30 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1997 def2bea2 2023-01-30 mark echo "date: $d" >> $testroot/stdout.expected
1998 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1999 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
2000 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
2001 def2bea2 2023-01-30 mark echo " M gamma/delta" >> $testroot/stdout.expected
2002 def2bea2 2023-01-30 mark echo >> $testroot/stdout.expected
2004 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick -l > $testroot/stdout)
2006 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2008 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2009 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2010 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
2014 def2bea2 2023-01-30 mark # confirm a previously unused logmsg ref is picked up
2015 def2bea2 2023-01-30 mark # when an affected path is actually committed
2016 def2bea2 2023-01-30 mark (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2017 def2bea2 2023-01-30 mark got commit > /dev/null)
2019 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2020 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
2021 def2bea2 2023-01-30 mark test_done "$testroot" "1"
2025 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
2026 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
2027 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
2029 def2bea2 2023-01-30 mark (cd $testroot/wt && got log -l1 | \
2030 def2bea2 2023-01-30 mark grep -A2 'log message' > $testroot/stdout)
2032 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2034 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2035 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2036 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
2040 def2bea2 2023-01-30 mark # make sure we are not littering work trees
2041 def2bea2 2023-01-30 mark # by leaving temp got-logmsg-* files behind
2042 def2bea2 2023-01-30 mark echo -n > $testroot/stdout.expected
2043 def2bea2 2023-01-30 mark (cd $testroot/wt && got status > $testroot/stdout)
2045 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2047 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2048 def2bea2 2023-01-30 mark echo "$testroot/wt is not clean"
2049 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2050 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
2054 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got status > $testroot/stdout)
2056 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2058 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2059 def2bea2 2023-01-30 mark echo "$testroot/repo is not clean"
2060 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2062 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
2065 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2066 c4296144 2019-05-09 stsp run_test test_commit_basic
2067 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
2068 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
2069 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
2070 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
2071 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
2072 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
2073 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
2074 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
2075 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
2076 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
2077 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
2078 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
2079 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
2080 84792843 2019-08-09 stsp run_test test_commit_no_email
2081 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
2082 62b21d33 2022-07-19 op run_test test_commit_cmdline_author
2083 257add31 2020-09-09 stsp run_test test_commit_gotconfig_author
2084 50b0790e 2020-09-11 stsp run_test test_commit_gotconfig_worktree_author
2085 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
2086 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
2087 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
2088 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
2089 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
2090 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink
2091 28cf319f 2021-01-28 stsp run_test test_commit_prepared_logmsg
2092 72840534 2022-01-19 stsp run_test test_commit_large_file
2093 4ba2e955 2022-09-02 sh+got run_test test_commit_gitignore
2094 21f07726 2022-10-31 stsp run_test test_commit_bad_author
2095 def2bea2 2023-01-30 mark run_test test_commit_logmsg_ref