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 49c543a6 2022-03-31 naddy ret=$?
24 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
44 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
55 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
76 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
87 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
104 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
115 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
132 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
144 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
163 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
164 819f385b 2019-05-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
165 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
172 819f385b 2019-05-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
173 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
185 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
186 f0b75401 2019-08-03 stsp echo "commit failed unexpectedly" >&2
187 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
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 49c543a6 2022-03-31 naddy ret=$?
196 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
207 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
235 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
246 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
264 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
265 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
277 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
290 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
312 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
313 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
314 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
327 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
328 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
329 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
334 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
345 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
362 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
363 1a36436d 2019-06-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
364 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
377 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
397 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
409 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
424 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
425 2b496619 2019-07-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
426 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
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 8469d821 2022-06-25 stsp echo "commit - $commit1" >> $testroot/stdout.expected
432 8469d821 2022-06-25 stsp echo "commit + $commit2" >> $testroot/stdout.expected
433 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
434 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
435 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $testroot/stdout.expected
436 e0233cea 2019-07-25 stsp echo -n 'blob + ' >> $testroot/stdout.expected
437 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
438 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
439 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
440 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
441 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
442 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
443 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
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 49c543a6 2022-03-31 naddy ret=$?
448 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
449 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
450 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
468 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
469 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
470 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
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 8469d821 2022-06-25 stsp echo "commit - $commit2" >> $testroot/stdout.expected
476 8469d821 2022-06-25 stsp echo "commit + $commit3" >> $testroot/stdout.expected
477 f2b0a8b0 2020-07-31 stsp echo -n 'blob - ' >> $testroot/stdout.expected
478 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
479 f2b0a8b0 2020-07-31 stsp | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
480 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
481 f2b0a8b0 2020-07-31 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
482 f2b0a8b0 2020-07-31 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
483 f2b0a8b0 2020-07-31 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
484 f2b0a8b0 2020-07-31 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
485 f2b0a8b0 2020-07-31 stsp echo '-modified delta' >> $testroot/stdout.expected
486 f2b0a8b0 2020-07-31 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
487 f2b0a8b0 2020-07-31 stsp echo -n 'blob + ' >> $testroot/stdout.expected
488 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
489 f2b0a8b0 2020-07-31 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
490 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
491 f2b0a8b0 2020-07-31 stsp echo '--- /dev/null' >> $testroot/stdout.expected
492 f2b0a8b0 2020-07-31 stsp echo '+++ gamma/new' >> $testroot/stdout.expected
493 f2b0a8b0 2020-07-31 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
494 f2b0a8b0 2020-07-31 stsp echo '+new' >> $testroot/stdout.expected
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 49c543a6 2022-03-31 naddy ret=$?
499 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
511 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
528 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
529 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
530 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
538 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
549 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
564 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
565 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
566 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
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 49c543a6 2022-03-31 naddy ret=$?
573 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
574 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
575 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
590 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
604 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
614 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
615 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
616 916f288c 2019-07-30 stsp test_done "$testroot" "1"
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 49c543a6 2022-03-31 naddy ret=$?
623 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
624 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
625 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
635 49c543a6 2022-03-31 naddy 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 cf208ddd 2022-07-19 op local errmsg=""
644 cf208ddd 2022-07-19 op
645 cf208ddd 2022-07-19 op errmsg="commit author's email address is required for"
646 cf208ddd 2022-07-19 op errmsg="$errmsg compatibility with Git"
647 916f288c 2019-07-30 stsp
648 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
649 49c543a6 2022-03-31 naddy ret=$?
650 49c543a6 2022-03-31 naddy 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 cf208ddd 2022-07-19 op printf "got: :flan_hacker:: %s\n" "$errmsg" > $testroot/stderr.expected
661 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
662 49c543a6 2022-03-31 naddy ret=$?
663 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
664 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
665 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
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 49c543a6 2022-03-31 naddy ret=$?
672 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
673 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
674 cf208ddd 2022-07-19 op test_done "$testroot" $ret
675 cf208ddd 2022-07-19 op return 1
676 84792843 2019-08-09 stsp fi
677 cf208ddd 2022-07-19 op
678 cf208ddd 2022-07-19 op # try again with a newline inside the email
679 cf208ddd 2022-07-19 op (cd $testroot/wt \
680 cf208ddd 2022-07-19 op && FS=' ' env GOT_AUTHOR="$(printf "Flan <hack\ner>")" \
681 cf208ddd 2022-07-19 op got commit -m 'test invalid email' > $testroot/stdout \
682 cf208ddd 2022-07-19 op 2> $testroot/stderr)
683 cf208ddd 2022-07-19 op
684 cf208ddd 2022-07-19 op printf "got: Flan <hack\ner>: %s\n" "$errmsg" \
685 cf208ddd 2022-07-19 op > $testroot/stderr.expected
686 cf208ddd 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
687 cf208ddd 2022-07-19 op ret=$?
688 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
689 cf208ddd 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
690 cf208ddd 2022-07-19 op test_done "$testroot" $ret
691 cf208ddd 2022-07-19 op return 1
692 cf208ddd 2022-07-19 op fi
693 cf208ddd 2022-07-19 op
694 cf208ddd 2022-07-19 op echo -n > $testroot/stdout.expected
695 cf208ddd 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
696 cf208ddd 2022-07-19 op ret=$?
697 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
698 cf208ddd 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
699 cf208ddd 2022-07-19 op test_done "$testroot" $ret
700 cf208ddd 2022-07-19 op return 1
701 cf208ddd 2022-07-19 op fi
702 cf208ddd 2022-07-19 op
703 cf208ddd 2022-07-19 op # try again with a < inside the email
704 cf208ddd 2022-07-19 op (cd $testroot/wt && env GOT_AUTHOR="$(printf "Flan <ha<ker>")" \
705 cf208ddd 2022-07-19 op got commit -m 'test invalid email' > $testroot/stdout \
706 cf208ddd 2022-07-19 op 2> $testroot/stderr)
707 cf208ddd 2022-07-19 op
708 cf208ddd 2022-07-19 op printf "got: Flan <ha<ker>: %s\n" "$errmsg" > $testroot/stderr.expected
709 cf208ddd 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
710 cf208ddd 2022-07-19 op ret=$?
711 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
712 cf208ddd 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
713 cf208ddd 2022-07-19 op test_done "$testroot" $ret
714 cf208ddd 2022-07-19 op return 1
715 cf208ddd 2022-07-19 op fi
716 cf208ddd 2022-07-19 op
717 cf208ddd 2022-07-19 op echo -n > $testroot/stdout.expected
718 cf208ddd 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
719 cf208ddd 2022-07-19 op ret=$?
720 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
721 cf208ddd 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
722 cf208ddd 2022-07-19 op fi
723 cf208ddd 2022-07-19 op 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 49c543a6 2022-03-31 naddy ret=$?
731 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
752 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
753 62b21d33 2022-07-19 op }
754 62b21d33 2022-07-19 op
755 62b21d33 2022-07-19 op test_commit_cmdline_author() {
756 62b21d33 2022-07-19 op local testroot=`test_init commit_cmdline_author`
757 62b21d33 2022-07-19 op
758 62b21d33 2022-07-19 op got checkout $testroot/repo $testroot/wt > /dev/null
759 62b21d33 2022-07-19 op ret=$?
760 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
761 62b21d33 2022-07-19 op test_done "$testroot" $ret
762 62b21d33 2022-07-19 op return 1
763 62b21d33 2022-07-19 op fi
764 62b21d33 2022-07-19 op
765 62b21d33 2022-07-19 op echo "modified alpha" > $testroot/wt/alpha
766 62b21d33 2022-07-19 op
767 62b21d33 2022-07-19 op # first try with a -A equals to $GOT_AUTHOR
768 62b21d33 2022-07-19 op (cd $testroot/wt && got commit -A "$GOT_AUTHOR" -m 'edit alpha') \
769 62b21d33 2022-07-19 op > /dev/null 2> $testroot/stderr
770 62b21d33 2022-07-19 op ret=$?
771 62b21d33 2022-07-19 op if [ $ret -eq 0 ]; then
772 62b21d33 2022-07-19 op test_done "$testroot" 1
773 62b21d33 2022-07-19 op return 1
774 62b21d33 2022-07-19 op fi
775 62b21d33 2022-07-19 op
776 62b21d33 2022-07-19 op echo 'got: specified author is equal to the default one' \
777 62b21d33 2022-07-19 op > $testroot/stderr.expected
778 62b21d33 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
779 62b21d33 2022-07-19 op ret=$?
780 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
781 62b21d33 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
782 62b21d33 2022-07-19 op test_done "$testroot" $ret
783 62b21d33 2022-07-19 op return 1
784 62b21d33 2022-07-19 op fi
785 62b21d33 2022-07-19 op
786 62b21d33 2022-07-19 op # try again with a different author
787 62b21d33 2022-07-19 op local author="Foo <foo@example.com>"
788 62b21d33 2022-07-19 op (cd $testroot/wt && got commit -A "$author" -m 'edit alpha') \
789 62b21d33 2022-07-19 op > /dev/null
790 62b21d33 2022-07-19 op ret=$?
791 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
792 62b21d33 2022-07-19 op test_done "$testroot" $ret
793 62b21d33 2022-07-19 op return 1
794 62b21d33 2022-07-19 op fi
795 62b21d33 2022-07-19 op
796 62b21d33 2022-07-19 op (cd $testroot/repo && got log -l1 | egrep '^(from|via):') \
797 62b21d33 2022-07-19 op > $testroot/stdout
798 62b21d33 2022-07-19 op ret=$?
799 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
800 62b21d33 2022-07-19 op test_done "$testroot" $ret
801 62b21d33 2022-07-19 op return 1
802 62b21d33 2022-07-19 op fi
803 62b21d33 2022-07-19 op
804 62b21d33 2022-07-19 op echo "from: $author" > $testroot/stdout.expected
805 62b21d33 2022-07-19 op echo "via: $GOT_AUTHOR" >> $testroot/stdout.expected
806 62b21d33 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
807 62b21d33 2022-07-19 op ret=$?
808 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
809 62b21d33 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
810 62b21d33 2022-07-19 op fi
811 62b21d33 2022-07-19 op 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 49c543a6 2022-03-31 naddy ret=$?
819 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
829 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
836 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
845 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
856 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
868 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
875 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
884 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
895 49c543a6 2022-03-31 naddy 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 7370f802 2022-07-24 op
905 7370f802 2022-07-24 op # unset in a subshell to avoid affecting our environment
906 7370f802 2022-07-24 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
907 7370f802 2022-07-24 op got commit -m 'test gitconfig author' > /dev/null)
908 49c543a6 2022-03-31 naddy ret=$?
909 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
910 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
911 aba9c984 2019-09-08 stsp return 1
912 aba9c984 2019-09-08 stsp fi
913 aba9c984 2019-09-08 stsp
914 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
915 49c543a6 2022-03-31 naddy ret=$?
916 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
917 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
918 aba9c984 2019-09-08 stsp return 1
919 aba9c984 2019-09-08 stsp fi
920 aba9c984 2019-09-08 stsp
921 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
922 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
923 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
924 49c543a6 2022-03-31 naddy ret=$?
925 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
926 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
927 aba9c984 2019-09-08 stsp fi
928 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
929 aba9c984 2019-09-08 stsp }
930 1ebedb77 2019-10-19 stsp
931 f6cae3ed 2020-09-13 naddy test_commit_xbit_change() {
932 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
933 1ebedb77 2019-10-19 stsp
934 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
935 49c543a6 2022-03-31 naddy ret=$?
936 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
937 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
938 1ebedb77 2019-10-19 stsp return 1
939 1ebedb77 2019-10-19 stsp fi
940 1ebedb77 2019-10-19 stsp
941 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
942 1ebedb77 2019-10-19 stsp
943 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
944 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
945 aba9c984 2019-09-08 stsp
946 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
947 49c543a6 2022-03-31 naddy ret=$?
948 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
949 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
950 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
951 1ebedb77 2019-10-19 stsp return 1
952 1ebedb77 2019-10-19 stsp fi
953 1ebedb77 2019-10-19 stsp
954 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
955 49c543a6 2022-03-31 naddy ret=$?
956 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
957 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
958 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
959 1ebedb77 2019-10-19 stsp return 1
960 1ebedb77 2019-10-19 stsp fi
961 1ebedb77 2019-10-19 stsp
962 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
963 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
964 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
965 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
966 49c543a6 2022-03-31 naddy ret=$?
967 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
968 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
969 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
970 1ebedb77 2019-10-19 stsp return 1
971 1ebedb77 2019-10-19 stsp fi
972 1ebedb77 2019-10-19 stsp
973 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
974 1ebedb77 2019-10-19 stsp
975 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
976 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
977 49c543a6 2022-03-31 naddy ret=$?
978 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
979 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
980 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
981 1ebedb77 2019-10-19 stsp return 1
982 1ebedb77 2019-10-19 stsp fi
983 1ebedb77 2019-10-19 stsp
984 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
985 1ebedb77 2019-10-19 stsp
986 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
987 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
988 1ebedb77 2019-10-19 stsp
989 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
990 49c543a6 2022-03-31 naddy ret=$?
991 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
992 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
993 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
994 1ebedb77 2019-10-19 stsp return 1
995 1ebedb77 2019-10-19 stsp fi
996 1ebedb77 2019-10-19 stsp
997 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
998 49c543a6 2022-03-31 naddy ret=$?
999 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1000 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
1001 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1002 1ebedb77 2019-10-19 stsp return 1
1003 1ebedb77 2019-10-19 stsp fi
1004 1ebedb77 2019-10-19 stsp
1005 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
1006 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1007 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1008 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1009 49c543a6 2022-03-31 naddy ret=$?
1010 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1011 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1012 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1013 1ebedb77 2019-10-19 stsp return 1
1014 1ebedb77 2019-10-19 stsp fi
1015 1ebedb77 2019-10-19 stsp
1016 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
1017 1ebedb77 2019-10-19 stsp
1018 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1019 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1020 f7b97ccb 2020-04-14 stsp
1021 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1022 49c543a6 2022-03-31 naddy ret=$?
1023 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1024 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1025 f7b97ccb 2020-04-14 stsp fi
1026 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1027 f7b97ccb 2020-04-14 stsp }
1028 f7b97ccb 2020-04-14 stsp
1029 f6cae3ed 2020-09-13 naddy commit_check_mode() {
1030 f7b97ccb 2020-04-14 stsp local mode="$1"
1031 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
1032 f7b97ccb 2020-04-14 stsp
1033 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
1034 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
1035 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
1036 f7b97ccb 2020-04-14 stsp
1037 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
1038 49c543a6 2022-03-31 naddy ret=$?
1039 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1040 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
1041 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1042 f7b97ccb 2020-04-14 stsp return 1
1043 f7b97ccb 2020-04-14 stsp fi
1044 1ebedb77 2019-10-19 stsp
1045 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
1046 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
1047 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1048 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1049 49c543a6 2022-03-31 naddy ret=$?
1050 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1051 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1052 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1053 a9662115 2021-08-29 naddy return 1
1054 f7b97ccb 2020-04-14 stsp fi
1055 f7b97ccb 2020-04-14 stsp
1056 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
1057 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
1058 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
1059 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
1060 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
1061 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
1062 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1063 49c543a6 2022-03-31 naddy ret=$?
1064 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1065 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1066 1ebedb77 2019-10-19 stsp fi
1067 f7b97ccb 2020-04-14 stsp return $ret
1068 f7b97ccb 2020-04-14 stsp }
1069 f7b97ccb 2020-04-14 stsp
1070 f6cae3ed 2020-09-13 naddy test_commit_normalizes_filemodes() {
1071 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
1072 f7b97ccb 2020-04-14 stsp
1073 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1074 49c543a6 2022-03-31 naddy ret=$?
1075 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1076 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1077 f7b97ccb 2020-04-14 stsp return 1
1078 f7b97ccb 2020-04-14 stsp fi
1079 f7b97ccb 2020-04-14 stsp
1080 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
1081 f7b97ccb 2020-04-14 stsp for m in $modes; do
1082 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
1083 49c543a6 2022-03-31 naddy ret=$?
1084 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1085 f7b97ccb 2020-04-14 stsp break
1086 f7b97ccb 2020-04-14 stsp fi
1087 f7b97ccb 2020-04-14 stsp done
1088 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1089 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1090 f7b97ccb 2020-04-14 stsp return 1
1091 f7b97ccb 2020-04-14 stsp fi
1092 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
1093 f7b97ccb 2020-04-14 stsp for m in $modes; do
1094 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
1095 49c543a6 2022-03-31 naddy ret=$?
1096 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1097 f7b97ccb 2020-04-14 stsp break
1098 f7b97ccb 2020-04-14 stsp fi
1099 f7b97ccb 2020-04-14 stsp done
1100 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1101 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1102 e7303626 2020-05-14 stsp return 1
1103 e7303626 2020-05-14 stsp fi
1104 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1105 e7303626 2020-05-14 stsp }
1106 e7303626 2020-05-14 stsp
1107 f6cae3ed 2020-09-13 naddy test_commit_with_unrelated_submodule() {
1108 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
1109 e7303626 2020-05-14 stsp
1110 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1111 e7303626 2020-05-14 stsp
1112 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
1113 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
1114 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1115 e7303626 2020-05-14 stsp
1116 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1117 49c543a6 2022-03-31 naddy ret=$?
1118 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1119 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
1120 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1121 e7303626 2020-05-14 stsp return 1
1122 e7303626 2020-05-14 stsp fi
1123 e7303626 2020-05-14 stsp
1124 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
1125 e7303626 2020-05-14 stsp
1126 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
1127 7aadece8 2020-05-17 stsp
1128 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1129 49c543a6 2022-03-31 naddy ret=$?
1130 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1131 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
1132 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
1133 f7b97ccb 2020-04-14 stsp return 1
1134 f7b97ccb 2020-04-14 stsp fi
1135 e7303626 2020-05-14 stsp
1136 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
1137 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
1138 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1139 3d9a4ec4 2020-07-23 stsp
1140 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1141 49c543a6 2022-03-31 naddy ret=$?
1142 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1143 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1144 3d9a4ec4 2020-07-23 stsp fi
1145 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1146 3d9a4ec4 2020-07-23 stsp }
1147 3d9a4ec4 2020-07-23 stsp
1148 f6cae3ed 2020-09-13 naddy check_symlinks() {
1149 bd6aa359 2020-07-23 stsp local wtpath="$1"
1150 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
1151 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
1152 bd6aa359 2020-07-23 stsp return 1
1153 bd6aa359 2020-07-23 stsp fi
1154 3d9a4ec4 2020-07-23 stsp
1155 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
1156 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1157 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1158 49c543a6 2022-03-31 naddy ret=$?
1159 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1160 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1161 3d9a4ec4 2020-07-23 stsp return 1
1162 3d9a4ec4 2020-07-23 stsp fi
1163 3d9a4ec4 2020-07-23 stsp
1164 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
1165 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
1166 bd6aa359 2020-07-23 stsp return 1
1167 bd6aa359 2020-07-23 stsp fi
1168 3d9a4ec4 2020-07-23 stsp
1169 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
1170 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1171 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1172 49c543a6 2022-03-31 naddy ret=$?
1173 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1174 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1175 3d9a4ec4 2020-07-23 stsp return 1
1176 3d9a4ec4 2020-07-23 stsp fi
1177 3d9a4ec4 2020-07-23 stsp
1178 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
1179 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1180 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
1181 bd6aa359 2020-07-23 stsp return 1
1182 bd6aa359 2020-07-23 stsp fi
1183 bd6aa359 2020-07-23 stsp
1184 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1185 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
1186 49c543a6 2022-03-31 naddy ret=$?
1187 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1188 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
1189 3d9a4ec4 2020-07-23 stsp return 1
1190 3d9a4ec4 2020-07-23 stsp fi
1191 3d9a4ec4 2020-07-23 stsp
1192 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1193 49c543a6 2022-03-31 naddy ret=$?
1194 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1195 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1196 3d9a4ec4 2020-07-23 stsp return 1
1197 3d9a4ec4 2020-07-23 stsp fi
1198 3d9a4ec4 2020-07-23 stsp
1199 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
1200 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1201 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1202 49c543a6 2022-03-31 naddy ret=$?
1203 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1204 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1205 3d9a4ec4 2020-07-23 stsp return 1
1206 3d9a4ec4 2020-07-23 stsp fi
1207 7aadece8 2020-05-17 stsp
1208 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
1209 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1210 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1211 49c543a6 2022-03-31 naddy ret=$?
1212 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1213 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1214 3d9a4ec4 2020-07-23 stsp return 1
1215 e7303626 2020-05-14 stsp fi
1216 3d9a4ec4 2020-07-23 stsp
1217 bd6aa359 2020-07-23 stsp return 0
1218 bd6aa359 2020-07-23 stsp }
1219 3d9a4ec4 2020-07-23 stsp
1220 f6cae3ed 2020-09-13 naddy test_commit_symlink() {
1221 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
1222 3d9a4ec4 2020-07-23 stsp
1223 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1224 49c543a6 2022-03-31 naddy ret=$?
1225 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1226 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1227 3d9a4ec4 2020-07-23 stsp return 1
1228 3d9a4ec4 2020-07-23 stsp fi
1229 3d9a4ec4 2020-07-23 stsp
1230 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
1231 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
1232 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1233 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1234 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1235 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1236 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
1237 bd6aa359 2020-07-23 stsp
1238 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1239 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1240 49c543a6 2022-03-31 naddy ret=$?
1241 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1242 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1243 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1244 35213c7c 2020-07-23 stsp return 1
1245 35213c7c 2020-07-23 stsp fi
1246 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1247 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1248 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1249 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1250 49c543a6 2022-03-31 naddy ret=$?
1251 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1252 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1253 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1254 35213c7c 2020-07-23 stsp return 1
1255 35213c7c 2020-07-23 stsp fi
1256 bd6aa359 2020-07-23 stsp
1257 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1258 35213c7c 2020-07-23 stsp > $testroot/stdout)
1259 35213c7c 2020-07-23 stsp
1260 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1261 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1262 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1263 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1264 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1265 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1266 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1267 bd6aa359 2020-07-23 stsp
1268 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1269 49c543a6 2022-03-31 naddy ret=$?
1270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1271 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1272 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1273 3d9a4ec4 2020-07-23 stsp return 1
1274 3d9a4ec4 2020-07-23 stsp fi
1275 3d9a4ec4 2020-07-23 stsp
1276 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1277 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1278 49c543a6 2022-03-31 naddy ret=$?
1279 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1280 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1281 bd6aa359 2020-07-23 stsp return 1
1282 3d9a4ec4 2020-07-23 stsp fi
1283 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1284 49c543a6 2022-03-31 naddy ret=$?
1285 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1286 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1287 bd6aa359 2020-07-23 stsp return 1
1288 bd6aa359 2020-07-23 stsp fi
1289 bd6aa359 2020-07-23 stsp
1290 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1291 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1292 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1293 75f0a0fb 2020-07-23 stsp return 1
1294 75f0a0fb 2020-07-23 stsp fi
1295 75f0a0fb 2020-07-23 stsp
1296 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1297 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1298 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1299 49c543a6 2022-03-31 naddy ret=$?
1300 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1301 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1302 5a1fbc73 2020-07-23 stsp return 1
1303 5a1fbc73 2020-07-23 stsp fi
1304 88fb31d4 2020-07-23 stsp
1305 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1306 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
1307 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1308 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1309 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1310 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1311 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1312 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1313 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1314 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1315 88fb31d4 2020-07-23 stsp
1316 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1317 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1318 49c543a6 2022-03-31 naddy ret=$?
1319 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1320 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1321 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1322 35213c7c 2020-07-23 stsp return 1
1323 35213c7c 2020-07-23 stsp fi
1324 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1325 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1326 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1327 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1328 49c543a6 2022-03-31 naddy ret=$?
1329 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1330 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1331 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1332 35213c7c 2020-07-23 stsp return 1
1333 35213c7c 2020-07-23 stsp fi
1334 88fb31d4 2020-07-23 stsp
1335 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1336 35213c7c 2020-07-23 stsp > $testroot/stdout)
1337 35213c7c 2020-07-23 stsp
1338 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1339 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1340 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1341 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1342 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1343 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1344 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1345 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1346 88fb31d4 2020-07-23 stsp
1347 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1348 49c543a6 2022-03-31 naddy ret=$?
1349 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1350 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1351 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1352 88fb31d4 2020-07-23 stsp return 1
1353 88fb31d4 2020-07-23 stsp fi
1354 88fb31d4 2020-07-23 stsp
1355 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1356 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1357 88fb31d4 2020-07-23 stsp alpha
1358 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1359 88fb31d4 2020-07-23 stsp beta
1360 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1361 88fb31d4 2020-07-23 stsp epsilon/
1362 88fb31d4 2020-07-23 stsp epsilon/beta.link
1363 88fb31d4 2020-07-23 stsp epsilon/zeta
1364 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1365 88fb31d4 2020-07-23 stsp gamma/
1366 88fb31d4 2020-07-23 stsp gamma/delta
1367 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1368 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1369 88fb31d4 2020-07-23 stsp EOF
1370 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1371 49c543a6 2022-03-31 naddy ret=$?
1372 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1373 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1374 88fb31d4 2020-07-23 stsp fi
1375 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1376 5a1fbc73 2020-07-23 stsp }
1377 5a1fbc73 2020-07-23 stsp
1378 f6cae3ed 2020-09-13 naddy test_commit_fix_bad_symlink() {
1379 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1380 5a1fbc73 2020-07-23 stsp
1381 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1382 49c543a6 2022-03-31 naddy ret=$?
1383 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1384 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1385 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1386 5a1fbc73 2020-07-23 stsp return 1
1387 5a1fbc73 2020-07-23 stsp fi
1388 5a1fbc73 2020-07-23 stsp
1389 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1390 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1391 5a1fbc73 2020-07-23 stsp
1392 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1393 35213c7c 2020-07-23 stsp > $testroot/stdout)
1394 5a1fbc73 2020-07-23 stsp
1395 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1396 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1397 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1398 75f0a0fb 2020-07-23 stsp return 1
1399 75f0a0fb 2020-07-23 stsp fi
1400 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1401 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1402 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1403 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1404 5a1fbc73 2020-07-23 stsp return 1
1405 5a1fbc73 2020-07-23 stsp fi
1406 5a1fbc73 2020-07-23 stsp
1407 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1408 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1409 49c543a6 2022-03-31 naddy ret=$?
1410 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1411 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1412 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1413 5a1fbc73 2020-07-23 stsp return 1
1414 5a1fbc73 2020-07-23 stsp fi
1415 5a1fbc73 2020-07-23 stsp
1416 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1417 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -sfh alpha passwd.link)
1418 5a1fbc73 2020-07-23 stsp
1419 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1420 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1421 5a1fbc73 2020-07-23 stsp
1422 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1423 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1424 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1425 5a1fbc73 2020-07-23 stsp
1426 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1427 49c543a6 2022-03-31 naddy ret=$?
1428 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1429 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1430 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1431 bd6aa359 2020-07-23 stsp return 1
1432 bd6aa359 2020-07-23 stsp fi
1433 5a1fbc73 2020-07-23 stsp
1434 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1435 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1436 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1437 5a1fbc73 2020-07-23 stsp return 1
1438 5a1fbc73 2020-07-23 stsp fi
1439 5a1fbc73 2020-07-23 stsp
1440 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1441 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1442 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1443 49c543a6 2022-03-31 naddy ret=$?
1444 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1445 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1446 5a1fbc73 2020-07-23 stsp return 1
1447 5a1fbc73 2020-07-23 stsp fi
1448 5a1fbc73 2020-07-23 stsp
1449 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1450 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1451 49c543a6 2022-03-31 naddy ret=$?
1452 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1453 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1454 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1455 5a1fbc73 2020-07-23 stsp return 1
1456 5a1fbc73 2020-07-23 stsp fi
1457 5a1fbc73 2020-07-23 stsp
1458 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1459 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1460 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1461 5a1fbc73 2020-07-23 stsp return 1
1462 5a1fbc73 2020-07-23 stsp fi
1463 5a1fbc73 2020-07-23 stsp
1464 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1465 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1466 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1467 49c543a6 2022-03-31 naddy ret=$?
1468 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1469 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1470 5a1fbc73 2020-07-23 stsp return 1
1471 5a1fbc73 2020-07-23 stsp fi
1472 5a1fbc73 2020-07-23 stsp
1473 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1474 1ebedb77 2019-10-19 stsp }
1475 28cf319f 2021-01-28 stsp
1476 28cf319f 2021-01-28 stsp test_commit_prepared_logmsg() {
1477 28cf319f 2021-01-28 stsp local testroot=`test_init commit_prepared_logmsg`
1478 28cf319f 2021-01-28 stsp
1479 28cf319f 2021-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1480 49c543a6 2022-03-31 naddy ret=$?
1481 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1482 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1483 28cf319f 2021-01-28 stsp return 1
1484 28cf319f 2021-01-28 stsp fi
1485 28cf319f 2021-01-28 stsp
1486 28cf319f 2021-01-28 stsp echo "modified alpha" > $testroot/wt/alpha
1487 28cf319f 2021-01-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
1488 28cf319f 2021-01-28 stsp echo "new file" > $testroot/wt/new
1489 28cf319f 2021-01-28 stsp (cd $testroot/wt && got add new >/dev/null)
1490 28cf319f 2021-01-28 stsp
1491 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg' > $testroot/logmsg
1492 28cf319f 2021-01-28 stsp
1493 28cf319f 2021-01-28 stsp cat > $testroot/editor.sh <<EOF
1494 28cf319f 2021-01-28 stsp #!/bin/sh
1495 28cf319f 2021-01-28 stsp sed -i 's/foo/bar/' "\$1"
1496 28cf319f 2021-01-28 stsp EOF
1497 28cf319f 2021-01-28 stsp chmod +x $testroot/editor.sh
1498 28cf319f 2021-01-28 stsp
1499 8e09a168 2021-06-17 tracey (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1500 28cf319f 2021-01-28 stsp got commit -F "$testroot/logmsg" > $testroot/stdout)
1501 1ebedb77 2019-10-19 stsp
1502 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1503 28cf319f 2021-01-28 stsp echo "A new" > $testroot/stdout.expected
1504 28cf319f 2021-01-28 stsp echo "M alpha" >> $testroot/stdout.expected
1505 28cf319f 2021-01-28 stsp echo "D beta" >> $testroot/stdout.expected
1506 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1507 28cf319f 2021-01-28 stsp
1508 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1509 49c543a6 2022-03-31 naddy ret=$?
1510 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1511 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1512 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1513 28cf319f 2021-01-28 stsp return 1
1514 28cf319f 2021-01-28 stsp fi
1515 28cf319f 2021-01-28 stsp
1516 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1517 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1518 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" > $testroot/stdout.expected
1519 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1520 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1521 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1522 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1523 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1524 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1525 28cf319f 2021-01-28 stsp
1526 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1527 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1528 49c543a6 2022-03-31 naddy ret=$?
1529 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1530 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1531 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1532 28cf319f 2021-01-28 stsp return 1
1533 28cf319f 2021-01-28 stsp fi
1534 28cf319f 2021-01-28 stsp
1535 28cf319f 2021-01-28 stsp echo "modified alpha again" > $testroot/wt/alpha
1536 28cf319f 2021-01-28 stsp
1537 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg non-interactive' \
1538 28cf319f 2021-01-28 stsp > $testroot/logmsg
1539 28cf319f 2021-01-28 stsp
1540 28cf319f 2021-01-28 stsp (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1541 28cf319f 2021-01-28 stsp > $testroot/stdout)
1542 28cf319f 2021-01-28 stsp
1543 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1544 28cf319f 2021-01-28 stsp echo "M alpha" > $testroot/stdout.expected
1545 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1546 28cf319f 2021-01-28 stsp
1547 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1548 49c543a6 2022-03-31 naddy ret=$?
1549 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1550 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1551 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1552 28cf319f 2021-01-28 stsp return 1
1553 28cf319f 2021-01-28 stsp fi
1554 28cf319f 2021-01-28 stsp
1555 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1556 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1557 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" \
1558 28cf319f 2021-01-28 stsp > $testroot/stdout.expected
1559 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1560 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1561 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1562 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1563 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg non-interactive" \
1564 28cf319f 2021-01-28 stsp >> $testroot/stdout.expected
1565 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1566 28cf319f 2021-01-28 stsp
1567 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1568 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1569 49c543a6 2022-03-31 naddy ret=$?
1570 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1571 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1572 28cf319f 2021-01-28 stsp fi
1573 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1574 28cf319f 2021-01-28 stsp }
1575 72840534 2022-01-19 stsp
1576 72840534 2022-01-19 stsp test_commit_large_file() {
1577 72840534 2022-01-19 stsp local testroot=`test_init commit_large_file`
1578 72840534 2022-01-19 stsp
1579 72840534 2022-01-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1580 49c543a6 2022-03-31 naddy ret=$?
1581 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1582 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1583 72840534 2022-01-19 stsp return 1
1584 72840534 2022-01-19 stsp fi
1585 72840534 2022-01-19 stsp
1586 230e1f1b 2022-07-05 stsp dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1587 72840534 2022-01-19 stsp (cd $testroot/wt && got add new >/dev/null)
1588 28cf319f 2021-01-28 stsp
1589 72840534 2022-01-19 stsp (cd $testroot/wt && got commit -m 'test commit_large_file' \
1590 72840534 2022-01-19 stsp > $testroot/stdout)
1591 72840534 2022-01-19 stsp
1592 72840534 2022-01-19 stsp local head_rev=`git_show_head $testroot/repo`
1593 72840534 2022-01-19 stsp echo "A new" > $testroot/stdout.expected
1594 72840534 2022-01-19 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1595 72840534 2022-01-19 stsp
1596 72840534 2022-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1597 49c543a6 2022-03-31 naddy ret=$?
1598 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1599 72840534 2022-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1600 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1601 72840534 2022-01-19 stsp return 1
1602 72840534 2022-01-19 stsp fi
1603 72840534 2022-01-19 stsp
1604 72840534 2022-01-19 stsp new_id=`get_blob_id $testroot/repo "" new`
1605 72840534 2022-01-19 stsp got cat -r $testroot/repo $new_id > $testroot/new
1606 49c543a6 2022-03-31 naddy ret=$?
1607 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1608 72840534 2022-01-19 stsp echo "commit failed unexpectedly" >&2
1609 72840534 2022-01-19 stsp test_done "$testroot" "1"
1610 72840534 2022-01-19 stsp return 1
1611 72840534 2022-01-19 stsp fi
1612 72840534 2022-01-19 stsp
1613 72840534 2022-01-19 stsp cmp -s $testroot/new $testroot/wt/new
1614 49c543a6 2022-03-31 naddy ret=$?
1615 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1616 72840534 2022-01-19 stsp diff -u $testroot/new $testroot/wt/new
1617 72840534 2022-01-19 stsp fi
1618 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1619 4ba2e955 2022-09-02 sh+got
1620 4ba2e955 2022-09-02 sh+got
1621 4ba2e955 2022-09-02 sh+got }
1622 4ba2e955 2022-09-02 sh+got
1623 4ba2e955 2022-09-02 sh+got test_commit_gitignore() {
1624 4ba2e955 2022-09-02 sh+got local testroot=`test_init commit_gitignores`
1625 4ba2e955 2022-09-02 sh+got
1626 4ba2e955 2022-09-02 sh+got got checkout $testroot/repo $testroot/wt > /dev/null
1627 4ba2e955 2022-09-02 sh+got ret=$?
1628 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1629 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1630 4ba2e955 2022-09-02 sh+got return 1
1631 4ba2e955 2022-09-02 sh+got fi
1632 4ba2e955 2022-09-02 sh+got
1633 4ba2e955 2022-09-02 sh+got mkdir -p $testroot/wt/tree1/foo
1634 4ba2e955 2022-09-02 sh+got mkdir -p $testroot/wt/tree2/foo
1635 4ba2e955 2022-09-02 sh+got echo "tree1/**" > $testroot/wt/.gitignore
1636 4ba2e955 2022-09-02 sh+got echo "tree2/**" >> $testroot/wt/.gitignore
1637 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree1/bar
1638 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree1/foo/baz
1639 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree2/bar
1640 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree2/foo/baz
1641 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/epsilon/zeta1
1642 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/epsilon/zeta2
1643 4ba2e955 2022-09-02 sh+got
1644 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got add -I -R tree1 > /dev/null)
1645 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got add -I tree2/foo/baz > /dev/null)
1646 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got commit -m "gitignore add" > /dev/null)
1647 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1648 4ba2e955 2022-09-02 sh+got
1649 4ba2e955 2022-09-02 sh+got echo ' gitignore add' > $testroot/stdout.expected
1650 4ba2e955 2022-09-02 sh+got echo ' A tree1/bar' >> $testroot/stdout.expected
1651 4ba2e955 2022-09-02 sh+got echo ' A tree1/foo/baz' >> $testroot/stdout.expected
1652 4ba2e955 2022-09-02 sh+got echo ' A tree2/foo/baz' >> $testroot/stdout.expected
1653 72840534 2022-01-19 stsp
1654 4ba2e955 2022-09-02 sh+got cmp -s $testroot/stdout.expected $testroot/stdout
1655 4ba2e955 2022-09-02 sh+got ret=$?
1656 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1657 4ba2e955 2022-09-02 sh+got diff -u $testroot/stdout.expected $testroot/stdout
1658 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1659 4ba2e955 2022-09-02 sh+got return 1
1660 4ba2e955 2022-09-02 sh+got fi
1661 72840534 2022-01-19 stsp
1662 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/tree1/bar
1663 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/tree1/foo/baz
1664 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/epsilon/zeta1
1665 4ba2e955 2022-09-02 sh+got
1666 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got commit -m "gitignore change" > /dev/null)
1667 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1668 4ba2e955 2022-09-02 sh+got
1669 4ba2e955 2022-09-02 sh+got echo ' gitignore change' > $testroot/stdout.expected
1670 4ba2e955 2022-09-02 sh+got echo ' M tree1/bar' >> $testroot/stdout.expected
1671 4ba2e955 2022-09-02 sh+got echo ' M tree1/foo/baz' >> $testroot/stdout.expected
1672 4ba2e955 2022-09-02 sh+got
1673 4ba2e955 2022-09-02 sh+got cmp -s $testroot/stdout.expected $testroot/stdout
1674 4ba2e955 2022-09-02 sh+got ret=$?
1675 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1676 4ba2e955 2022-09-02 sh+got diff -u $testroot/stdout.expected $testroot/stdout
1677 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1678 4ba2e955 2022-09-02 sh+got return 1
1679 4ba2e955 2022-09-02 sh+got fi
1680 4ba2e955 2022-09-02 sh+got
1681 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1682 72840534 2022-01-19 stsp }
1683 21f07726 2022-10-31 stsp
1684 21f07726 2022-10-31 stsp test_commit_bad_author() {
1685 21f07726 2022-10-31 stsp local testroot=`test_init commit_bad_author`
1686 21f07726 2022-10-31 stsp
1687 21f07726 2022-10-31 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1688 21f07726 2022-10-31 stsp ret=$?
1689 21f07726 2022-10-31 stsp if [ $ret -ne 0 ]; then
1690 21f07726 2022-10-31 stsp test_done "$testroot" $ret
1691 21f07726 2022-10-31 stsp return 1
1692 21f07726 2022-10-31 stsp fi
1693 21f07726 2022-10-31 stsp
1694 21f07726 2022-10-31 stsp echo "modified alpha" > $testroot/wt/alpha
1695 21f07726 2022-10-31 stsp
1696 21f07726 2022-10-31 stsp (cd $testroot/wt && got commit \
1697 21f07726 2022-10-31 stsp -A "${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>" -m 'edit alpha') \
1698 21f07726 2022-10-31 stsp > /dev/null 2> $testroot/stderr
1699 21f07726 2022-10-31 stsp ret=$?
1700 21f07726 2022-10-31 stsp if [ $ret -eq 0 ]; then
1701 21f07726 2022-10-31 stsp test_done "$testroot" 1
1702 21f07726 2022-10-31 stsp return 1
1703 21f07726 2022-10-31 stsp fi
1704 72840534 2022-01-19 stsp
1705 21f07726 2022-10-31 stsp echo -n "got: ${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>: " \
1706 21f07726 2022-10-31 stsp > $testroot/stderr.expected
1707 21f07726 2022-10-31 stsp echo -n 'space between author name and email required: ' \
1708 21f07726 2022-10-31 stsp >> $testroot/stderr.expected
1709 21f07726 2022-10-31 stsp echo 'commit author formatting would make Git unhappy' \
1710 21f07726 2022-10-31 stsp >> $testroot/stderr.expected
1711 21f07726 2022-10-31 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1712 21f07726 2022-10-31 stsp ret=$?
1713 21f07726 2022-10-31 stsp if [ $ret -ne 0 ]; then
1714 21f07726 2022-10-31 stsp diff -u $testroot/stderr.expected $testroot/stderr
1715 21f07726 2022-10-31 stsp test_done "$testroot" $ret
1716 21f07726 2022-10-31 stsp return 1
1717 21f07726 2022-10-31 stsp fi
1718 72840534 2022-01-19 stsp
1719 21f07726 2022-10-31 stsp test_done "$testroot" 0
1720 21f07726 2022-10-31 stsp }
1721 21f07726 2022-10-31 stsp
1722 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1723 c4296144 2019-05-09 stsp run_test test_commit_basic
1724 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
1725 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
1726 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
1727 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
1728 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
1729 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
1730 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
1731 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
1732 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
1733 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
1734 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
1735 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
1736 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
1737 84792843 2019-08-09 stsp run_test test_commit_no_email
1738 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
1739 62b21d33 2022-07-19 op run_test test_commit_cmdline_author
1740 257add31 2020-09-09 stsp run_test test_commit_gotconfig_author
1741 50b0790e 2020-09-11 stsp run_test test_commit_gotconfig_worktree_author
1742 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
1743 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
1744 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
1745 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
1746 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
1747 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink
1748 28cf319f 2021-01-28 stsp run_test test_commit_prepared_logmsg
1749 72840534 2022-01-19 stsp run_test test_commit_large_file
1750 4ba2e955 2022-09-02 sh+got run_test test_commit_gitignore
1751 21f07726 2022-10-31 stsp run_test test_commit_bad_author