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 c4296144 2019-05-09 stsp function 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 c4296144 2019-05-09 stsp if [ "$ret" != "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 c4296144 2019-05-09 stsp if [ "$ret" != "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 baa7dcfa 2019-05-09 stsp function 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 baa7dcfa 2019-05-09 stsp if [ "$ret" != "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 baa7dcfa 2019-05-09 stsp if [ "$ret" != "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 bc70eb79 2019-05-09 stsp function 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 bc70eb79 2019-05-09 stsp if [ "$ret" != "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 bc70eb79 2019-05-09 stsp if [ "$ret" != "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 5bbcb68b 2019-05-09 stsp function 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 5bbcb68b 2019-05-09 stsp if [ "$ret" != "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 5bbcb68b 2019-05-09 stsp if [ "$ret" != "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 819f385b 2019-05-10 stsp function 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 819f385b 2019-05-10 stsp if [ "$ret" != "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 819f385b 2019-05-10 stsp if [ "$ret" != "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 819f385b 2019-05-10 stsp if [ "$ret" != "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 f0b75401 2019-08-03 stsp if [ "$ret" != "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 f0b75401 2019-08-03 stsp if [ "$ret" != "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 8ba6ba2d 2019-05-14 stsp function 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 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "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 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
233 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
235 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
236 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
238 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
241 f363d663 2019-05-23 stsp function test_commit_rejects_conflicted_file {
242 461aee03 2019-06-29 stsp local testroot=`test_init commit_rejects_conflicted_file`
244 f363d663 2019-05-23 stsp local initial_rev=`git_show_head $testroot/repo`
246 f363d663 2019-05-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
248 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
249 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
253 f363d663 2019-05-23 stsp echo "modified alpha" > $testroot/wt/alpha
254 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
256 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
258 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
260 f363d663 2019-05-23 stsp echo "C alpha" > $testroot/stdout.expected
261 f363d663 2019-05-23 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
262 f363d663 2019-05-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
263 f363d663 2019-05-23 stsp echo >> $testroot/stdout.expected
265 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
267 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
269 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
270 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
271 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
275 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
276 f363d663 2019-05-23 stsp 2> $testroot/stderr)
278 f363d663 2019-05-23 stsp echo -n > $testroot/stdout.expected
279 f363d663 2019-05-23 stsp echo "got: cannot commit file in conflicted status" \
280 f363d663 2019-05-23 stsp > $testroot/stderr.expected
282 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
284 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
285 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
286 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
289 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
291 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
292 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
294 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
297 1a36436d 2019-06-10 stsp function test_commit_single_file_multiple {
298 1a36436d 2019-06-10 stsp local testroot=`test_init commit_single_file_multiple`
300 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
302 1a36436d 2019-06-10 stsp if [ "$ret" != "0" ]; then
303 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
307 1a36436d 2019-06-10 stsp for i in 1 2 3 4; do
308 1a36436d 2019-06-10 stsp echo "modified alpha" >> $testroot/wt/alpha
310 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
311 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
313 1a36436d 2019-06-10 stsp local head_rev=`git_show_head $testroot/repo`
314 1a36436d 2019-06-10 stsp echo "M alpha" > $testroot/stdout.expected
315 1a36436d 2019-06-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
317 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
319 1a36436d 2019-06-10 stsp if [ "$ret" != "0" ]; then
320 1a36436d 2019-06-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
321 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
326 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
329 4866d084 2019-07-10 stsp function test_commit_added_and_modified_in_same_dir {
330 4866d084 2019-07-10 stsp local testroot=`test_init commit_added_and_modified_in_same_dir`
332 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
334 4866d084 2019-07-10 stsp if [ "$ret" != "0" ]; then
335 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
339 4866d084 2019-07-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
340 4866d084 2019-07-10 stsp echo "new file" > $testroot/wt/epsilon/new
341 4866d084 2019-07-10 stsp (cd $testroot/wt && got add epsilon/new >/dev/null)
343 4866d084 2019-07-10 stsp (cd $testroot/wt && got commit \
344 4866d084 2019-07-10 stsp -m 'added and modified in same dir' > $testroot/stdout \
345 4866d084 2019-07-10 stsp 2> $testroot/stderr)
347 4866d084 2019-07-10 stsp local head_rev=`git_show_head $testroot/repo`
348 4866d084 2019-07-10 stsp echo "A epsilon/new" > $testroot/stdout.expected
349 4866d084 2019-07-10 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
350 4866d084 2019-07-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
352 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
354 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
355 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
357 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
360 e0233cea 2019-07-25 stsp function test_commit_path_prefix {
361 e0233cea 2019-07-25 stsp local testroot=`test_init commit_path_prefix`
362 e0233cea 2019-07-25 stsp local commit1=`git_show_head $testroot/repo`
364 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
366 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
367 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
371 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
373 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
375 e0233cea 2019-07-25 stsp local commit2=`git_show_head $testroot/repo`
376 e0233cea 2019-07-25 stsp echo "M delta" > $testroot/stdout.expected
377 e0233cea 2019-07-25 stsp echo "Created commit $commit2" >> $testroot/stdout.expected
379 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
381 4866d084 2019-07-10 stsp if [ "$ret" != "0" ]; then
382 2b496619 2019-07-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
383 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
387 e0233cea 2019-07-25 stsp echo "diff $commit1 $commit2" > $testroot/stdout.expected
388 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
389 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
390 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $testroot/stdout.expected
391 e0233cea 2019-07-25 stsp echo -n 'blob + ' >> $testroot/stdout.expected
392 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
393 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
394 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
395 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
396 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
397 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
398 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
400 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
401 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
403 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
404 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
406 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
409 90e8619e 2019-07-25 stsp function test_commit_dir_path {
410 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
412 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
414 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
415 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
419 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
420 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
422 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
423 90e8619e 2019-07-25 stsp > $testroot/stdout)
425 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
426 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
427 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
429 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
431 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
432 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
433 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
437 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
438 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
439 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
441 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
442 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
444 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
447 5c1e53bc 2019-07-28 stsp function test_commit_selected_paths {
448 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
450 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
452 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
453 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
457 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
458 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
459 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
460 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
461 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
462 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
464 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
465 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
467 5c1e53bc 2019-07-28 stsp if [ "$ret" == "0" ]; then
468 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
469 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
472 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
474 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
476 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
477 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
478 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
482 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
483 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
485 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
486 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
487 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
488 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
489 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
491 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
493 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
494 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
496 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
499 916f288c 2019-07-30 stsp function test_commit_outside_refs_heads {
500 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
502 916f288c 2019-07-30 stsp got ref -r $testroot/repo refs/remotes/origin/master master
504 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
505 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
507 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
508 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
512 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
514 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
515 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
517 916f288c 2019-07-30 stsp if [ "$ret" == "0" ]; then
518 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
519 916f288c 2019-07-30 stsp test_done "$testroot" "1"
523 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
524 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
526 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
527 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
528 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
532 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
533 916f288c 2019-07-30 stsp > $testroot/stderr.expected
534 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
535 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
536 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
538 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
539 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
541 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
544 84792843 2019-08-09 stsp function test_commit_no_email {
545 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
547 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
549 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
550 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
554 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
555 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
556 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
557 84792843 2019-08-09 stsp 2> $testroot/stderr)
559 84792843 2019-08-09 stsp echo -n "got: GOT_AUTHOR environment variable contains no email " \
560 84792843 2019-08-09 stsp > $testroot/stderr.expected
561 84792843 2019-08-09 stsp echo -n "address; an email address is required for compatibility "\
562 84792843 2019-08-09 stsp >> $testroot/stderr.expected
563 84792843 2019-08-09 stsp echo "with Git" >> $testroot/stderr.expected
564 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
566 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
567 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
568 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
572 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
573 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
575 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
576 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
578 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
581 6af1ccbd 2019-08-16 stsp function test_commit_tree_entry_sorting {
582 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
584 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
586 6af1ccbd 2019-08-16 stsp if [ "$ret" != "0" ]; then
587 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
591 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
592 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
593 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
594 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
595 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
596 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
597 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
598 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
599 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
601 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
603 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
604 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
605 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
607 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
610 aba9c984 2019-09-08 stsp function test_commit_gitconfig_author {
611 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
613 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
615 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
616 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
620 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
621 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
623 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
624 aba9c984 2019-09-08 stsp (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
626 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
627 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
631 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
633 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
634 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
638 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
639 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
640 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
642 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
643 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
645 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
648 1ebedb77 2019-10-19 stsp function test_commit_xbit_change {
649 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
651 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
653 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
654 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
658 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
660 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
661 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
663 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
665 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
666 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
667 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
671 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
673 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
674 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
675 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
679 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
680 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
681 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
682 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
684 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
685 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
686 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
690 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
692 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
693 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
695 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
696 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
697 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
701 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
703 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
704 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
706 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
708 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
709 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
710 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
714 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
716 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
717 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
718 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
722 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
723 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
724 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
725 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
727 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
728 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
729 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
733 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
735 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
736 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
738 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
740 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
741 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
743 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
746 c4296144 2019-05-09 stsp run_test test_commit_basic
747 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
748 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
749 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
750 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
751 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
752 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
753 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
754 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
755 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
756 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
757 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
758 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
759 84792843 2019-08-09 stsp run_test test_commit_no_email
760 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
761 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
762 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change