Blame


1 c4296144 2019-05-09 stsp #!/bin/sh
2 c4296144 2019-05-09 stsp #
3 c4296144 2019-05-09 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 c4296144 2019-05-09 stsp #
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.
8 c4296144 2019-05-09 stsp #
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.
16 c4296144 2019-05-09 stsp
17 c4296144 2019-05-09 stsp . ./common.sh
18 c4296144 2019-05-09 stsp
19 c4296144 2019-05-09 stsp function test_commit_basic {
20 c4296144 2019-05-09 stsp local testroot=`test_init commit_basic`
21 c4296144 2019-05-09 stsp
22 c4296144 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 c4296144 2019-05-09 stsp ret="$?"
24 c4296144 2019-05-09 stsp if [ "$ret" != "0" ]; then
25 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
26 c4296144 2019-05-09 stsp return 1
27 c4296144 2019-05-09 stsp fi
28 c4296144 2019-05-09 stsp
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)
33 c4296144 2019-05-09 stsp
34 83a7ae6d 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_basic' > $testroot/stdout)
35 c4296144 2019-05-09 stsp
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
41 c4296144 2019-05-09 stsp
42 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
43 c4296144 2019-05-09 stsp ret="$?"
44 c4296144 2019-05-09 stsp if [ "$ret" != "0" ]; then
45 c4296144 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
46 c4296144 2019-05-09 stsp fi
47 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
48 c4296144 2019-05-09 stsp }
49 c4296144 2019-05-09 stsp
50 baa7dcfa 2019-05-09 stsp function test_commit_new_subdir {
51 baa7dcfa 2019-05-09 stsp local testroot=`test_init commit_new_subdir`
52 baa7dcfa 2019-05-09 stsp
53 baa7dcfa 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
54 baa7dcfa 2019-05-09 stsp ret="$?"
55 baa7dcfa 2019-05-09 stsp if [ "$ret" != "0" ]; then
56 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
57 baa7dcfa 2019-05-09 stsp return 1
58 baa7dcfa 2019-05-09 stsp fi
59 baa7dcfa 2019-05-09 stsp
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)
65 baa7dcfa 2019-05-09 stsp
66 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && \
67 baa7dcfa 2019-05-09 stsp got commit -m 'test commit_new_subdir' > $testroot/stdout)
68 baa7dcfa 2019-05-09 stsp
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
73 baa7dcfa 2019-05-09 stsp
74 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
75 baa7dcfa 2019-05-09 stsp ret="$?"
76 baa7dcfa 2019-05-09 stsp if [ "$ret" != "0" ]; then
77 baa7dcfa 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
78 baa7dcfa 2019-05-09 stsp fi
79 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
80 baa7dcfa 2019-05-09 stsp }
81 baa7dcfa 2019-05-09 stsp
82 bc70eb79 2019-05-09 stsp function test_commit_subdir {
83 bc70eb79 2019-05-09 stsp local testroot=`test_init commit_subdir`
84 bc70eb79 2019-05-09 stsp
85 bc70eb79 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
86 bc70eb79 2019-05-09 stsp ret="$?"
87 bc70eb79 2019-05-09 stsp if [ "$ret" != "0" ]; then
88 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
89 bc70eb79 2019-05-09 stsp return 1
90 bc70eb79 2019-05-09 stsp fi
91 bc70eb79 2019-05-09 stsp
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
94 bc70eb79 2019-05-09 stsp
95 bc70eb79 2019-05-09 stsp (cd $testroot/wt && \
96 bc70eb79 2019-05-09 stsp got commit -m 'test commit_subdir' epsilon > $testroot/stdout)
97 bc70eb79 2019-05-09 stsp
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
101 bc70eb79 2019-05-09 stsp
102 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
103 bc70eb79 2019-05-09 stsp ret="$?"
104 bc70eb79 2019-05-09 stsp if [ "$ret" != "0" ]; then
105 bc70eb79 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
106 bc70eb79 2019-05-09 stsp fi
107 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
108 bc70eb79 2019-05-09 stsp }
109 bc70eb79 2019-05-09 stsp
110 5bbcb68b 2019-05-09 stsp function test_commit_single_file {
111 5bbcb68b 2019-05-09 stsp local testroot=`test_init commit_single_file`
112 5bbcb68b 2019-05-09 stsp
113 5bbcb68b 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
114 5bbcb68b 2019-05-09 stsp ret="$?"
115 5bbcb68b 2019-05-09 stsp if [ "$ret" != "0" ]; then
116 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
117 5bbcb68b 2019-05-09 stsp return 1
118 5bbcb68b 2019-05-09 stsp fi
119 5bbcb68b 2019-05-09 stsp
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
122 5bbcb68b 2019-05-09 stsp
123 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon/zeta \
124 5bbcb68b 2019-05-09 stsp > $testroot/stdout)
125 5bbcb68b 2019-05-09 stsp
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
129 5bbcb68b 2019-05-09 stsp
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
131 5bbcb68b 2019-05-09 stsp ret="$?"
132 5bbcb68b 2019-05-09 stsp if [ "$ret" != "0" ]; then
133 5bbcb68b 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
134 5bbcb68b 2019-05-09 stsp fi
135 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
136 5bbcb68b 2019-05-09 stsp }
137 5bbcb68b 2019-05-09 stsp
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`
141 819f385b 2019-05-10 stsp
142 819f385b 2019-05-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 819f385b 2019-05-10 stsp ret="$?"
144 819f385b 2019-05-10 stsp if [ "$ret" != "0" ]; then
145 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
146 819f385b 2019-05-10 stsp return 1
147 819f385b 2019-05-10 stsp fi
148 819f385b 2019-05-10 stsp
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"
151 819f385b 2019-05-10 stsp
152 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/wt/alpha
153 819f385b 2019-05-10 stsp
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)
156 819f385b 2019-05-10 stsp
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
160 819f385b 2019-05-10 stsp
161 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
162 819f385b 2019-05-10 stsp ret="$?"
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"
166 819f385b 2019-05-10 stsp return 1
167 819f385b 2019-05-10 stsp fi
168 819f385b 2019-05-10 stsp
169 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
170 819f385b 2019-05-10 stsp ret="$?"
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"
174 f0b75401 2019-08-03 stsp return 1
175 819f385b 2019-05-10 stsp fi
176 f0b75401 2019-08-03 stsp
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)
180 f0b75401 2019-08-03 stsp
181 f0b75401 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
182 f0b75401 2019-08-03 stsp
183 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m 'changed alpha ' > $testroot/stdout)
184 f0b75401 2019-08-03 stsp ret="$?"
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"
188 f0b75401 2019-08-03 stsp return 1
189 f0b75401 2019-08-03 stsp fi
190 f0b75401 2019-08-03 stsp
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
195 f0b75401 2019-08-03 stsp ret="$?"
196 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
197 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
198 f0b75401 2019-08-03 stsp fi
199 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
200 819f385b 2019-05-10 stsp }
201 819f385b 2019-05-10 stsp
202 8ba6ba2d 2019-05-14 stsp function test_commit_added_subdirs {
203 8ba6ba2d 2019-05-14 stsp local testroot=`test_init commit_added_subdirs`
204 8ba6ba2d 2019-05-14 stsp
205 8ba6ba2d 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
206 8ba6ba2d 2019-05-14 stsp ret="$?"
207 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
208 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
209 8ba6ba2d 2019-05-14 stsp return 1
210 8ba6ba2d 2019-05-14 stsp fi
211 8ba6ba2d 2019-05-14 stsp
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
219 8ba6ba2d 2019-05-14 stsp
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)
222 8ba6ba2d 2019-05-14 stsp
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)
225 8ba6ba2d 2019-05-14 stsp
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
232 8ba6ba2d 2019-05-14 stsp
233 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
234 8ba6ba2d 2019-05-14 stsp ret="$?"
235 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
236 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
237 8ba6ba2d 2019-05-14 stsp fi
238 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
239 8ba6ba2d 2019-05-14 stsp }
240 8ba6ba2d 2019-05-14 stsp
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`
243 f363d663 2019-05-23 stsp
244 f363d663 2019-05-23 stsp local initial_rev=`git_show_head $testroot/repo`
245 f363d663 2019-05-23 stsp
246 f363d663 2019-05-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
247 f363d663 2019-05-23 stsp ret="$?"
248 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
249 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
250 f363d663 2019-05-23 stsp return 1
251 f363d663 2019-05-23 stsp fi
252 f363d663 2019-05-23 stsp
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)
255 f363d663 2019-05-23 stsp
256 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
257 f363d663 2019-05-23 stsp
258 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
259 f363d663 2019-05-23 stsp
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
264 f363d663 2019-05-23 stsp
265 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
266 f363d663 2019-05-23 stsp
267 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
268 f363d663 2019-05-23 stsp ret="$?"
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"
272 f363d663 2019-05-23 stsp return 1
273 f363d663 2019-05-23 stsp fi
274 f363d663 2019-05-23 stsp
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)
277 f363d663 2019-05-23 stsp
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
281 f363d663 2019-05-23 stsp
282 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
283 f363d663 2019-05-23 stsp ret="$?"
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"
287 f363d663 2019-05-23 stsp return 1
288 f363d663 2019-05-23 stsp fi
289 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
290 f363d663 2019-05-23 stsp ret="$?"
291 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
292 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
293 f363d663 2019-05-23 stsp fi
294 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
295 f363d663 2019-05-23 stsp }
296 1a36436d 2019-06-10 stsp
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`
299 f363d663 2019-05-23 stsp
300 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
301 1a36436d 2019-06-10 stsp ret="$?"
302 1a36436d 2019-06-10 stsp if [ "$ret" != "0" ]; then
303 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
304 1a36436d 2019-06-10 stsp return 1
305 1a36436d 2019-06-10 stsp fi
306 1a36436d 2019-06-10 stsp
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
309 1a36436d 2019-06-10 stsp
310 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
311 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
312 1a36436d 2019-06-10 stsp
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
316 1a36436d 2019-06-10 stsp
317 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
318 1a36436d 2019-06-10 stsp ret="$?"
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"
322 1a36436d 2019-06-10 stsp return 1
323 1a36436d 2019-06-10 stsp fi
324 1a36436d 2019-06-10 stsp done
325 1a36436d 2019-06-10 stsp
326 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
327 1a36436d 2019-06-10 stsp }
328 4866d084 2019-07-10 stsp
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`
331 1a36436d 2019-06-10 stsp
332 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
333 4866d084 2019-07-10 stsp ret="$?"
334 4866d084 2019-07-10 stsp if [ "$ret" != "0" ]; then
335 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
336 4866d084 2019-07-10 stsp return 1
337 4866d084 2019-07-10 stsp fi
338 4866d084 2019-07-10 stsp
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)
342 4866d084 2019-07-10 stsp
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)
346 4866d084 2019-07-10 stsp
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
351 e0233cea 2019-07-25 stsp
352 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
353 e0233cea 2019-07-25 stsp ret="$?"
354 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
355 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
356 e0233cea 2019-07-25 stsp fi
357 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
358 e0233cea 2019-07-25 stsp }
359 e0233cea 2019-07-25 stsp
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`
363 e0233cea 2019-07-25 stsp
364 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
365 e0233cea 2019-07-25 stsp ret="$?"
366 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
367 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
368 e0233cea 2019-07-25 stsp return 1
369 e0233cea 2019-07-25 stsp fi
370 e0233cea 2019-07-25 stsp
371 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
372 e0233cea 2019-07-25 stsp
373 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
374 e0233cea 2019-07-25 stsp
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
378 4866d084 2019-07-10 stsp
379 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
380 4866d084 2019-07-10 stsp ret="$?"
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"
384 e0233cea 2019-07-25 stsp return 1
385 4866d084 2019-07-10 stsp fi
386 e0233cea 2019-07-25 stsp
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
399 e0233cea 2019-07-25 stsp
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
402 e0233cea 2019-07-25 stsp ret="$?"
403 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
404 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
405 e0233cea 2019-07-25 stsp fi
406 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
407 4866d084 2019-07-10 stsp }
408 90e8619e 2019-07-25 stsp
409 90e8619e 2019-07-25 stsp function test_commit_dir_path {
410 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
411 4866d084 2019-07-10 stsp
412 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
413 90e8619e 2019-07-25 stsp ret="$?"
414 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
415 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
416 90e8619e 2019-07-25 stsp return 1
417 90e8619e 2019-07-25 stsp fi
418 90e8619e 2019-07-25 stsp
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
421 90e8619e 2019-07-25 stsp
422 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
423 90e8619e 2019-07-25 stsp > $testroot/stdout)
424 90e8619e 2019-07-25 stsp
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
428 90e8619e 2019-07-25 stsp
429 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
430 90e8619e 2019-07-25 stsp ret="$?"
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"
434 90e8619e 2019-07-25 stsp return 1
435 90e8619e 2019-07-25 stsp fi
436 90e8619e 2019-07-25 stsp
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
440 90e8619e 2019-07-25 stsp ret="$?"
441 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
442 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
443 90e8619e 2019-07-25 stsp fi
444 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
445 90e8619e 2019-07-25 stsp }
446 5c1e53bc 2019-07-28 stsp
447 5c1e53bc 2019-07-28 stsp function test_commit_selected_paths {
448 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
449 5c1e53bc 2019-07-28 stsp
450 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
451 5c1e53bc 2019-07-28 stsp ret="$?"
452 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
453 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
454 5c1e53bc 2019-07-28 stsp return 1
455 5c1e53bc 2019-07-28 stsp fi
456 5c1e53bc 2019-07-28 stsp
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)
463 90e8619e 2019-07-25 stsp
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)
466 5c1e53bc 2019-07-28 stsp ret="$?"
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"
470 5c1e53bc 2019-07-28 stsp return 1
471 5c1e53bc 2019-07-28 stsp fi
472 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
473 5c1e53bc 2019-07-28 stsp
474 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
475 5c1e53bc 2019-07-28 stsp ret="$?"
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"
479 5c1e53bc 2019-07-28 stsp return 1
480 5c1e53bc 2019-07-28 stsp fi
481 5c1e53bc 2019-07-28 stsp
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)
484 5c1e53bc 2019-07-28 stsp
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
490 5c1e53bc 2019-07-28 stsp
491 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
492 5c1e53bc 2019-07-28 stsp ret="$?"
493 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
494 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
495 5c1e53bc 2019-07-28 stsp fi
496 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
497 5c1e53bc 2019-07-28 stsp }
498 5c1e53bc 2019-07-28 stsp
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`
501 916f288c 2019-07-30 stsp
502 916f288c 2019-07-30 stsp got ref -r $testroot/repo refs/remotes/origin/master master
503 916f288c 2019-07-30 stsp
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
506 916f288c 2019-07-30 stsp ret="$?"
507 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
508 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
509 916f288c 2019-07-30 stsp return 1
510 916f288c 2019-07-30 stsp fi
511 916f288c 2019-07-30 stsp
512 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
513 916f288c 2019-07-30 stsp
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)
516 916f288c 2019-07-30 stsp ret="$?"
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"
520 916f288c 2019-07-30 stsp return 1
521 916f288c 2019-07-30 stsp fi
522 916f288c 2019-07-30 stsp
523 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
524 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
525 916f288c 2019-07-30 stsp ret="$?"
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"
529 916f288c 2019-07-30 stsp return 1
530 916f288c 2019-07-30 stsp fi
531 916f288c 2019-07-30 stsp
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
537 916f288c 2019-07-30 stsp ret="$?"
538 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
539 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
540 916f288c 2019-07-30 stsp fi
541 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
542 916f288c 2019-07-30 stsp }
543 916f288c 2019-07-30 stsp
544 84792843 2019-08-09 stsp function test_commit_no_email {
545 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
546 916f288c 2019-07-30 stsp
547 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
548 84792843 2019-08-09 stsp ret="$?"
549 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
550 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
551 84792843 2019-08-09 stsp return 1
552 84792843 2019-08-09 stsp fi
553 84792843 2019-08-09 stsp
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)
558 84792843 2019-08-09 stsp
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
565 84792843 2019-08-09 stsp ret="$?"
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"
569 84792843 2019-08-09 stsp return 1
570 84792843 2019-08-09 stsp fi
571 84792843 2019-08-09 stsp
572 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
573 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
574 84792843 2019-08-09 stsp ret="$?"
575 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
576 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
577 84792843 2019-08-09 stsp fi
578 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
579 84792843 2019-08-09 stsp }
580 6af1ccbd 2019-08-16 stsp
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`
583 6af1ccbd 2019-08-16 stsp
584 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
585 6af1ccbd 2019-08-16 stsp ret="$?"
586 6af1ccbd 2019-08-16 stsp if [ "$ret" != "0" ]; then
587 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
588 6af1ccbd 2019-08-16 stsp return 1
589 6af1ccbd 2019-08-16 stsp fi
590 6af1ccbd 2019-08-16 stsp
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)
600 84792843 2019-08-09 stsp
601 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
602 84792843 2019-08-09 stsp
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)
606 6af1ccbd 2019-08-16 stsp ret="$?"
607 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
608 6af1ccbd 2019-08-16 stsp }
609 aba9c984 2019-09-08 stsp
610 aba9c984 2019-09-08 stsp function test_commit_gitconfig_author {
611 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
612 84792843 2019-08-09 stsp
613 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
614 aba9c984 2019-09-08 stsp ret="$?"
615 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
616 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
617 aba9c984 2019-09-08 stsp return 1
618 aba9c984 2019-09-08 stsp fi
619 aba9c984 2019-09-08 stsp
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')
622 aba9c984 2019-09-08 stsp
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)
625 aba9c984 2019-09-08 stsp ret="$?"
626 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
627 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
628 aba9c984 2019-09-08 stsp return 1
629 aba9c984 2019-09-08 stsp fi
630 aba9c984 2019-09-08 stsp
631 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
632 aba9c984 2019-09-08 stsp ret="$?"
633 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
634 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
635 aba9c984 2019-09-08 stsp return 1
636 aba9c984 2019-09-08 stsp fi
637 aba9c984 2019-09-08 stsp
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
641 aba9c984 2019-09-08 stsp ret="$?"
642 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
643 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
644 aba9c984 2019-09-08 stsp fi
645 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
646 aba9c984 2019-09-08 stsp }
647 1ebedb77 2019-10-19 stsp
648 1ebedb77 2019-10-19 stsp function test_commit_xbit_change {
649 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
650 1ebedb77 2019-10-19 stsp
651 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
652 1ebedb77 2019-10-19 stsp ret="$?"
653 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
654 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
655 1ebedb77 2019-10-19 stsp return 1
656 1ebedb77 2019-10-19 stsp fi
657 1ebedb77 2019-10-19 stsp
658 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
659 1ebedb77 2019-10-19 stsp
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)
662 aba9c984 2019-09-08 stsp
663 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
664 1ebedb77 2019-10-19 stsp ret="$?"
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"
668 1ebedb77 2019-10-19 stsp return 1
669 1ebedb77 2019-10-19 stsp fi
670 1ebedb77 2019-10-19 stsp
671 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
672 1ebedb77 2019-10-19 stsp ret="$?"
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"
676 1ebedb77 2019-10-19 stsp return 1
677 1ebedb77 2019-10-19 stsp fi
678 1ebedb77 2019-10-19 stsp
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
683 1ebedb77 2019-10-19 stsp ret="$?"
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"
687 1ebedb77 2019-10-19 stsp return 1
688 1ebedb77 2019-10-19 stsp fi
689 1ebedb77 2019-10-19 stsp
690 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
691 1ebedb77 2019-10-19 stsp
692 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
693 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
694 1ebedb77 2019-10-19 stsp ret="$?"
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"
698 1ebedb77 2019-10-19 stsp return 1
699 1ebedb77 2019-10-19 stsp fi
700 1ebedb77 2019-10-19 stsp
701 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
702 1ebedb77 2019-10-19 stsp
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)
705 1ebedb77 2019-10-19 stsp
706 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
707 1ebedb77 2019-10-19 stsp ret="$?"
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"
711 1ebedb77 2019-10-19 stsp return 1
712 1ebedb77 2019-10-19 stsp fi
713 1ebedb77 2019-10-19 stsp
714 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
715 1ebedb77 2019-10-19 stsp ret="$?"
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"
719 1ebedb77 2019-10-19 stsp return 1
720 1ebedb77 2019-10-19 stsp fi
721 1ebedb77 2019-10-19 stsp
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
726 1ebedb77 2019-10-19 stsp ret="$?"
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"
730 1ebedb77 2019-10-19 stsp return 1
731 1ebedb77 2019-10-19 stsp fi
732 1ebedb77 2019-10-19 stsp
733 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
734 1ebedb77 2019-10-19 stsp
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)
737 1ebedb77 2019-10-19 stsp
738 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
739 1ebedb77 2019-10-19 stsp ret="$?"
740 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
741 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
742 1ebedb77 2019-10-19 stsp fi
743 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
744 1ebedb77 2019-10-19 stsp }
745 1ebedb77 2019-10-19 stsp
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