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 f6cae3ed 2020-09-13 naddy 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 fc414659 2022-04-16 thomas ret=$?
24 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
44 fc414659 2022-04-16 thomas if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 fc414659 2022-04-16 thomas ret=$?
55 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
76 fc414659 2022-04-16 thomas if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 fc414659 2022-04-16 thomas ret=$?
87 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
104 fc414659 2022-04-16 thomas if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 fc414659 2022-04-16 thomas ret=$?
115 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
132 fc414659 2022-04-16 thomas if [ $ret -ne 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 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`
141 819f385b 2019-05-10 stsp
142 819f385b 2019-05-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 fc414659 2022-04-16 thomas ret=$?
144 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
163 fc414659 2022-04-16 thomas 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"
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 fc414659 2022-04-16 thomas ret=$?
171 fc414659 2022-04-16 thomas 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"
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 fc414659 2022-04-16 thomas ret=$?
185 fc414659 2022-04-16 thomas 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"
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 fc414659 2022-04-16 thomas ret=$?
196 fc414659 2022-04-16 thomas if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 fc414659 2022-04-16 thomas ret=$?
207 fc414659 2022-04-16 thomas if [ $ret -ne 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 ba580f68 2020-03-22 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
232 ba580f68 2020-03-22 stsp
233 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
234 fc414659 2022-04-16 thomas ret=$?
235 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
236 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
237 ba580f68 2020-03-22 stsp fi
238 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
239 ba580f68 2020-03-22 stsp }
240 ba580f68 2020-03-22 stsp
241 f6cae3ed 2020-09-13 naddy test_commit_deleted_subdirs() {
242 ba580f68 2020-03-22 stsp local testroot=`test_init commit_deleted_subdirs`
243 ba580f68 2020-03-22 stsp
244 ba580f68 2020-03-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
245 fc414659 2022-04-16 thomas ret=$?
246 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
247 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
248 ba580f68 2020-03-22 stsp return 1
249 ba580f68 2020-03-22 stsp fi
250 ba580f68 2020-03-22 stsp
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)
253 ba580f68 2020-03-22 stsp
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)
256 ba580f68 2020-03-22 stsp
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
261 ba580f68 2020-03-22 stsp
262 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
263 fc414659 2022-04-16 thomas ret=$?
264 fc414659 2022-04-16 thomas 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"
267 ba580f68 2020-03-22 stsp return 1
268 ba580f68 2020-03-22 stsp fi
269 8ba6ba2d 2019-05-14 stsp
270 ba580f68 2020-03-22 stsp got tree -r $testroot/repo > $testroot/stdout
271 ba580f68 2020-03-22 stsp
272 ba580f68 2020-03-22 stsp echo "alpha" > $testroot/stdout.expected
273 ba580f68 2020-03-22 stsp echo "beta" >> $testroot/stdout.expected
274 ba580f68 2020-03-22 stsp
275 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
276 fc414659 2022-04-16 thomas ret=$?
277 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
278 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
279 8ba6ba2d 2019-05-14 stsp fi
280 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
281 8ba6ba2d 2019-05-14 stsp }
282 8ba6ba2d 2019-05-14 stsp
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`
285 f363d663 2019-05-23 stsp
286 f363d663 2019-05-23 stsp local initial_rev=`git_show_head $testroot/repo`
287 f363d663 2019-05-23 stsp
288 f363d663 2019-05-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
289 fc414659 2022-04-16 thomas ret=$?
290 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
291 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
292 f363d663 2019-05-23 stsp return 1
293 f363d663 2019-05-23 stsp fi
294 f363d663 2019-05-23 stsp
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 f363d663 2019-05-23 stsp
298 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
299 f363d663 2019-05-23 stsp
300 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
301 f363d663 2019-05-23 stsp
302 f363d663 2019-05-23 stsp echo "C alpha" > $testroot/stdout.expected
303 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
304 f363d663 2019-05-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
305 f363d663 2019-05-23 stsp echo >> $testroot/stdout.expected
306 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
307 f363d663 2019-05-23 stsp
308 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
309 f363d663 2019-05-23 stsp
310 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
311 fc414659 2022-04-16 thomas ret=$?
312 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
313 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
314 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
315 f363d663 2019-05-23 stsp return 1
316 f363d663 2019-05-23 stsp fi
317 f363d663 2019-05-23 stsp
318 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
319 f363d663 2019-05-23 stsp 2> $testroot/stderr)
320 f363d663 2019-05-23 stsp
321 f363d663 2019-05-23 stsp echo -n > $testroot/stdout.expected
322 f363d663 2019-05-23 stsp echo "got: cannot commit file in conflicted status" \
323 f363d663 2019-05-23 stsp > $testroot/stderr.expected
324 f363d663 2019-05-23 stsp
325 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
326 fc414659 2022-04-16 thomas ret=$?
327 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
328 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
329 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
330 f363d663 2019-05-23 stsp return 1
331 f363d663 2019-05-23 stsp fi
332 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
333 fc414659 2022-04-16 thomas ret=$?
334 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
335 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
336 f363d663 2019-05-23 stsp fi
337 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
338 f363d663 2019-05-23 stsp }
339 1a36436d 2019-06-10 stsp
340 f6cae3ed 2020-09-13 naddy test_commit_single_file_multiple() {
341 1a36436d 2019-06-10 stsp local testroot=`test_init commit_single_file_multiple`
342 f363d663 2019-05-23 stsp
343 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
344 fc414659 2022-04-16 thomas ret=$?
345 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
346 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
347 1a36436d 2019-06-10 stsp return 1
348 1a36436d 2019-06-10 stsp fi
349 1a36436d 2019-06-10 stsp
350 1a36436d 2019-06-10 stsp for i in 1 2 3 4; do
351 1a36436d 2019-06-10 stsp echo "modified alpha" >> $testroot/wt/alpha
352 1a36436d 2019-06-10 stsp
353 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
354 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
355 1a36436d 2019-06-10 stsp
356 1a36436d 2019-06-10 stsp local head_rev=`git_show_head $testroot/repo`
357 1a36436d 2019-06-10 stsp echo "M alpha" > $testroot/stdout.expected
358 1a36436d 2019-06-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
359 1a36436d 2019-06-10 stsp
360 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
361 fc414659 2022-04-16 thomas ret=$?
362 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
363 1a36436d 2019-06-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
364 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
365 1a36436d 2019-06-10 stsp return 1
366 1a36436d 2019-06-10 stsp fi
367 1a36436d 2019-06-10 stsp done
368 1a36436d 2019-06-10 stsp
369 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
370 1a36436d 2019-06-10 stsp }
371 4866d084 2019-07-10 stsp
372 f6cae3ed 2020-09-13 naddy test_commit_added_and_modified_in_same_dir() {
373 4866d084 2019-07-10 stsp local testroot=`test_init commit_added_and_modified_in_same_dir`
374 1a36436d 2019-06-10 stsp
375 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
376 fc414659 2022-04-16 thomas ret=$?
377 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
378 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
379 4866d084 2019-07-10 stsp return 1
380 4866d084 2019-07-10 stsp fi
381 4866d084 2019-07-10 stsp
382 4866d084 2019-07-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
383 4866d084 2019-07-10 stsp echo "new file" > $testroot/wt/epsilon/new
384 4866d084 2019-07-10 stsp (cd $testroot/wt && got add epsilon/new >/dev/null)
385 4866d084 2019-07-10 stsp
386 4866d084 2019-07-10 stsp (cd $testroot/wt && got commit \
387 4866d084 2019-07-10 stsp -m 'added and modified in same dir' > $testroot/stdout \
388 4866d084 2019-07-10 stsp 2> $testroot/stderr)
389 4866d084 2019-07-10 stsp
390 4866d084 2019-07-10 stsp local head_rev=`git_show_head $testroot/repo`
391 4866d084 2019-07-10 stsp echo "A epsilon/new" > $testroot/stdout.expected
392 4866d084 2019-07-10 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
393 4866d084 2019-07-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
394 e0233cea 2019-07-25 stsp
395 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
396 fc414659 2022-04-16 thomas ret=$?
397 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
398 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
399 e0233cea 2019-07-25 stsp fi
400 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
401 e0233cea 2019-07-25 stsp }
402 e0233cea 2019-07-25 stsp
403 f6cae3ed 2020-09-13 naddy test_commit_path_prefix() {
404 e0233cea 2019-07-25 stsp local testroot=`test_init commit_path_prefix`
405 e0233cea 2019-07-25 stsp local commit1=`git_show_head $testroot/repo`
406 e0233cea 2019-07-25 stsp
407 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
408 fc414659 2022-04-16 thomas ret=$?
409 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
410 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
411 e0233cea 2019-07-25 stsp return 1
412 e0233cea 2019-07-25 stsp fi
413 e0233cea 2019-07-25 stsp
414 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
415 e0233cea 2019-07-25 stsp
416 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
417 e0233cea 2019-07-25 stsp
418 e0233cea 2019-07-25 stsp local commit2=`git_show_head $testroot/repo`
419 e0233cea 2019-07-25 stsp echo "M delta" > $testroot/stdout.expected
420 e0233cea 2019-07-25 stsp echo "Created commit $commit2" >> $testroot/stdout.expected
421 4866d084 2019-07-10 stsp
422 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
423 fc414659 2022-04-16 thomas ret=$?
424 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
425 2b496619 2019-07-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
426 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
427 e0233cea 2019-07-25 stsp return 1
428 4866d084 2019-07-10 stsp fi
429 e0233cea 2019-07-25 stsp
430 e0233cea 2019-07-25 stsp echo "diff $commit1 $commit2" > $testroot/stdout.expected
431 9b4458b4 2022-06-26 thomas echo "commit - $commit1" >> $testroot/stdout.expected
432 9b4458b4 2022-06-26 thomas echo "commit + $commit2" >> $testroot/stdout.expected
433 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
434 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
435 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $testroot/stdout.expected
436 e0233cea 2019-07-25 stsp echo -n 'blob + ' >> $testroot/stdout.expected
437 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
438 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
439 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
440 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
441 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
442 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
443 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
444 e0233cea 2019-07-25 stsp
445 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
446 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
447 fc414659 2022-04-16 thomas ret=$?
448 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
449 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
450 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
451 f2b0a8b0 2020-07-31 stsp return 1
452 f2b0a8b0 2020-07-31 stsp fi
453 f2b0a8b0 2020-07-31 stsp
454 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got rm delta > /dev/null)
455 f2b0a8b0 2020-07-31 stsp echo new > $testroot/wt/new
456 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got add new > /dev/null)
457 f2b0a8b0 2020-07-31 stsp
458 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
459 f2b0a8b0 2020-07-31 stsp > $testroot/stdout)
460 f2b0a8b0 2020-07-31 stsp
461 f2b0a8b0 2020-07-31 stsp local commit3=`git_show_head $testroot/repo`
462 f2b0a8b0 2020-07-31 stsp echo "A new" > $testroot/stdout.expected
463 f2b0a8b0 2020-07-31 stsp echo "D delta" >> $testroot/stdout.expected
464 f2b0a8b0 2020-07-31 stsp echo "Created commit $commit3" >> $testroot/stdout.expected
465 f2b0a8b0 2020-07-31 stsp
466 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
467 fc414659 2022-04-16 thomas ret=$?
468 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
469 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
470 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
471 f2b0a8b0 2020-07-31 stsp return 1
472 f2b0a8b0 2020-07-31 stsp fi
473 f2b0a8b0 2020-07-31 stsp
474 f2b0a8b0 2020-07-31 stsp echo "diff $commit2 $commit3" > $testroot/stdout.expected
475 9b4458b4 2022-06-26 thomas echo "commit - $commit2" >> $testroot/stdout.expected
476 9b4458b4 2022-06-26 thomas echo "commit + $commit3" >> $testroot/stdout.expected
477 f2b0a8b0 2020-07-31 stsp echo -n 'blob - ' >> $testroot/stdout.expected
478 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
479 f2b0a8b0 2020-07-31 stsp | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
480 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
481 f2b0a8b0 2020-07-31 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
482 f2b0a8b0 2020-07-31 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
483 f2b0a8b0 2020-07-31 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
484 f2b0a8b0 2020-07-31 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
485 f2b0a8b0 2020-07-31 stsp echo '-modified delta' >> $testroot/stdout.expected
486 f2b0a8b0 2020-07-31 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
487 f2b0a8b0 2020-07-31 stsp echo -n 'blob + ' >> $testroot/stdout.expected
488 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
489 f2b0a8b0 2020-07-31 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
490 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
491 f2b0a8b0 2020-07-31 stsp echo '--- /dev/null' >> $testroot/stdout.expected
492 f2b0a8b0 2020-07-31 stsp echo '+++ gamma/new' >> $testroot/stdout.expected
493 f2b0a8b0 2020-07-31 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
494 f2b0a8b0 2020-07-31 stsp echo '+new' >> $testroot/stdout.expected
495 f2b0a8b0 2020-07-31 stsp
496 f2b0a8b0 2020-07-31 stsp got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
497 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
498 fc414659 2022-04-16 thomas ret=$?
499 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
500 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
501 e0233cea 2019-07-25 stsp fi
502 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
503 f2b0a8b0 2020-07-31 stsp return "$ret"
504 4866d084 2019-07-10 stsp }
505 90e8619e 2019-07-25 stsp
506 f6cae3ed 2020-09-13 naddy test_commit_dir_path() {
507 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
508 4866d084 2019-07-10 stsp
509 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
510 fc414659 2022-04-16 thomas ret=$?
511 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
512 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
513 90e8619e 2019-07-25 stsp return 1
514 90e8619e 2019-07-25 stsp fi
515 90e8619e 2019-07-25 stsp
516 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
517 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
518 90e8619e 2019-07-25 stsp
519 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
520 90e8619e 2019-07-25 stsp > $testroot/stdout)
521 90e8619e 2019-07-25 stsp
522 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
523 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
524 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
525 90e8619e 2019-07-25 stsp
526 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
527 fc414659 2022-04-16 thomas ret=$?
528 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
529 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
530 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
531 90e8619e 2019-07-25 stsp return 1
532 90e8619e 2019-07-25 stsp fi
533 90e8619e 2019-07-25 stsp
534 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
535 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
536 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
537 fc414659 2022-04-16 thomas ret=$?
538 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
539 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
540 90e8619e 2019-07-25 stsp fi
541 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
542 90e8619e 2019-07-25 stsp }
543 5c1e53bc 2019-07-28 stsp
544 f6cae3ed 2020-09-13 naddy test_commit_selected_paths() {
545 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
546 5c1e53bc 2019-07-28 stsp
547 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
548 fc414659 2022-04-16 thomas ret=$?
549 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
550 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
551 5c1e53bc 2019-07-28 stsp return 1
552 5c1e53bc 2019-07-28 stsp fi
553 5c1e53bc 2019-07-28 stsp
554 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
555 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
556 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
557 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
558 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
559 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
560 90e8619e 2019-07-25 stsp
561 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
562 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
563 fc414659 2022-04-16 thomas ret=$?
564 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
565 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
566 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
567 5c1e53bc 2019-07-28 stsp return 1
568 5c1e53bc 2019-07-28 stsp fi
569 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
570 5c1e53bc 2019-07-28 stsp
571 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
572 fc414659 2022-04-16 thomas ret=$?
573 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
574 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
575 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
576 5c1e53bc 2019-07-28 stsp return 1
577 5c1e53bc 2019-07-28 stsp fi
578 5c1e53bc 2019-07-28 stsp
579 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
580 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
581 5c1e53bc 2019-07-28 stsp
582 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
583 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
584 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
585 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
586 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
587 5c1e53bc 2019-07-28 stsp
588 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
589 fc414659 2022-04-16 thomas ret=$?
590 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
591 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
592 5c1e53bc 2019-07-28 stsp fi
593 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
594 5c1e53bc 2019-07-28 stsp }
595 5c1e53bc 2019-07-28 stsp
596 f6cae3ed 2020-09-13 naddy test_commit_outside_refs_heads() {
597 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
598 916f288c 2019-07-30 stsp
599 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
600 916f288c 2019-07-30 stsp
601 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
602 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
603 fc414659 2022-04-16 thomas ret=$?
604 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
605 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
606 916f288c 2019-07-30 stsp return 1
607 916f288c 2019-07-30 stsp fi
608 916f288c 2019-07-30 stsp
609 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
610 916f288c 2019-07-30 stsp
611 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
612 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
613 fc414659 2022-04-16 thomas ret=$?
614 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
615 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
616 916f288c 2019-07-30 stsp test_done "$testroot" "1"
617 916f288c 2019-07-30 stsp return 1
618 916f288c 2019-07-30 stsp fi
619 916f288c 2019-07-30 stsp
620 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
621 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
622 fc414659 2022-04-16 thomas ret=$?
623 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
624 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
625 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
626 916f288c 2019-07-30 stsp return 1
627 916f288c 2019-07-30 stsp fi
628 916f288c 2019-07-30 stsp
629 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
630 916f288c 2019-07-30 stsp > $testroot/stderr.expected
631 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
632 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
633 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
634 fc414659 2022-04-16 thomas ret=$?
635 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
636 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
637 916f288c 2019-07-30 stsp fi
638 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
639 916f288c 2019-07-30 stsp }
640 916f288c 2019-07-30 stsp
641 f6cae3ed 2020-09-13 naddy test_commit_no_email() {
642 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
643 ec9b5f0b 2022-07-19 thomas local errmsg=""
644 ec9b5f0b 2022-07-19 thomas
645 ec9b5f0b 2022-07-19 thomas errmsg="commit author's email address is required for"
646 ec9b5f0b 2022-07-19 thomas errmsg="$errmsg compatibility with Git"
647 916f288c 2019-07-30 stsp
648 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
649 fc414659 2022-04-16 thomas ret=$?
650 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
651 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
652 84792843 2019-08-09 stsp return 1
653 84792843 2019-08-09 stsp fi
654 84792843 2019-08-09 stsp
655 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
656 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
657 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
658 84792843 2019-08-09 stsp 2> $testroot/stderr)
659 84792843 2019-08-09 stsp
660 ec9b5f0b 2022-07-19 thomas printf "got: :flan_hacker:: %s\n" "$errmsg" > $testroot/stderr.expected
661 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
662 fc414659 2022-04-16 thomas ret=$?
663 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
664 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
665 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
666 84792843 2019-08-09 stsp return 1
667 84792843 2019-08-09 stsp fi
668 84792843 2019-08-09 stsp
669 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
670 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
671 fc414659 2022-04-16 thomas ret=$?
672 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
673 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
674 ec9b5f0b 2022-07-19 thomas test_done "$testroot" $ret
675 ec9b5f0b 2022-07-19 thomas return 1
676 84792843 2019-08-09 stsp fi
677 ec9b5f0b 2022-07-19 thomas
678 ec9b5f0b 2022-07-19 thomas # try again with a newline inside the email
679 ec9b5f0b 2022-07-19 thomas (cd $testroot/wt \
680 ec9b5f0b 2022-07-19 thomas && FS=' ' env GOT_AUTHOR="$(printf "Flan <hack\ner>")" \
681 ec9b5f0b 2022-07-19 thomas got commit -m 'test invalid email' > $testroot/stdout \
682 ec9b5f0b 2022-07-19 thomas 2> $testroot/stderr)
683 ec9b5f0b 2022-07-19 thomas
684 ec9b5f0b 2022-07-19 thomas printf "got: Flan <hack\ner>: %s\n" "$errmsg" \
685 ec9b5f0b 2022-07-19 thomas > $testroot/stderr.expected
686 ec9b5f0b 2022-07-19 thomas cmp -s $testroot/stderr.expected $testroot/stderr
687 ec9b5f0b 2022-07-19 thomas ret=$?
688 ec9b5f0b 2022-07-19 thomas if [ $ret -ne 0 ]; then
689 ec9b5f0b 2022-07-19 thomas diff -u $testroot/stderr.expected $testroot/stderr
690 ec9b5f0b 2022-07-19 thomas test_done "$testroot" $ret
691 ec9b5f0b 2022-07-19 thomas return 1
692 ec9b5f0b 2022-07-19 thomas fi
693 ec9b5f0b 2022-07-19 thomas
694 ec9b5f0b 2022-07-19 thomas echo -n > $testroot/stdout.expected
695 ec9b5f0b 2022-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
696 ec9b5f0b 2022-07-19 thomas ret=$?
697 ec9b5f0b 2022-07-19 thomas if [ $ret -ne 0 ]; then
698 ec9b5f0b 2022-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
699 ec9b5f0b 2022-07-19 thomas test_done "$testroot" $ret
700 ec9b5f0b 2022-07-19 thomas return 1
701 ec9b5f0b 2022-07-19 thomas fi
702 ec9b5f0b 2022-07-19 thomas
703 ec9b5f0b 2022-07-19 thomas # try again with a < inside the email
704 ec9b5f0b 2022-07-19 thomas (cd $testroot/wt && env GOT_AUTHOR="$(printf "Flan <ha<ker>")" \
705 ec9b5f0b 2022-07-19 thomas got commit -m 'test invalid email' > $testroot/stdout \
706 ec9b5f0b 2022-07-19 thomas 2> $testroot/stderr)
707 ec9b5f0b 2022-07-19 thomas
708 ec9b5f0b 2022-07-19 thomas printf "got: Flan <ha<ker>: %s\n" "$errmsg" > $testroot/stderr.expected
709 ec9b5f0b 2022-07-19 thomas cmp -s $testroot/stderr.expected $testroot/stderr
710 ec9b5f0b 2022-07-19 thomas ret=$?
711 ec9b5f0b 2022-07-19 thomas if [ $ret -ne 0 ]; then
712 ec9b5f0b 2022-07-19 thomas diff -u $testroot/stderr.expected $testroot/stderr
713 ec9b5f0b 2022-07-19 thomas test_done "$testroot" $ret
714 ec9b5f0b 2022-07-19 thomas return 1
715 ec9b5f0b 2022-07-19 thomas fi
716 ec9b5f0b 2022-07-19 thomas
717 ec9b5f0b 2022-07-19 thomas echo -n > $testroot/stdout.expected
718 ec9b5f0b 2022-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
719 ec9b5f0b 2022-07-19 thomas ret=$?
720 ec9b5f0b 2022-07-19 thomas if [ $ret -ne 0 ]; then
721 ec9b5f0b 2022-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
722 ec9b5f0b 2022-07-19 thomas fi
723 ec9b5f0b 2022-07-19 thomas test_done "$testroot" $ret
724 84792843 2019-08-09 stsp }
725 6af1ccbd 2019-08-16 stsp
726 f6cae3ed 2020-09-13 naddy test_commit_tree_entry_sorting() {
727 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
728 6af1ccbd 2019-08-16 stsp
729 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
730 fc414659 2022-04-16 thomas ret=$?
731 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
732 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
733 6af1ccbd 2019-08-16 stsp return 1
734 6af1ccbd 2019-08-16 stsp fi
735 6af1ccbd 2019-08-16 stsp
736 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
737 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
738 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
739 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
740 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
741 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
742 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
743 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
744 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
745 84792843 2019-08-09 stsp
746 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
747 84792843 2019-08-09 stsp
748 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
749 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
750 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
751 fc414659 2022-04-16 thomas ret=$?
752 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
753 18d1acad 2022-07-20 thomas }
754 18d1acad 2022-07-20 thomas
755 18d1acad 2022-07-20 thomas test_commit_cmdline_author() {
756 18d1acad 2022-07-20 thomas local testroot=`test_init commit_cmdline_author`
757 18d1acad 2022-07-20 thomas
758 18d1acad 2022-07-20 thomas got checkout $testroot/repo $testroot/wt > /dev/null
759 18d1acad 2022-07-20 thomas ret=$?
760 18d1acad 2022-07-20 thomas if [ $ret -ne 0 ]; then
761 18d1acad 2022-07-20 thomas test_done "$testroot" $ret
762 18d1acad 2022-07-20 thomas return 1
763 18d1acad 2022-07-20 thomas fi
764 18d1acad 2022-07-20 thomas
765 18d1acad 2022-07-20 thomas echo "modified alpha" > $testroot/wt/alpha
766 18d1acad 2022-07-20 thomas
767 18d1acad 2022-07-20 thomas # first try with a -A equals to $GOT_AUTHOR
768 18d1acad 2022-07-20 thomas (cd $testroot/wt && got commit -A "$GOT_AUTHOR" -m 'edit alpha') \
769 18d1acad 2022-07-20 thomas > /dev/null 2> $testroot/stderr
770 18d1acad 2022-07-20 thomas ret=$?
771 18d1acad 2022-07-20 thomas if [ $ret -eq 0 ]; then
772 18d1acad 2022-07-20 thomas test_done "$testroot" 1
773 18d1acad 2022-07-20 thomas return 1
774 18d1acad 2022-07-20 thomas fi
775 18d1acad 2022-07-20 thomas
776 18d1acad 2022-07-20 thomas echo 'got: specified author is equal to the default one' \
777 18d1acad 2022-07-20 thomas > $testroot/stderr.expected
778 18d1acad 2022-07-20 thomas cmp -s $testroot/stderr.expected $testroot/stderr
779 18d1acad 2022-07-20 thomas ret=$?
780 18d1acad 2022-07-20 thomas if [ $ret -ne 0 ]; then
781 18d1acad 2022-07-20 thomas diff -u $testroot/stderr.expected $testroot/stderr
782 18d1acad 2022-07-20 thomas test_done "$testroot" $ret
783 18d1acad 2022-07-20 thomas return 1
784 18d1acad 2022-07-20 thomas fi
785 18d1acad 2022-07-20 thomas
786 18d1acad 2022-07-20 thomas # try again with a different author
787 18d1acad 2022-07-20 thomas local author="Foo <foo@example.com>"
788 18d1acad 2022-07-20 thomas (cd $testroot/wt && got commit -A "$author" -m 'edit alpha') \
789 18d1acad 2022-07-20 thomas > /dev/null
790 18d1acad 2022-07-20 thomas ret=$?
791 18d1acad 2022-07-20 thomas if [ $ret -ne 0 ]; then
792 18d1acad 2022-07-20 thomas test_done "$testroot" $ret
793 18d1acad 2022-07-20 thomas return 1
794 18d1acad 2022-07-20 thomas fi
795 18d1acad 2022-07-20 thomas
796 18d1acad 2022-07-20 thomas (cd $testroot/repo && got log -l1 | egrep '^(from|via):') \
797 18d1acad 2022-07-20 thomas > $testroot/stdout
798 18d1acad 2022-07-20 thomas ret=$?
799 18d1acad 2022-07-20 thomas if [ $ret -ne 0 ]; then
800 18d1acad 2022-07-20 thomas test_done "$testroot" $ret
801 18d1acad 2022-07-20 thomas return 1
802 18d1acad 2022-07-20 thomas fi
803 18d1acad 2022-07-20 thomas
804 18d1acad 2022-07-20 thomas echo "from: $author" > $testroot/stdout.expected
805 18d1acad 2022-07-20 thomas echo "via: $GOT_AUTHOR" >> $testroot/stdout.expected
806 18d1acad 2022-07-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
807 18d1acad 2022-07-20 thomas ret=$?
808 18d1acad 2022-07-20 thomas if [ $ret -ne 0 ]; then
809 18d1acad 2022-07-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
810 18d1acad 2022-07-20 thomas fi
811 18d1acad 2022-07-20 thomas test_done "$testroot" $ret
812 257add31 2020-09-09 stsp }
813 257add31 2020-09-09 stsp
814 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_author() {
815 257add31 2020-09-09 stsp local testroot=`test_init commit_gotconfig_author`
816 257add31 2020-09-09 stsp
817 257add31 2020-09-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
818 fc414659 2022-04-16 thomas ret=$?
819 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
820 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
821 257add31 2020-09-09 stsp return 1
822 257add31 2020-09-09 stsp fi
823 257add31 2020-09-09 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
824 257add31 2020-09-09 stsp > $testroot/repo/.git/got.conf
825 257add31 2020-09-09 stsp
826 257add31 2020-09-09 stsp echo "modified alpha" > $testroot/wt/alpha
827 257add31 2020-09-09 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
828 fc414659 2022-04-16 thomas ret=$?
829 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
830 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
831 257add31 2020-09-09 stsp return 1
832 257add31 2020-09-09 stsp fi
833 257add31 2020-09-09 stsp
834 257add31 2020-09-09 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
835 fc414659 2022-04-16 thomas ret=$?
836 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
837 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
838 257add31 2020-09-09 stsp return 1
839 257add31 2020-09-09 stsp fi
840 257add31 2020-09-09 stsp
841 257add31 2020-09-09 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
842 50b0790e 2020-09-11 stsp > $testroot/stdout.expected
843 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
844 fc414659 2022-04-16 thomas ret=$?
845 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
846 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
847 50b0790e 2020-09-11 stsp fi
848 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
849 50b0790e 2020-09-11 stsp }
850 50b0790e 2020-09-11 stsp
851 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_worktree_author() {
852 50b0790e 2020-09-11 stsp local testroot=`test_init commit_gotconfig_worktree_author`
853 50b0790e 2020-09-11 stsp
854 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
855 fc414659 2022-04-16 thomas ret=$?
856 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
857 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
858 50b0790e 2020-09-11 stsp return 1
859 50b0790e 2020-09-11 stsp fi
860 50b0790e 2020-09-11 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
861 50b0790e 2020-09-11 stsp > $testroot/repo/.git/got.conf
862 50b0790e 2020-09-11 stsp echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
863 50b0790e 2020-09-11 stsp > $testroot/wt/.got/got.conf
864 50b0790e 2020-09-11 stsp
865 50b0790e 2020-09-11 stsp echo "modified alpha" > $testroot/wt/alpha
866 50b0790e 2020-09-11 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
867 fc414659 2022-04-16 thomas ret=$?
868 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
869 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
870 50b0790e 2020-09-11 stsp return 1
871 50b0790e 2020-09-11 stsp fi
872 50b0790e 2020-09-11 stsp
873 50b0790e 2020-09-11 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
874 fc414659 2022-04-16 thomas ret=$?
875 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
876 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
877 50b0790e 2020-09-11 stsp return 1
878 50b0790e 2020-09-11 stsp fi
879 50b0790e 2020-09-11 stsp
880 50b0790e 2020-09-11 stsp echo "from: Flan Squee <flan_squee@openbsd.org>" \
881 257add31 2020-09-09 stsp > $testroot/stdout.expected
882 257add31 2020-09-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
883 fc414659 2022-04-16 thomas ret=$?
884 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
885 257add31 2020-09-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
886 257add31 2020-09-09 stsp fi
887 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
888 6af1ccbd 2019-08-16 stsp }
889 aba9c984 2019-09-08 stsp
890 f6cae3ed 2020-09-13 naddy test_commit_gitconfig_author() {
891 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
892 84792843 2019-08-09 stsp
893 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
894 fc414659 2022-04-16 thomas ret=$?
895 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
896 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
897 aba9c984 2019-09-08 stsp return 1
898 aba9c984 2019-09-08 stsp fi
899 aba9c984 2019-09-08 stsp
900 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
901 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
902 aba9c984 2019-09-08 stsp
903 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
904 aba9c984 2019-09-08 stsp (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
905 fc414659 2022-04-16 thomas ret=$?
906 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
907 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
908 aba9c984 2019-09-08 stsp return 1
909 aba9c984 2019-09-08 stsp fi
910 aba9c984 2019-09-08 stsp
911 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
912 fc414659 2022-04-16 thomas ret=$?
913 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
914 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
915 aba9c984 2019-09-08 stsp return 1
916 aba9c984 2019-09-08 stsp fi
917 aba9c984 2019-09-08 stsp
918 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
919 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
920 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
921 fc414659 2022-04-16 thomas ret=$?
922 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
923 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
924 aba9c984 2019-09-08 stsp fi
925 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
926 aba9c984 2019-09-08 stsp }
927 1ebedb77 2019-10-19 stsp
928 f6cae3ed 2020-09-13 naddy test_commit_xbit_change() {
929 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
930 1ebedb77 2019-10-19 stsp
931 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
932 fc414659 2022-04-16 thomas ret=$?
933 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
934 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
935 1ebedb77 2019-10-19 stsp return 1
936 1ebedb77 2019-10-19 stsp fi
937 1ebedb77 2019-10-19 stsp
938 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
939 1ebedb77 2019-10-19 stsp
940 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
941 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
942 aba9c984 2019-09-08 stsp
943 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
944 fc414659 2022-04-16 thomas ret=$?
945 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
946 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
947 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
948 1ebedb77 2019-10-19 stsp return 1
949 1ebedb77 2019-10-19 stsp fi
950 1ebedb77 2019-10-19 stsp
951 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
952 fc414659 2022-04-16 thomas ret=$?
953 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
954 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
955 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
956 1ebedb77 2019-10-19 stsp return 1
957 1ebedb77 2019-10-19 stsp fi
958 1ebedb77 2019-10-19 stsp
959 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
960 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
961 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
962 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
963 fc414659 2022-04-16 thomas ret=$?
964 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
965 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
966 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
967 1ebedb77 2019-10-19 stsp return 1
968 1ebedb77 2019-10-19 stsp fi
969 1ebedb77 2019-10-19 stsp
970 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
971 1ebedb77 2019-10-19 stsp
972 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
973 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
974 fc414659 2022-04-16 thomas ret=$?
975 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
976 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
977 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
978 1ebedb77 2019-10-19 stsp return 1
979 1ebedb77 2019-10-19 stsp fi
980 1ebedb77 2019-10-19 stsp
981 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
982 1ebedb77 2019-10-19 stsp
983 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
984 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
985 1ebedb77 2019-10-19 stsp
986 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
987 fc414659 2022-04-16 thomas ret=$?
988 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
989 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
990 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
991 1ebedb77 2019-10-19 stsp return 1
992 1ebedb77 2019-10-19 stsp fi
993 1ebedb77 2019-10-19 stsp
994 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
995 fc414659 2022-04-16 thomas ret=$?
996 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
997 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
998 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
999 1ebedb77 2019-10-19 stsp return 1
1000 1ebedb77 2019-10-19 stsp fi
1001 1ebedb77 2019-10-19 stsp
1002 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
1003 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1004 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1005 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1006 fc414659 2022-04-16 thomas ret=$?
1007 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1008 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1009 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1010 1ebedb77 2019-10-19 stsp return 1
1011 1ebedb77 2019-10-19 stsp fi
1012 1ebedb77 2019-10-19 stsp
1013 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
1014 1ebedb77 2019-10-19 stsp
1015 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1016 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1017 f7b97ccb 2020-04-14 stsp
1018 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1019 fc414659 2022-04-16 thomas ret=$?
1020 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1021 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1022 f7b97ccb 2020-04-14 stsp fi
1023 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1024 f7b97ccb 2020-04-14 stsp }
1025 f7b97ccb 2020-04-14 stsp
1026 f6cae3ed 2020-09-13 naddy commit_check_mode() {
1027 f7b97ccb 2020-04-14 stsp local mode="$1"
1028 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
1029 f7b97ccb 2020-04-14 stsp
1030 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
1031 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
1032 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
1033 f7b97ccb 2020-04-14 stsp
1034 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
1035 fc414659 2022-04-16 thomas ret=$?
1036 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1037 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
1038 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1039 f7b97ccb 2020-04-14 stsp return 1
1040 f7b97ccb 2020-04-14 stsp fi
1041 1ebedb77 2019-10-19 stsp
1042 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
1043 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
1044 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1045 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1046 fc414659 2022-04-16 thomas ret=$?
1047 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1048 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1049 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1050 a9662115 2021-08-29 naddy return 1
1051 f7b97ccb 2020-04-14 stsp fi
1052 f7b97ccb 2020-04-14 stsp
1053 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
1054 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
1055 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
1056 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
1057 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
1058 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
1059 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1060 fc414659 2022-04-16 thomas ret=$?
1061 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1062 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1063 1ebedb77 2019-10-19 stsp fi
1064 f7b97ccb 2020-04-14 stsp return $ret
1065 f7b97ccb 2020-04-14 stsp }
1066 f7b97ccb 2020-04-14 stsp
1067 f6cae3ed 2020-09-13 naddy test_commit_normalizes_filemodes() {
1068 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
1069 f7b97ccb 2020-04-14 stsp
1070 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1071 fc414659 2022-04-16 thomas ret=$?
1072 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1073 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1074 f7b97ccb 2020-04-14 stsp return 1
1075 f7b97ccb 2020-04-14 stsp fi
1076 f7b97ccb 2020-04-14 stsp
1077 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
1078 f7b97ccb 2020-04-14 stsp for m in $modes; do
1079 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
1080 fc414659 2022-04-16 thomas ret=$?
1081 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1082 f7b97ccb 2020-04-14 stsp break
1083 f7b97ccb 2020-04-14 stsp fi
1084 f7b97ccb 2020-04-14 stsp done
1085 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1086 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1087 f7b97ccb 2020-04-14 stsp return 1
1088 f7b97ccb 2020-04-14 stsp fi
1089 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
1090 f7b97ccb 2020-04-14 stsp for m in $modes; do
1091 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
1092 fc414659 2022-04-16 thomas ret=$?
1093 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1094 f7b97ccb 2020-04-14 stsp break
1095 f7b97ccb 2020-04-14 stsp fi
1096 f7b97ccb 2020-04-14 stsp done
1097 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1098 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1099 e7303626 2020-05-14 stsp return 1
1100 e7303626 2020-05-14 stsp fi
1101 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1102 e7303626 2020-05-14 stsp }
1103 e7303626 2020-05-14 stsp
1104 f6cae3ed 2020-09-13 naddy test_commit_with_unrelated_submodule() {
1105 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
1106 e7303626 2020-05-14 stsp
1107 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1108 e7303626 2020-05-14 stsp
1109 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
1110 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1111 e7303626 2020-05-14 stsp
1112 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1113 fc414659 2022-04-16 thomas ret=$?
1114 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1115 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
1116 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1117 e7303626 2020-05-14 stsp return 1
1118 e7303626 2020-05-14 stsp fi
1119 e7303626 2020-05-14 stsp
1120 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
1121 e7303626 2020-05-14 stsp
1122 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
1123 7aadece8 2020-05-17 stsp
1124 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1125 fc414659 2022-04-16 thomas ret=$?
1126 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1127 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
1128 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
1129 f7b97ccb 2020-04-14 stsp return 1
1130 f7b97ccb 2020-04-14 stsp fi
1131 e7303626 2020-05-14 stsp
1132 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
1133 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
1134 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1135 3d9a4ec4 2020-07-23 stsp
1136 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1137 fc414659 2022-04-16 thomas ret=$?
1138 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1139 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1140 3d9a4ec4 2020-07-23 stsp fi
1141 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1142 3d9a4ec4 2020-07-23 stsp }
1143 3d9a4ec4 2020-07-23 stsp
1144 f6cae3ed 2020-09-13 naddy check_symlinks() {
1145 bd6aa359 2020-07-23 stsp local wtpath="$1"
1146 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
1147 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
1148 bd6aa359 2020-07-23 stsp return 1
1149 bd6aa359 2020-07-23 stsp fi
1150 3d9a4ec4 2020-07-23 stsp
1151 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
1152 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1153 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1154 fc414659 2022-04-16 thomas ret=$?
1155 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1156 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1157 3d9a4ec4 2020-07-23 stsp return 1
1158 3d9a4ec4 2020-07-23 stsp fi
1159 3d9a4ec4 2020-07-23 stsp
1160 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
1161 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
1162 bd6aa359 2020-07-23 stsp return 1
1163 bd6aa359 2020-07-23 stsp fi
1164 3d9a4ec4 2020-07-23 stsp
1165 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
1166 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1167 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1168 fc414659 2022-04-16 thomas ret=$?
1169 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1170 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1171 3d9a4ec4 2020-07-23 stsp return 1
1172 3d9a4ec4 2020-07-23 stsp fi
1173 3d9a4ec4 2020-07-23 stsp
1174 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
1175 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1176 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
1177 bd6aa359 2020-07-23 stsp return 1
1178 bd6aa359 2020-07-23 stsp fi
1179 bd6aa359 2020-07-23 stsp
1180 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1181 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
1182 fc414659 2022-04-16 thomas ret=$?
1183 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1184 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
1185 3d9a4ec4 2020-07-23 stsp return 1
1186 3d9a4ec4 2020-07-23 stsp fi
1187 3d9a4ec4 2020-07-23 stsp
1188 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1189 fc414659 2022-04-16 thomas ret=$?
1190 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1191 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1192 3d9a4ec4 2020-07-23 stsp return 1
1193 3d9a4ec4 2020-07-23 stsp fi
1194 3d9a4ec4 2020-07-23 stsp
1195 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
1196 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1197 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1198 fc414659 2022-04-16 thomas ret=$?
1199 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1200 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1201 3d9a4ec4 2020-07-23 stsp return 1
1202 3d9a4ec4 2020-07-23 stsp fi
1203 7aadece8 2020-05-17 stsp
1204 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
1205 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1206 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1207 fc414659 2022-04-16 thomas ret=$?
1208 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1209 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1210 3d9a4ec4 2020-07-23 stsp return 1
1211 e7303626 2020-05-14 stsp fi
1212 3d9a4ec4 2020-07-23 stsp
1213 bd6aa359 2020-07-23 stsp return 0
1214 bd6aa359 2020-07-23 stsp }
1215 3d9a4ec4 2020-07-23 stsp
1216 f6cae3ed 2020-09-13 naddy test_commit_symlink() {
1217 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
1218 3d9a4ec4 2020-07-23 stsp
1219 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1220 fc414659 2022-04-16 thomas ret=$?
1221 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1222 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1223 3d9a4ec4 2020-07-23 stsp return 1
1224 3d9a4ec4 2020-07-23 stsp fi
1225 3d9a4ec4 2020-07-23 stsp
1226 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
1227 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
1228 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1229 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1230 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1231 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1232 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
1233 bd6aa359 2020-07-23 stsp
1234 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1235 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1236 fc414659 2022-04-16 thomas ret=$?
1237 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1238 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1239 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1240 35213c7c 2020-07-23 stsp return 1
1241 35213c7c 2020-07-23 stsp fi
1242 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1243 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1244 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1245 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1246 fc414659 2022-04-16 thomas ret=$?
1247 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1248 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1249 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1250 35213c7c 2020-07-23 stsp return 1
1251 35213c7c 2020-07-23 stsp fi
1252 bd6aa359 2020-07-23 stsp
1253 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1254 35213c7c 2020-07-23 stsp > $testroot/stdout)
1255 35213c7c 2020-07-23 stsp
1256 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1257 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1258 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1259 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1260 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1261 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1262 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1263 bd6aa359 2020-07-23 stsp
1264 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1265 fc414659 2022-04-16 thomas ret=$?
1266 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1267 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1268 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1269 3d9a4ec4 2020-07-23 stsp return 1
1270 3d9a4ec4 2020-07-23 stsp fi
1271 3d9a4ec4 2020-07-23 stsp
1272 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1273 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1274 fc414659 2022-04-16 thomas ret=$?
1275 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1276 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1277 bd6aa359 2020-07-23 stsp return 1
1278 3d9a4ec4 2020-07-23 stsp fi
1279 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1280 fc414659 2022-04-16 thomas ret=$?
1281 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1282 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1283 bd6aa359 2020-07-23 stsp return 1
1284 bd6aa359 2020-07-23 stsp fi
1285 bd6aa359 2020-07-23 stsp
1286 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1287 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1288 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1289 75f0a0fb 2020-07-23 stsp return 1
1290 75f0a0fb 2020-07-23 stsp fi
1291 75f0a0fb 2020-07-23 stsp
1292 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1293 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1294 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1295 fc414659 2022-04-16 thomas ret=$?
1296 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1297 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1298 5a1fbc73 2020-07-23 stsp return 1
1299 5a1fbc73 2020-07-23 stsp fi
1300 88fb31d4 2020-07-23 stsp
1301 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1302 dd6165e4 2021-09-21 thomas.ad (cd $testroot/wt && ln -sfT gamma epsilon.link)
1303 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1304 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1305 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1306 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1307 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1308 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1309 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1310 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1311 88fb31d4 2020-07-23 stsp
1312 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1313 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1314 fc414659 2022-04-16 thomas ret=$?
1315 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1316 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1317 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1318 35213c7c 2020-07-23 stsp return 1
1319 35213c7c 2020-07-23 stsp fi
1320 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1321 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1322 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1323 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1324 fc414659 2022-04-16 thomas ret=$?
1325 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1326 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1327 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1328 35213c7c 2020-07-23 stsp return 1
1329 35213c7c 2020-07-23 stsp fi
1330 88fb31d4 2020-07-23 stsp
1331 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1332 35213c7c 2020-07-23 stsp > $testroot/stdout)
1333 35213c7c 2020-07-23 stsp
1334 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1335 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1336 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1337 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1338 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1339 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1340 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1341 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1342 88fb31d4 2020-07-23 stsp
1343 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1344 fc414659 2022-04-16 thomas ret=$?
1345 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1346 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1347 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1348 88fb31d4 2020-07-23 stsp return 1
1349 88fb31d4 2020-07-23 stsp fi
1350 88fb31d4 2020-07-23 stsp
1351 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1352 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1353 88fb31d4 2020-07-23 stsp alpha
1354 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1355 88fb31d4 2020-07-23 stsp beta
1356 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1357 88fb31d4 2020-07-23 stsp epsilon/
1358 88fb31d4 2020-07-23 stsp epsilon/beta.link
1359 88fb31d4 2020-07-23 stsp epsilon/zeta
1360 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1361 88fb31d4 2020-07-23 stsp gamma/
1362 88fb31d4 2020-07-23 stsp gamma/delta
1363 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1364 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1365 88fb31d4 2020-07-23 stsp EOF
1366 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1367 fc414659 2022-04-16 thomas ret=$?
1368 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1369 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1370 88fb31d4 2020-07-23 stsp fi
1371 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1372 5a1fbc73 2020-07-23 stsp }
1373 5a1fbc73 2020-07-23 stsp
1374 f6cae3ed 2020-09-13 naddy test_commit_fix_bad_symlink() {
1375 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1376 5a1fbc73 2020-07-23 stsp
1377 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1378 fc414659 2022-04-16 thomas ret=$?
1379 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1380 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1381 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1382 5a1fbc73 2020-07-23 stsp return 1
1383 5a1fbc73 2020-07-23 stsp fi
1384 5a1fbc73 2020-07-23 stsp
1385 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1386 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1387 5a1fbc73 2020-07-23 stsp
1388 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1389 35213c7c 2020-07-23 stsp > $testroot/stdout)
1390 5a1fbc73 2020-07-23 stsp
1391 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1392 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1393 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1394 75f0a0fb 2020-07-23 stsp return 1
1395 75f0a0fb 2020-07-23 stsp fi
1396 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1397 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1398 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1399 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1400 5a1fbc73 2020-07-23 stsp return 1
1401 5a1fbc73 2020-07-23 stsp fi
1402 5a1fbc73 2020-07-23 stsp
1403 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1404 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1405 fc414659 2022-04-16 thomas ret=$?
1406 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1407 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1408 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1409 5a1fbc73 2020-07-23 stsp return 1
1410 5a1fbc73 2020-07-23 stsp fi
1411 5a1fbc73 2020-07-23 stsp
1412 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1413 dd6165e4 2021-09-21 thomas.ad (cd $testroot/wt && ln -sfT alpha passwd.link)
1414 5a1fbc73 2020-07-23 stsp
1415 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1416 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1417 5a1fbc73 2020-07-23 stsp
1418 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1419 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1420 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1421 5a1fbc73 2020-07-23 stsp
1422 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1423 fc414659 2022-04-16 thomas ret=$?
1424 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1425 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1426 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1427 bd6aa359 2020-07-23 stsp return 1
1428 bd6aa359 2020-07-23 stsp fi
1429 5a1fbc73 2020-07-23 stsp
1430 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1431 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1432 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1433 5a1fbc73 2020-07-23 stsp return 1
1434 5a1fbc73 2020-07-23 stsp fi
1435 5a1fbc73 2020-07-23 stsp
1436 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1437 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1438 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1439 fc414659 2022-04-16 thomas ret=$?
1440 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1441 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1442 5a1fbc73 2020-07-23 stsp return 1
1443 5a1fbc73 2020-07-23 stsp fi
1444 5a1fbc73 2020-07-23 stsp
1445 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1446 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1447 fc414659 2022-04-16 thomas ret=$?
1448 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1449 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1450 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1451 5a1fbc73 2020-07-23 stsp return 1
1452 5a1fbc73 2020-07-23 stsp fi
1453 5a1fbc73 2020-07-23 stsp
1454 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1455 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1456 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1457 5a1fbc73 2020-07-23 stsp return 1
1458 5a1fbc73 2020-07-23 stsp fi
1459 5a1fbc73 2020-07-23 stsp
1460 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1461 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1462 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1463 fc414659 2022-04-16 thomas ret=$?
1464 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1465 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1466 5a1fbc73 2020-07-23 stsp return 1
1467 5a1fbc73 2020-07-23 stsp fi
1468 5a1fbc73 2020-07-23 stsp
1469 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1470 1ebedb77 2019-10-19 stsp }
1471 28cf319f 2021-01-28 stsp
1472 28cf319f 2021-01-28 stsp test_commit_prepared_logmsg() {
1473 28cf319f 2021-01-28 stsp local testroot=`test_init commit_prepared_logmsg`
1474 28cf319f 2021-01-28 stsp
1475 28cf319f 2021-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1476 fc414659 2022-04-16 thomas ret=$?
1477 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1478 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1479 28cf319f 2021-01-28 stsp return 1
1480 28cf319f 2021-01-28 stsp fi
1481 28cf319f 2021-01-28 stsp
1482 28cf319f 2021-01-28 stsp echo "modified alpha" > $testroot/wt/alpha
1483 28cf319f 2021-01-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
1484 28cf319f 2021-01-28 stsp echo "new file" > $testroot/wt/new
1485 28cf319f 2021-01-28 stsp (cd $testroot/wt && got add new >/dev/null)
1486 28cf319f 2021-01-28 stsp
1487 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg' > $testroot/logmsg
1488 28cf319f 2021-01-28 stsp
1489 28cf319f 2021-01-28 stsp cat > $testroot/editor.sh <<EOF
1490 28cf319f 2021-01-28 stsp #!/bin/sh
1491 c206b220 2021-10-09 thomas SOPTS='-i ""'
1492 c206b220 2021-10-09 thomas [ "\$OSTYPE" = "linux-gnu" ] && SOPTS="-i"
1493 c206b220 2021-10-09 thomas sed "\$SOPTS" -e 's/foo/bar/' "\$1"
1494 28cf319f 2021-01-28 stsp EOF
1495 28cf319f 2021-01-28 stsp chmod +x $testroot/editor.sh
1496 28cf319f 2021-01-28 stsp
1497 8e09a168 2021-06-17 tracey (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1498 28cf319f 2021-01-28 stsp got commit -F "$testroot/logmsg" > $testroot/stdout)
1499 1ebedb77 2019-10-19 stsp
1500 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1501 28cf319f 2021-01-28 stsp echo "A new" > $testroot/stdout.expected
1502 28cf319f 2021-01-28 stsp echo "M alpha" >> $testroot/stdout.expected
1503 28cf319f 2021-01-28 stsp echo "D beta" >> $testroot/stdout.expected
1504 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1505 28cf319f 2021-01-28 stsp
1506 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1507 fc414659 2022-04-16 thomas ret=$?
1508 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1509 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1510 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1511 28cf319f 2021-01-28 stsp return 1
1512 28cf319f 2021-01-28 stsp fi
1513 28cf319f 2021-01-28 stsp
1514 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1515 fa37079f 2021-10-09 thomas local prev_LC_TIME="$LC_TIME"
1516 fa37079f 2021-10-09 thomas export LC_TIME=C
1517 fa37079f 2021-10-09 thomas d=`date -u -d "@$author_time" +"%a %b %e %X %Y UTC"`
1518 fa37079f 2021-10-09 thomas LC_TIME="$prev_LC_TIME"
1519 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" > $testroot/stdout.expected
1520 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1521 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1522 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1523 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1524 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1525 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1526 28cf319f 2021-01-28 stsp
1527 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1528 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1529 fc414659 2022-04-16 thomas ret=$?
1530 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1531 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1532 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1533 28cf319f 2021-01-28 stsp return 1
1534 28cf319f 2021-01-28 stsp fi
1535 28cf319f 2021-01-28 stsp
1536 28cf319f 2021-01-28 stsp echo "modified alpha again" > $testroot/wt/alpha
1537 28cf319f 2021-01-28 stsp
1538 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg non-interactive' \
1539 28cf319f 2021-01-28 stsp > $testroot/logmsg
1540 28cf319f 2021-01-28 stsp
1541 28cf319f 2021-01-28 stsp (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1542 28cf319f 2021-01-28 stsp > $testroot/stdout)
1543 28cf319f 2021-01-28 stsp
1544 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1545 28cf319f 2021-01-28 stsp echo "M alpha" > $testroot/stdout.expected
1546 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1547 28cf319f 2021-01-28 stsp
1548 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1549 fc414659 2022-04-16 thomas ret=$?
1550 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1551 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1552 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1553 28cf319f 2021-01-28 stsp return 1
1554 28cf319f 2021-01-28 stsp fi
1555 28cf319f 2021-01-28 stsp
1556 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1557 fa37079f 2021-10-09 thomas local prev_LC_TIME="$LC_TIME"
1558 fa37079f 2021-10-09 thomas export LC_TIME=C
1559 fa37079f 2021-10-09 thomas d=`date -u -d "@$author_time" +"%a %b %e %X %Y UTC"`
1560 fa37079f 2021-10-09 thomas LC_TIME="$prev_LC_TIME"
1561 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" \
1562 28cf319f 2021-01-28 stsp > $testroot/stdout.expected
1563 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1564 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1565 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1566 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1567 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg non-interactive" \
1568 28cf319f 2021-01-28 stsp >> $testroot/stdout.expected
1569 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1570 28cf319f 2021-01-28 stsp
1571 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1572 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1573 fc414659 2022-04-16 thomas ret=$?
1574 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1575 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1576 28cf319f 2021-01-28 stsp fi
1577 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1578 28cf319f 2021-01-28 stsp }
1579 e8f02263 2022-01-23 thomas
1580 e8f02263 2022-01-23 thomas test_commit_large_file() {
1581 e8f02263 2022-01-23 thomas local testroot=`test_init commit_large_file`
1582 e8f02263 2022-01-23 thomas
1583 e8f02263 2022-01-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1584 fc414659 2022-04-16 thomas ret=$?
1585 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1586 e8f02263 2022-01-23 thomas test_done "$testroot" "$ret"
1587 e8f02263 2022-01-23 thomas return 1
1588 e8f02263 2022-01-23 thomas fi
1589 e8f02263 2022-01-23 thomas
1590 b9e845cd 2022-07-06 thomas dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1591 e8f02263 2022-01-23 thomas (cd $testroot/wt && got add new >/dev/null)
1592 28cf319f 2021-01-28 stsp
1593 e8f02263 2022-01-23 thomas (cd $testroot/wt && got commit -m 'test commit_large_file' \
1594 e8f02263 2022-01-23 thomas > $testroot/stdout)
1595 e8f02263 2022-01-23 thomas
1596 e8f02263 2022-01-23 thomas local head_rev=`git_show_head $testroot/repo`
1597 e8f02263 2022-01-23 thomas echo "A new" > $testroot/stdout.expected
1598 e8f02263 2022-01-23 thomas echo "Created commit $head_rev" >> $testroot/stdout.expected
1599 e8f02263 2022-01-23 thomas
1600 e8f02263 2022-01-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1601 fc414659 2022-04-16 thomas ret=$?
1602 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1603 e8f02263 2022-01-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1604 e8f02263 2022-01-23 thomas test_done "$testroot" "$ret"
1605 e8f02263 2022-01-23 thomas return 1
1606 e8f02263 2022-01-23 thomas fi
1607 e8f02263 2022-01-23 thomas
1608 e8f02263 2022-01-23 thomas new_id=`get_blob_id $testroot/repo "" new`
1609 e8f02263 2022-01-23 thomas got cat -r $testroot/repo $new_id > $testroot/new
1610 fc414659 2022-04-16 thomas ret=$?
1611 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1612 e8f02263 2022-01-23 thomas echo "commit failed unexpectedly" >&2
1613 e8f02263 2022-01-23 thomas test_done "$testroot" "1"
1614 e8f02263 2022-01-23 thomas return 1
1615 e8f02263 2022-01-23 thomas fi
1616 e8f02263 2022-01-23 thomas
1617 e8f02263 2022-01-23 thomas cmp -s $testroot/new $testroot/wt/new
1618 fc414659 2022-04-16 thomas ret=$?
1619 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1620 e8f02263 2022-01-23 thomas diff -u $testroot/new $testroot/wt/new
1621 e8f02263 2022-01-23 thomas fi
1622 e8f02263 2022-01-23 thomas test_done "$testroot" "$ret"
1623 e8f02263 2022-01-23 thomas
1624 e8f02263 2022-01-23 thomas
1625 e8f02263 2022-01-23 thomas }
1626 e8f02263 2022-01-23 thomas
1627 e8f02263 2022-01-23 thomas
1628 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1629 c4296144 2019-05-09 stsp run_test test_commit_basic
1630 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
1631 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
1632 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
1633 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
1634 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
1635 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
1636 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
1637 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
1638 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
1639 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
1640 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
1641 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
1642 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
1643 84792843 2019-08-09 stsp run_test test_commit_no_email
1644 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
1645 18d1acad 2022-07-20 thomas run_test test_commit_cmdline_author
1646 257add31 2020-09-09 stsp run_test test_commit_gotconfig_author
1647 50b0790e 2020-09-11 stsp run_test test_commit_gotconfig_worktree_author
1648 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
1649 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
1650 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
1651 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
1652 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
1653 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink
1654 28cf319f 2021-01-28 stsp run_test test_commit_prepared_logmsg
1655 e8f02263 2022-01-23 thomas run_test test_commit_large_file