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 local author="Foo <foo@example.com>"
768 62b21d33 2022-07-19 op (cd $testroot/wt && got commit -A "$author" -m 'edit alpha') \
769 62b21d33 2022-07-19 op > /dev/null
770 62b21d33 2022-07-19 op ret=$?
771 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
772 62b21d33 2022-07-19 op test_done "$testroot" $ret
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 (cd $testroot/repo && got log -l1 | egrep '^(from|via):') \
777 62b21d33 2022-07-19 op > $testroot/stdout
778 62b21d33 2022-07-19 op ret=$?
779 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
780 62b21d33 2022-07-19 op test_done "$testroot" $ret
781 62b21d33 2022-07-19 op return 1
782 62b21d33 2022-07-19 op fi
783 62b21d33 2022-07-19 op
784 62b21d33 2022-07-19 op echo "from: $author" > $testroot/stdout.expected
785 62b21d33 2022-07-19 op echo "via: $GOT_AUTHOR" >> $testroot/stdout.expected
786 62b21d33 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
787 62b21d33 2022-07-19 op ret=$?
788 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
789 62b21d33 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
790 62b21d33 2022-07-19 op fi
791 62b21d33 2022-07-19 op test_done "$testroot" $ret
792 257add31 2020-09-09 stsp }
793 257add31 2020-09-09 stsp
794 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_author() {
795 257add31 2020-09-09 stsp local testroot=`test_init commit_gotconfig_author`
796 257add31 2020-09-09 stsp
797 257add31 2020-09-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
798 49c543a6 2022-03-31 naddy ret=$?
799 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
800 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
801 257add31 2020-09-09 stsp return 1
802 257add31 2020-09-09 stsp fi
803 257add31 2020-09-09 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
804 257add31 2020-09-09 stsp > $testroot/repo/.git/got.conf
805 257add31 2020-09-09 stsp
806 257add31 2020-09-09 stsp echo "modified alpha" > $testroot/wt/alpha
807 257add31 2020-09-09 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
808 49c543a6 2022-03-31 naddy ret=$?
809 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
810 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
811 257add31 2020-09-09 stsp return 1
812 257add31 2020-09-09 stsp fi
813 257add31 2020-09-09 stsp
814 257add31 2020-09-09 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
815 49c543a6 2022-03-31 naddy ret=$?
816 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
817 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
818 257add31 2020-09-09 stsp return 1
819 257add31 2020-09-09 stsp fi
820 257add31 2020-09-09 stsp
821 257add31 2020-09-09 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
822 50b0790e 2020-09-11 stsp > $testroot/stdout.expected
823 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
824 49c543a6 2022-03-31 naddy ret=$?
825 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
826 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
827 50b0790e 2020-09-11 stsp fi
828 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
829 50b0790e 2020-09-11 stsp }
830 50b0790e 2020-09-11 stsp
831 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_worktree_author() {
832 50b0790e 2020-09-11 stsp local testroot=`test_init commit_gotconfig_worktree_author`
833 50b0790e 2020-09-11 stsp
834 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
835 49c543a6 2022-03-31 naddy ret=$?
836 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
837 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
838 50b0790e 2020-09-11 stsp return 1
839 50b0790e 2020-09-11 stsp fi
840 50b0790e 2020-09-11 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
841 50b0790e 2020-09-11 stsp > $testroot/repo/.git/got.conf
842 50b0790e 2020-09-11 stsp echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
843 50b0790e 2020-09-11 stsp > $testroot/wt/.got/got.conf
844 50b0790e 2020-09-11 stsp
845 50b0790e 2020-09-11 stsp echo "modified alpha" > $testroot/wt/alpha
846 50b0790e 2020-09-11 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
847 49c543a6 2022-03-31 naddy ret=$?
848 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
849 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
850 50b0790e 2020-09-11 stsp return 1
851 50b0790e 2020-09-11 stsp fi
852 50b0790e 2020-09-11 stsp
853 50b0790e 2020-09-11 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
854 49c543a6 2022-03-31 naddy ret=$?
855 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
856 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
857 50b0790e 2020-09-11 stsp return 1
858 50b0790e 2020-09-11 stsp fi
859 50b0790e 2020-09-11 stsp
860 50b0790e 2020-09-11 stsp echo "from: Flan Squee <flan_squee@openbsd.org>" \
861 257add31 2020-09-09 stsp > $testroot/stdout.expected
862 257add31 2020-09-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
863 49c543a6 2022-03-31 naddy ret=$?
864 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
865 257add31 2020-09-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
866 257add31 2020-09-09 stsp fi
867 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
868 6af1ccbd 2019-08-16 stsp }
869 aba9c984 2019-09-08 stsp
870 f6cae3ed 2020-09-13 naddy test_commit_gitconfig_author() {
871 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
872 84792843 2019-08-09 stsp
873 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
874 49c543a6 2022-03-31 naddy ret=$?
875 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
876 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
877 aba9c984 2019-09-08 stsp return 1
878 aba9c984 2019-09-08 stsp fi
879 aba9c984 2019-09-08 stsp
880 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
881 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
882 aba9c984 2019-09-08 stsp
883 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
884 7370f802 2022-07-24 op
885 7370f802 2022-07-24 op # unset in a subshell to avoid affecting our environment
886 7370f802 2022-07-24 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
887 7370f802 2022-07-24 op got commit -m 'test gitconfig author' > /dev/null)
888 49c543a6 2022-03-31 naddy ret=$?
889 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
890 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
891 aba9c984 2019-09-08 stsp return 1
892 aba9c984 2019-09-08 stsp fi
893 aba9c984 2019-09-08 stsp
894 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
895 49c543a6 2022-03-31 naddy ret=$?
896 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
897 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
898 aba9c984 2019-09-08 stsp return 1
899 aba9c984 2019-09-08 stsp fi
900 aba9c984 2019-09-08 stsp
901 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
902 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
903 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
904 49c543a6 2022-03-31 naddy ret=$?
905 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
906 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
907 aba9c984 2019-09-08 stsp fi
908 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
909 aba9c984 2019-09-08 stsp }
910 1ebedb77 2019-10-19 stsp
911 f6cae3ed 2020-09-13 naddy test_commit_xbit_change() {
912 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
913 1ebedb77 2019-10-19 stsp
914 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
915 49c543a6 2022-03-31 naddy ret=$?
916 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
917 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
918 1ebedb77 2019-10-19 stsp return 1
919 1ebedb77 2019-10-19 stsp fi
920 1ebedb77 2019-10-19 stsp
921 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
922 1ebedb77 2019-10-19 stsp
923 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
924 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
925 aba9c984 2019-09-08 stsp
926 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
927 49c543a6 2022-03-31 naddy ret=$?
928 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
929 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
930 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
931 1ebedb77 2019-10-19 stsp return 1
932 1ebedb77 2019-10-19 stsp fi
933 1ebedb77 2019-10-19 stsp
934 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
935 49c543a6 2022-03-31 naddy ret=$?
936 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
937 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
938 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
939 1ebedb77 2019-10-19 stsp return 1
940 1ebedb77 2019-10-19 stsp fi
941 1ebedb77 2019-10-19 stsp
942 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
943 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
944 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
945 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
946 49c543a6 2022-03-31 naddy ret=$?
947 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
948 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
949 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
950 1ebedb77 2019-10-19 stsp return 1
951 1ebedb77 2019-10-19 stsp fi
952 1ebedb77 2019-10-19 stsp
953 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
954 1ebedb77 2019-10-19 stsp
955 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
956 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
957 49c543a6 2022-03-31 naddy ret=$?
958 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
959 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
960 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
961 1ebedb77 2019-10-19 stsp return 1
962 1ebedb77 2019-10-19 stsp fi
963 1ebedb77 2019-10-19 stsp
964 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
965 1ebedb77 2019-10-19 stsp
966 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
967 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
968 1ebedb77 2019-10-19 stsp
969 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
970 49c543a6 2022-03-31 naddy ret=$?
971 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
972 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
973 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
974 1ebedb77 2019-10-19 stsp return 1
975 1ebedb77 2019-10-19 stsp fi
976 1ebedb77 2019-10-19 stsp
977 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
978 49c543a6 2022-03-31 naddy ret=$?
979 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
980 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
981 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
982 1ebedb77 2019-10-19 stsp return 1
983 1ebedb77 2019-10-19 stsp fi
984 1ebedb77 2019-10-19 stsp
985 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
986 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
987 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
988 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
989 49c543a6 2022-03-31 naddy ret=$?
990 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
991 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
992 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
993 1ebedb77 2019-10-19 stsp return 1
994 1ebedb77 2019-10-19 stsp fi
995 1ebedb77 2019-10-19 stsp
996 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
997 1ebedb77 2019-10-19 stsp
998 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
999 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1000 f7b97ccb 2020-04-14 stsp
1001 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1002 49c543a6 2022-03-31 naddy ret=$?
1003 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1004 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1005 f7b97ccb 2020-04-14 stsp fi
1006 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1007 f7b97ccb 2020-04-14 stsp }
1008 f7b97ccb 2020-04-14 stsp
1009 f6cae3ed 2020-09-13 naddy commit_check_mode() {
1010 f7b97ccb 2020-04-14 stsp local mode="$1"
1011 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
1012 f7b97ccb 2020-04-14 stsp
1013 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
1014 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
1015 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
1016 f7b97ccb 2020-04-14 stsp
1017 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
1018 49c543a6 2022-03-31 naddy ret=$?
1019 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1020 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
1021 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1022 f7b97ccb 2020-04-14 stsp return 1
1023 f7b97ccb 2020-04-14 stsp fi
1024 1ebedb77 2019-10-19 stsp
1025 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
1026 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
1027 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1028 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1029 49c543a6 2022-03-31 naddy ret=$?
1030 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1031 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1032 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1033 a9662115 2021-08-29 naddy return 1
1034 f7b97ccb 2020-04-14 stsp fi
1035 f7b97ccb 2020-04-14 stsp
1036 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
1037 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
1038 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
1039 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
1040 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
1041 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
1042 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1043 49c543a6 2022-03-31 naddy ret=$?
1044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1045 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1046 1ebedb77 2019-10-19 stsp fi
1047 f7b97ccb 2020-04-14 stsp return $ret
1048 f7b97ccb 2020-04-14 stsp }
1049 f7b97ccb 2020-04-14 stsp
1050 f6cae3ed 2020-09-13 naddy test_commit_normalizes_filemodes() {
1051 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
1052 f7b97ccb 2020-04-14 stsp
1053 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1054 49c543a6 2022-03-31 naddy ret=$?
1055 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1056 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1057 f7b97ccb 2020-04-14 stsp return 1
1058 f7b97ccb 2020-04-14 stsp fi
1059 f7b97ccb 2020-04-14 stsp
1060 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
1061 f7b97ccb 2020-04-14 stsp for m in $modes; do
1062 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
1063 49c543a6 2022-03-31 naddy ret=$?
1064 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1065 f7b97ccb 2020-04-14 stsp break
1066 f7b97ccb 2020-04-14 stsp fi
1067 f7b97ccb 2020-04-14 stsp done
1068 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1069 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1070 f7b97ccb 2020-04-14 stsp return 1
1071 f7b97ccb 2020-04-14 stsp fi
1072 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
1073 f7b97ccb 2020-04-14 stsp for m in $modes; do
1074 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
1075 49c543a6 2022-03-31 naddy ret=$?
1076 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1077 f7b97ccb 2020-04-14 stsp break
1078 f7b97ccb 2020-04-14 stsp fi
1079 f7b97ccb 2020-04-14 stsp done
1080 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1081 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1082 e7303626 2020-05-14 stsp return 1
1083 e7303626 2020-05-14 stsp fi
1084 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1085 e7303626 2020-05-14 stsp }
1086 e7303626 2020-05-14 stsp
1087 f6cae3ed 2020-09-13 naddy test_commit_with_unrelated_submodule() {
1088 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
1089 e7303626 2020-05-14 stsp
1090 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1091 e7303626 2020-05-14 stsp
1092 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
1093 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
1094 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1095 e7303626 2020-05-14 stsp
1096 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1097 49c543a6 2022-03-31 naddy ret=$?
1098 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1099 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
1100 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1101 e7303626 2020-05-14 stsp return 1
1102 e7303626 2020-05-14 stsp fi
1103 e7303626 2020-05-14 stsp
1104 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
1105 e7303626 2020-05-14 stsp
1106 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
1107 7aadece8 2020-05-17 stsp
1108 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1109 49c543a6 2022-03-31 naddy ret=$?
1110 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1111 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
1112 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
1113 f7b97ccb 2020-04-14 stsp return 1
1114 f7b97ccb 2020-04-14 stsp fi
1115 e7303626 2020-05-14 stsp
1116 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
1117 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
1118 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1119 3d9a4ec4 2020-07-23 stsp
1120 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1121 49c543a6 2022-03-31 naddy ret=$?
1122 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1123 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1124 3d9a4ec4 2020-07-23 stsp fi
1125 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1126 3d9a4ec4 2020-07-23 stsp }
1127 3d9a4ec4 2020-07-23 stsp
1128 f6cae3ed 2020-09-13 naddy check_symlinks() {
1129 bd6aa359 2020-07-23 stsp local wtpath="$1"
1130 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
1131 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
1132 bd6aa359 2020-07-23 stsp return 1
1133 bd6aa359 2020-07-23 stsp fi
1134 3d9a4ec4 2020-07-23 stsp
1135 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
1136 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1137 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1138 49c543a6 2022-03-31 naddy ret=$?
1139 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1140 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1141 3d9a4ec4 2020-07-23 stsp return 1
1142 3d9a4ec4 2020-07-23 stsp fi
1143 3d9a4ec4 2020-07-23 stsp
1144 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
1145 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
1146 bd6aa359 2020-07-23 stsp return 1
1147 bd6aa359 2020-07-23 stsp fi
1148 3d9a4ec4 2020-07-23 stsp
1149 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
1150 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1151 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1152 49c543a6 2022-03-31 naddy ret=$?
1153 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1154 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1155 3d9a4ec4 2020-07-23 stsp return 1
1156 3d9a4ec4 2020-07-23 stsp fi
1157 3d9a4ec4 2020-07-23 stsp
1158 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
1159 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1160 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
1161 bd6aa359 2020-07-23 stsp return 1
1162 bd6aa359 2020-07-23 stsp fi
1163 bd6aa359 2020-07-23 stsp
1164 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1165 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
1166 49c543a6 2022-03-31 naddy ret=$?
1167 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1168 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
1169 3d9a4ec4 2020-07-23 stsp return 1
1170 3d9a4ec4 2020-07-23 stsp fi
1171 3d9a4ec4 2020-07-23 stsp
1172 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1173 49c543a6 2022-03-31 naddy ret=$?
1174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1175 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1176 3d9a4ec4 2020-07-23 stsp return 1
1177 3d9a4ec4 2020-07-23 stsp fi
1178 3d9a4ec4 2020-07-23 stsp
1179 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
1180 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1181 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1182 49c543a6 2022-03-31 naddy ret=$?
1183 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1184 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1185 3d9a4ec4 2020-07-23 stsp return 1
1186 3d9a4ec4 2020-07-23 stsp fi
1187 7aadece8 2020-05-17 stsp
1188 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
1189 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1190 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1191 49c543a6 2022-03-31 naddy ret=$?
1192 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1193 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1194 3d9a4ec4 2020-07-23 stsp return 1
1195 e7303626 2020-05-14 stsp fi
1196 3d9a4ec4 2020-07-23 stsp
1197 bd6aa359 2020-07-23 stsp return 0
1198 bd6aa359 2020-07-23 stsp }
1199 3d9a4ec4 2020-07-23 stsp
1200 f6cae3ed 2020-09-13 naddy test_commit_symlink() {
1201 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
1202 3d9a4ec4 2020-07-23 stsp
1203 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1204 49c543a6 2022-03-31 naddy ret=$?
1205 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1206 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1207 3d9a4ec4 2020-07-23 stsp return 1
1208 3d9a4ec4 2020-07-23 stsp fi
1209 3d9a4ec4 2020-07-23 stsp
1210 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
1211 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
1212 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1213 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1214 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1215 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1216 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
1217 bd6aa359 2020-07-23 stsp
1218 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1219 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1220 49c543a6 2022-03-31 naddy ret=$?
1221 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1222 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1223 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1224 35213c7c 2020-07-23 stsp return 1
1225 35213c7c 2020-07-23 stsp fi
1226 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1227 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1228 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1229 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1230 49c543a6 2022-03-31 naddy ret=$?
1231 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1232 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1233 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1234 35213c7c 2020-07-23 stsp return 1
1235 35213c7c 2020-07-23 stsp fi
1236 bd6aa359 2020-07-23 stsp
1237 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1238 35213c7c 2020-07-23 stsp > $testroot/stdout)
1239 35213c7c 2020-07-23 stsp
1240 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1241 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1242 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1243 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1244 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1245 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1246 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1247 bd6aa359 2020-07-23 stsp
1248 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1249 49c543a6 2022-03-31 naddy ret=$?
1250 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1251 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1252 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1253 3d9a4ec4 2020-07-23 stsp return 1
1254 3d9a4ec4 2020-07-23 stsp fi
1255 3d9a4ec4 2020-07-23 stsp
1256 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1257 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1258 49c543a6 2022-03-31 naddy ret=$?
1259 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1260 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1261 bd6aa359 2020-07-23 stsp return 1
1262 3d9a4ec4 2020-07-23 stsp fi
1263 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1264 49c543a6 2022-03-31 naddy ret=$?
1265 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1266 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1267 bd6aa359 2020-07-23 stsp return 1
1268 bd6aa359 2020-07-23 stsp fi
1269 bd6aa359 2020-07-23 stsp
1270 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1271 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1272 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1273 75f0a0fb 2020-07-23 stsp return 1
1274 75f0a0fb 2020-07-23 stsp fi
1275 75f0a0fb 2020-07-23 stsp
1276 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1277 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1278 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1279 49c543a6 2022-03-31 naddy ret=$?
1280 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1281 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1282 5a1fbc73 2020-07-23 stsp return 1
1283 5a1fbc73 2020-07-23 stsp fi
1284 88fb31d4 2020-07-23 stsp
1285 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1286 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
1287 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1288 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1289 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1290 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1291 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1292 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1293 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1294 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1295 88fb31d4 2020-07-23 stsp
1296 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1297 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1298 49c543a6 2022-03-31 naddy ret=$?
1299 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1300 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1301 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1302 35213c7c 2020-07-23 stsp return 1
1303 35213c7c 2020-07-23 stsp fi
1304 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1305 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1306 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1307 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1308 49c543a6 2022-03-31 naddy ret=$?
1309 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1310 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1311 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1312 35213c7c 2020-07-23 stsp return 1
1313 35213c7c 2020-07-23 stsp fi
1314 88fb31d4 2020-07-23 stsp
1315 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1316 35213c7c 2020-07-23 stsp > $testroot/stdout)
1317 35213c7c 2020-07-23 stsp
1318 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1319 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1320 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1321 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1322 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1323 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1324 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1325 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1326 88fb31d4 2020-07-23 stsp
1327 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1328 49c543a6 2022-03-31 naddy ret=$?
1329 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1330 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1331 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1332 88fb31d4 2020-07-23 stsp return 1
1333 88fb31d4 2020-07-23 stsp fi
1334 88fb31d4 2020-07-23 stsp
1335 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1336 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1337 88fb31d4 2020-07-23 stsp alpha
1338 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1339 88fb31d4 2020-07-23 stsp beta
1340 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1341 88fb31d4 2020-07-23 stsp epsilon/
1342 88fb31d4 2020-07-23 stsp epsilon/beta.link
1343 88fb31d4 2020-07-23 stsp epsilon/zeta
1344 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1345 88fb31d4 2020-07-23 stsp gamma/
1346 88fb31d4 2020-07-23 stsp gamma/delta
1347 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1348 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1349 88fb31d4 2020-07-23 stsp EOF
1350 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1351 49c543a6 2022-03-31 naddy ret=$?
1352 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1353 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1354 88fb31d4 2020-07-23 stsp fi
1355 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1356 5a1fbc73 2020-07-23 stsp }
1357 5a1fbc73 2020-07-23 stsp
1358 f6cae3ed 2020-09-13 naddy test_commit_fix_bad_symlink() {
1359 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1360 5a1fbc73 2020-07-23 stsp
1361 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1362 49c543a6 2022-03-31 naddy ret=$?
1363 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1364 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1365 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1366 5a1fbc73 2020-07-23 stsp return 1
1367 5a1fbc73 2020-07-23 stsp fi
1368 5a1fbc73 2020-07-23 stsp
1369 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1370 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1371 5a1fbc73 2020-07-23 stsp
1372 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1373 35213c7c 2020-07-23 stsp > $testroot/stdout)
1374 5a1fbc73 2020-07-23 stsp
1375 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1376 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1377 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1378 75f0a0fb 2020-07-23 stsp return 1
1379 75f0a0fb 2020-07-23 stsp fi
1380 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1381 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1382 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1383 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1384 5a1fbc73 2020-07-23 stsp return 1
1385 5a1fbc73 2020-07-23 stsp fi
1386 5a1fbc73 2020-07-23 stsp
1387 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1388 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1389 49c543a6 2022-03-31 naddy ret=$?
1390 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1391 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1392 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1393 5a1fbc73 2020-07-23 stsp return 1
1394 5a1fbc73 2020-07-23 stsp fi
1395 5a1fbc73 2020-07-23 stsp
1396 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1397 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -sfh alpha passwd.link)
1398 5a1fbc73 2020-07-23 stsp
1399 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1400 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1401 5a1fbc73 2020-07-23 stsp
1402 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1403 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1404 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1405 5a1fbc73 2020-07-23 stsp
1406 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1407 49c543a6 2022-03-31 naddy ret=$?
1408 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1409 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1410 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1411 bd6aa359 2020-07-23 stsp return 1
1412 bd6aa359 2020-07-23 stsp fi
1413 5a1fbc73 2020-07-23 stsp
1414 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1415 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1416 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1417 5a1fbc73 2020-07-23 stsp return 1
1418 5a1fbc73 2020-07-23 stsp fi
1419 5a1fbc73 2020-07-23 stsp
1420 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1421 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1422 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1423 49c543a6 2022-03-31 naddy ret=$?
1424 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1425 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1426 5a1fbc73 2020-07-23 stsp return 1
1427 5a1fbc73 2020-07-23 stsp fi
1428 5a1fbc73 2020-07-23 stsp
1429 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1430 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1431 49c543a6 2022-03-31 naddy ret=$?
1432 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1433 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1434 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1435 5a1fbc73 2020-07-23 stsp return 1
1436 5a1fbc73 2020-07-23 stsp fi
1437 5a1fbc73 2020-07-23 stsp
1438 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1439 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1440 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1441 5a1fbc73 2020-07-23 stsp return 1
1442 5a1fbc73 2020-07-23 stsp fi
1443 5a1fbc73 2020-07-23 stsp
1444 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1445 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1446 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1447 49c543a6 2022-03-31 naddy ret=$?
1448 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1449 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1450 5a1fbc73 2020-07-23 stsp return 1
1451 5a1fbc73 2020-07-23 stsp fi
1452 5a1fbc73 2020-07-23 stsp
1453 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1454 1ebedb77 2019-10-19 stsp }
1455 28cf319f 2021-01-28 stsp
1456 28cf319f 2021-01-28 stsp test_commit_prepared_logmsg() {
1457 28cf319f 2021-01-28 stsp local testroot=`test_init commit_prepared_logmsg`
1458 28cf319f 2021-01-28 stsp
1459 28cf319f 2021-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1460 49c543a6 2022-03-31 naddy ret=$?
1461 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1462 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1463 28cf319f 2021-01-28 stsp return 1
1464 28cf319f 2021-01-28 stsp fi
1465 28cf319f 2021-01-28 stsp
1466 28cf319f 2021-01-28 stsp echo "modified alpha" > $testroot/wt/alpha
1467 28cf319f 2021-01-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
1468 28cf319f 2021-01-28 stsp echo "new file" > $testroot/wt/new
1469 28cf319f 2021-01-28 stsp (cd $testroot/wt && got add new >/dev/null)
1470 28cf319f 2021-01-28 stsp
1471 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg' > $testroot/logmsg
1472 28cf319f 2021-01-28 stsp
1473 28cf319f 2021-01-28 stsp cat > $testroot/editor.sh <<EOF
1474 28cf319f 2021-01-28 stsp #!/bin/sh
1475 28cf319f 2021-01-28 stsp sed -i 's/foo/bar/' "\$1"
1476 28cf319f 2021-01-28 stsp EOF
1477 28cf319f 2021-01-28 stsp chmod +x $testroot/editor.sh
1478 28cf319f 2021-01-28 stsp
1479 8e09a168 2021-06-17 tracey (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1480 28cf319f 2021-01-28 stsp got commit -F "$testroot/logmsg" > $testroot/stdout)
1481 1ebedb77 2019-10-19 stsp
1482 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1483 28cf319f 2021-01-28 stsp echo "A new" > $testroot/stdout.expected
1484 28cf319f 2021-01-28 stsp echo "M alpha" >> $testroot/stdout.expected
1485 28cf319f 2021-01-28 stsp echo "D beta" >> $testroot/stdout.expected
1486 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1487 28cf319f 2021-01-28 stsp
1488 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1489 49c543a6 2022-03-31 naddy ret=$?
1490 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1491 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1492 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1493 28cf319f 2021-01-28 stsp return 1
1494 28cf319f 2021-01-28 stsp fi
1495 28cf319f 2021-01-28 stsp
1496 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1497 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1498 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" > $testroot/stdout.expected
1499 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1500 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1501 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1502 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1503 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1504 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1505 28cf319f 2021-01-28 stsp
1506 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1507 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1508 49c543a6 2022-03-31 naddy ret=$?
1509 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1510 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1511 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1512 28cf319f 2021-01-28 stsp return 1
1513 28cf319f 2021-01-28 stsp fi
1514 28cf319f 2021-01-28 stsp
1515 28cf319f 2021-01-28 stsp echo "modified alpha again" > $testroot/wt/alpha
1516 28cf319f 2021-01-28 stsp
1517 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg non-interactive' \
1518 28cf319f 2021-01-28 stsp > $testroot/logmsg
1519 28cf319f 2021-01-28 stsp
1520 28cf319f 2021-01-28 stsp (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1521 28cf319f 2021-01-28 stsp > $testroot/stdout)
1522 28cf319f 2021-01-28 stsp
1523 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1524 28cf319f 2021-01-28 stsp echo "M alpha" > $testroot/stdout.expected
1525 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1526 28cf319f 2021-01-28 stsp
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 local author_time=`git_show_author_time $testroot/repo`
1536 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1537 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" \
1538 28cf319f 2021-01-28 stsp > $testroot/stdout.expected
1539 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1540 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1541 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1542 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1543 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg non-interactive" \
1544 28cf319f 2021-01-28 stsp >> $testroot/stdout.expected
1545 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1546 28cf319f 2021-01-28 stsp
1547 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1548 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1549 49c543a6 2022-03-31 naddy ret=$?
1550 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1551 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1552 28cf319f 2021-01-28 stsp fi
1553 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1554 28cf319f 2021-01-28 stsp }
1555 72840534 2022-01-19 stsp
1556 72840534 2022-01-19 stsp test_commit_large_file() {
1557 72840534 2022-01-19 stsp local testroot=`test_init commit_large_file`
1558 72840534 2022-01-19 stsp
1559 72840534 2022-01-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1560 49c543a6 2022-03-31 naddy ret=$?
1561 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1562 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1563 72840534 2022-01-19 stsp return 1
1564 72840534 2022-01-19 stsp fi
1565 72840534 2022-01-19 stsp
1566 230e1f1b 2022-07-05 stsp dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1567 72840534 2022-01-19 stsp (cd $testroot/wt && got add new >/dev/null)
1568 28cf319f 2021-01-28 stsp
1569 72840534 2022-01-19 stsp (cd $testroot/wt && got commit -m 'test commit_large_file' \
1570 72840534 2022-01-19 stsp > $testroot/stdout)
1571 72840534 2022-01-19 stsp
1572 72840534 2022-01-19 stsp local head_rev=`git_show_head $testroot/repo`
1573 72840534 2022-01-19 stsp echo "A new" > $testroot/stdout.expected
1574 72840534 2022-01-19 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1575 72840534 2022-01-19 stsp
1576 72840534 2022-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1577 49c543a6 2022-03-31 naddy ret=$?
1578 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1579 72840534 2022-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1580 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1581 72840534 2022-01-19 stsp return 1
1582 72840534 2022-01-19 stsp fi
1583 72840534 2022-01-19 stsp
1584 72840534 2022-01-19 stsp new_id=`get_blob_id $testroot/repo "" new`
1585 72840534 2022-01-19 stsp got cat -r $testroot/repo $new_id > $testroot/new
1586 49c543a6 2022-03-31 naddy ret=$?
1587 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1588 72840534 2022-01-19 stsp echo "commit failed unexpectedly" >&2
1589 72840534 2022-01-19 stsp test_done "$testroot" "1"
1590 72840534 2022-01-19 stsp return 1
1591 72840534 2022-01-19 stsp fi
1592 72840534 2022-01-19 stsp
1593 72840534 2022-01-19 stsp cmp -s $testroot/new $testroot/wt/new
1594 49c543a6 2022-03-31 naddy ret=$?
1595 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1596 72840534 2022-01-19 stsp diff -u $testroot/new $testroot/wt/new
1597 72840534 2022-01-19 stsp fi
1598 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1599 4ba2e955 2022-09-02 sh+got
1600 4ba2e955 2022-09-02 sh+got
1601 4ba2e955 2022-09-02 sh+got }
1602 4ba2e955 2022-09-02 sh+got
1603 4ba2e955 2022-09-02 sh+got test_commit_gitignore() {
1604 4ba2e955 2022-09-02 sh+got local testroot=`test_init commit_gitignores`
1605 4ba2e955 2022-09-02 sh+got
1606 4ba2e955 2022-09-02 sh+got got checkout $testroot/repo $testroot/wt > /dev/null
1607 4ba2e955 2022-09-02 sh+got ret=$?
1608 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1609 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1610 4ba2e955 2022-09-02 sh+got return 1
1611 4ba2e955 2022-09-02 sh+got fi
1612 4ba2e955 2022-09-02 sh+got
1613 4ba2e955 2022-09-02 sh+got mkdir -p $testroot/wt/tree1/foo
1614 4ba2e955 2022-09-02 sh+got mkdir -p $testroot/wt/tree2/foo
1615 4ba2e955 2022-09-02 sh+got echo "tree1/**" > $testroot/wt/.gitignore
1616 4ba2e955 2022-09-02 sh+got echo "tree2/**" >> $testroot/wt/.gitignore
1617 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree1/bar
1618 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree1/foo/baz
1619 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree2/bar
1620 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree2/foo/baz
1621 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/epsilon/zeta1
1622 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/epsilon/zeta2
1623 4ba2e955 2022-09-02 sh+got
1624 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got add -I -R tree1 > /dev/null)
1625 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got add -I tree2/foo/baz > /dev/null)
1626 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got commit -m "gitignore add" > /dev/null)
1627 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1628 4ba2e955 2022-09-02 sh+got
1629 4ba2e955 2022-09-02 sh+got echo ' gitignore add' > $testroot/stdout.expected
1630 4ba2e955 2022-09-02 sh+got echo ' A tree1/bar' >> $testroot/stdout.expected
1631 4ba2e955 2022-09-02 sh+got echo ' A tree1/foo/baz' >> $testroot/stdout.expected
1632 4ba2e955 2022-09-02 sh+got echo ' A tree2/foo/baz' >> $testroot/stdout.expected
1633 72840534 2022-01-19 stsp
1634 4ba2e955 2022-09-02 sh+got cmp -s $testroot/stdout.expected $testroot/stdout
1635 4ba2e955 2022-09-02 sh+got ret=$?
1636 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1637 4ba2e955 2022-09-02 sh+got diff -u $testroot/stdout.expected $testroot/stdout
1638 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1639 4ba2e955 2022-09-02 sh+got return 1
1640 4ba2e955 2022-09-02 sh+got fi
1641 72840534 2022-01-19 stsp
1642 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/tree1/bar
1643 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/tree1/foo/baz
1644 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/epsilon/zeta1
1645 4ba2e955 2022-09-02 sh+got
1646 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got commit -m "gitignore change" > /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 change' > $testroot/stdout.expected
1650 4ba2e955 2022-09-02 sh+got echo ' M tree1/bar' >> $testroot/stdout.expected
1651 4ba2e955 2022-09-02 sh+got echo ' M tree1/foo/baz' >> $testroot/stdout.expected
1652 4ba2e955 2022-09-02 sh+got
1653 4ba2e955 2022-09-02 sh+got cmp -s $testroot/stdout.expected $testroot/stdout
1654 4ba2e955 2022-09-02 sh+got ret=$?
1655 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1656 4ba2e955 2022-09-02 sh+got diff -u $testroot/stdout.expected $testroot/stdout
1657 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1658 4ba2e955 2022-09-02 sh+got return 1
1659 4ba2e955 2022-09-02 sh+got fi
1660 4ba2e955 2022-09-02 sh+got
1661 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1662 72840534 2022-01-19 stsp }
1663 21f07726 2022-10-31 stsp
1664 21f07726 2022-10-31 stsp test_commit_bad_author() {
1665 21f07726 2022-10-31 stsp local testroot=`test_init commit_bad_author`
1666 21f07726 2022-10-31 stsp
1667 21f07726 2022-10-31 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1668 21f07726 2022-10-31 stsp ret=$?
1669 21f07726 2022-10-31 stsp if [ $ret -ne 0 ]; then
1670 21f07726 2022-10-31 stsp test_done "$testroot" $ret
1671 21f07726 2022-10-31 stsp return 1
1672 21f07726 2022-10-31 stsp fi
1673 21f07726 2022-10-31 stsp
1674 21f07726 2022-10-31 stsp echo "modified alpha" > $testroot/wt/alpha
1675 21f07726 2022-10-31 stsp
1676 21f07726 2022-10-31 stsp (cd $testroot/wt && got commit \
1677 21f07726 2022-10-31 stsp -A "${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>" -m 'edit alpha') \
1678 21f07726 2022-10-31 stsp > /dev/null 2> $testroot/stderr
1679 21f07726 2022-10-31 stsp ret=$?
1680 21f07726 2022-10-31 stsp if [ $ret -eq 0 ]; then
1681 21f07726 2022-10-31 stsp test_done "$testroot" 1
1682 21f07726 2022-10-31 stsp return 1
1683 21f07726 2022-10-31 stsp fi
1684 72840534 2022-01-19 stsp
1685 21f07726 2022-10-31 stsp echo -n "got: ${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>: " \
1686 21f07726 2022-10-31 stsp > $testroot/stderr.expected
1687 21f07726 2022-10-31 stsp echo -n 'space between author name and email required: ' \
1688 21f07726 2022-10-31 stsp >> $testroot/stderr.expected
1689 21f07726 2022-10-31 stsp echo 'commit author formatting would make Git unhappy' \
1690 21f07726 2022-10-31 stsp >> $testroot/stderr.expected
1691 21f07726 2022-10-31 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1692 21f07726 2022-10-31 stsp ret=$?
1693 21f07726 2022-10-31 stsp if [ $ret -ne 0 ]; then
1694 21f07726 2022-10-31 stsp diff -u $testroot/stderr.expected $testroot/stderr
1695 21f07726 2022-10-31 stsp test_done "$testroot" $ret
1696 21f07726 2022-10-31 stsp return 1
1697 21f07726 2022-10-31 stsp fi
1698 72840534 2022-01-19 stsp
1699 21f07726 2022-10-31 stsp test_done "$testroot" 0
1700 21f07726 2022-10-31 stsp }
1701 def2bea2 2023-01-30 mark
1702 def2bea2 2023-01-30 mark test_commit_logmsg_ref() {
1703 def2bea2 2023-01-30 mark local testroot=`test_init commit_logmsg_ref`
1704 def2bea2 2023-01-30 mark
1705 def2bea2 2023-01-30 mark got checkout $testroot/repo $testroot/wt > /dev/null
1706 def2bea2 2023-01-30 mark ret=$?
1707 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1708 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1709 def2bea2 2023-01-30 mark return 1
1710 def2bea2 2023-01-30 mark fi
1711 def2bea2 2023-01-30 mark
1712 def2bea2 2023-01-30 mark (cd $testroot/repo && git checkout -q -b newbranch)
1713 def2bea2 2023-01-30 mark
1714 def2bea2 2023-01-30 mark local bo_logmsg_prefix="log message of backed-out commit"
1715 def2bea2 2023-01-30 mark local cy_logmsg_prefix="log message of cherrypicked commit"
1716 def2bea2 2023-01-30 mark local branch_rev_logmsg="changes on newbranch to cherrypick"
1717 def2bea2 2023-01-30 mark local branch_rev2_logmsg="modified zeta on newbranch to cherrypick"
1718 def2bea2 2023-01-30 mark
1719 def2bea2 2023-01-30 mark echo "modified delta on branch" > $testroot/repo/gamma/delta
1720 def2bea2 2023-01-30 mark echo "modified alpha on branch" > $testroot/repo/alpha
1721 def2bea2 2023-01-30 mark (cd $testroot/repo && git rm -q beta)
1722 def2bea2 2023-01-30 mark echo "new file on branch" > $testroot/repo/epsilon/new
1723 def2bea2 2023-01-30 mark (cd $testroot/repo && git add epsilon/new)
1724 def2bea2 2023-01-30 mark
1725 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev_logmsg"
1726 def2bea2 2023-01-30 mark local branch_rev=`git_show_head $testroot/repo`
1727 def2bea2 2023-01-30 mark
1728 def2bea2 2023-01-30 mark echo "modified zeta on branch" > $testroot/repo/epsilon/zeta
1729 def2bea2 2023-01-30 mark
1730 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev2_logmsg"
1731 def2bea2 2023-01-30 mark local branch_rev2=`git_show_head $testroot/repo`
1732 def2bea2 2023-01-30 mark
1733 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1734 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev2 > /dev/null)
1735 21f07726 2022-10-31 stsp
1736 def2bea2 2023-01-30 mark cat > $testroot/editor.sh <<EOF
1737 def2bea2 2023-01-30 mark #!/bin/sh
1738 def2bea2 2023-01-30 mark sed -i 's/# l/l/' "\$1"
1739 def2bea2 2023-01-30 mark EOF
1740 def2bea2 2023-01-30 mark chmod +x $testroot/editor.sh
1741 def2bea2 2023-01-30 mark
1742 def2bea2 2023-01-30 mark (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1743 def2bea2 2023-01-30 mark got commit > /dev/null)
1744 def2bea2 2023-01-30 mark ret=$?
1745 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1746 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1747 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1748 def2bea2 2023-01-30 mark return 1
1749 def2bea2 2023-01-30 mark fi
1750 def2bea2 2023-01-30 mark
1751 def2bea2 2023-01-30 mark # check that multiple cherrypicked log messages populate the editor
1752 def2bea2 2023-01-30 mark local first=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | head -1`
1753 def2bea2 2023-01-30 mark local second=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | tail -1`
1754 def2bea2 2023-01-30 mark
1755 def2bea2 2023-01-30 mark if [ $branch_rev == $first ]; then
1756 def2bea2 2023-01-30 mark local first_msg=$branch_rev_logmsg
1757 def2bea2 2023-01-30 mark local second_msg=$branch_rev2_logmsg
1758 def2bea2 2023-01-30 mark else
1759 def2bea2 2023-01-30 mark local first_msg=$branch_rev2_logmsg
1760 def2bea2 2023-01-30 mark local second_msg=$branch_rev_logmsg
1761 def2bea2 2023-01-30 mark fi
1762 def2bea2 2023-01-30 mark
1763 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $first:" > $testroot/stdout.expected
1764 def2bea2 2023-01-30 mark echo " $first_msg" >> $testroot/stdout.expected
1765 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1766 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $second:" >> $testroot/stdout.expected
1767 def2bea2 2023-01-30 mark echo " $second_msg" >> $testroot/stdout.expected
1768 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1769 def2bea2 2023-01-30 mark
1770 def2bea2 2023-01-30 mark (cd $testroot/wt && got log -l2 | \
1771 def2bea2 2023-01-30 mark grep -A2 'log message' | sed '/^--/d' > $testroot/stdout)
1772 def2bea2 2023-01-30 mark
1773 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1774 def2bea2 2023-01-30 mark ret=$?
1775 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1776 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1777 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1778 def2bea2 2023-01-30 mark return 1
1779 def2bea2 2023-01-30 mark fi
1780 def2bea2 2023-01-30 mark
1781 def2bea2 2023-01-30 mark # check that only the relevant log message populates the editor
1782 def2bea2 2023-01-30 mark # when the changes from one of two backout commits are reverted
1783 def2bea2 2023-01-30 mark got checkout $testroot/repo $testroot/wt2 > /dev/null
1784 def2bea2 2023-01-30 mark ret=$?
1785 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1786 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1787 def2bea2 2023-01-30 mark return 1
1788 def2bea2 2023-01-30 mark fi
1789 def2bea2 2023-01-30 mark
1790 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got backout $branch_rev > /dev/null)
1791 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got backout $branch_rev2 > /dev/null)
1792 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got revert epsilon/zeta > /dev/null)
1793 def2bea2 2023-01-30 mark
1794 def2bea2 2023-01-30 mark (cd $testroot/wt2 && env VISUAL="$testroot/editor.sh" \
1795 def2bea2 2023-01-30 mark got commit > /dev/null)
1796 def2bea2 2023-01-30 mark ret=$?
1797 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1798 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1799 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1800 def2bea2 2023-01-30 mark return 1
1801 def2bea2 2023-01-30 mark fi
1802 def2bea2 2023-01-30 mark
1803 def2bea2 2023-01-30 mark echo " $bo_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1804 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1805 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1806 def2bea2 2023-01-30 mark
1807 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got log -l1 | \
1808 def2bea2 2023-01-30 mark grep -A2 'log message' > $testroot/stdout)
1809 def2bea2 2023-01-30 mark
1810 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1811 def2bea2 2023-01-30 mark ret=$?
1812 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1813 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1814 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1815 def2bea2 2023-01-30 mark return 1
1816 def2bea2 2023-01-30 mark fi
1817 def2bea2 2023-01-30 mark
1818 def2bea2 2023-01-30 mark # check that a cherrypicked log message is still
1819 def2bea2 2023-01-30 mark # used when its changes are only partially reverted
1820 def2bea2 2023-01-30 mark branch_rev_logmsg="changes to cherrypick and partially revert"
1821 def2bea2 2023-01-30 mark
1822 def2bea2 2023-01-30 mark echo "newline in alpha" >> $testroot/repo/alpha
1823 def2bea2 2023-01-30 mark echo "modified epsilon/zeta on branch" > $testroot/repo/epsilon/zeta
1824 def2bea2 2023-01-30 mark
1825 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev_logmsg"
1826 def2bea2 2023-01-30 mark branch_rev=`git_show_head $testroot/repo`
1827 def2bea2 2023-01-30 mark
1828 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1829 def2bea2 2023-01-30 mark (cd $testroot/wt && got revert alpha > /dev/null)
1830 def2bea2 2023-01-30 mark
1831 def2bea2 2023-01-30 mark (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1832 def2bea2 2023-01-30 mark got commit > /dev/null)
1833 def2bea2 2023-01-30 mark ret=$?
1834 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1835 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1836 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1837 def2bea2 2023-01-30 mark return 1
1838 def2bea2 2023-01-30 mark fi
1839 def2bea2 2023-01-30 mark
1840 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1841 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1842 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1843 def2bea2 2023-01-30 mark
1844 def2bea2 2023-01-30 mark (cd $testroot/wt && got log -l1 | \
1845 def2bea2 2023-01-30 mark grep -A2 'log message' > $testroot/stdout)
1846 def2bea2 2023-01-30 mark
1847 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1848 def2bea2 2023-01-30 mark ret=$?
1849 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1850 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1851 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1852 def2bea2 2023-01-30 mark return 1
1853 def2bea2 2023-01-30 mark fi
1854 def2bea2 2023-01-30 mark
1855 def2bea2 2023-01-30 mark # check we don't use and consequently delete the logmsg ref of a
1856 def2bea2 2023-01-30 mark # cherrypicked commit when omitting its changed path from the commit
1857 def2bea2 2023-01-30 mark branch_rev_logmsg="changes to cherrypick but omit from the commit"
1858 def2bea2 2023-01-30 mark
1859 def2bea2 2023-01-30 mark echo "changed delta" >> $testroot/repo/gamma/delta
1860 def2bea2 2023-01-30 mark
1861 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev_logmsg"
1862 def2bea2 2023-01-30 mark local author_time=`git_show_author_time $testroot/repo`
1863 def2bea2 2023-01-30 mark local d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1864 def2bea2 2023-01-30 mark branch_rev=`git_show_head $testroot/repo`
1865 def2bea2 2023-01-30 mark
1866 def2bea2 2023-01-30 mark (cd $testroot/wt && got update > /dev/null)
1867 def2bea2 2023-01-30 mark ret=$?
1868 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1869 def2bea2 2023-01-30 mark echo "got update failed unexpectedly" >&2
1870 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1871 def2bea2 2023-01-30 mark return 1
1872 def2bea2 2023-01-30 mark fi
1873 def2bea2 2023-01-30 mark
1874 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1875 def2bea2 2023-01-30 mark
1876 def2bea2 2023-01-30 mark echo "changed alpha" >> $testroot/wt/alpha
1877 def2bea2 2023-01-30 mark
1878 def2bea2 2023-01-30 mark (cd $testroot/wt && got commit -m \
1879 def2bea2 2023-01-30 mark "don't commit cy change to gamma/delta" alpha > /dev/null)
1880 def2bea2 2023-01-30 mark ret=$?
1881 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1882 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1883 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1884 def2bea2 2023-01-30 mark return 1
1885 def2bea2 2023-01-30 mark fi
1886 def2bea2 2023-01-30 mark
1887 def2bea2 2023-01-30 mark # confirm logmsg ref was not deleted with got cherrypick -l
1888 def2bea2 2023-01-30 mark echo "-----------------------------------------------" \
1889 def2bea2 2023-01-30 mark > $testroot/stdout.expected
1890 b584caa3 2023-01-30 mark echo "cherrypick $branch_rev (newbranch)" >> $testroot/stdout.expected
1891 def2bea2 2023-01-30 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1892 def2bea2 2023-01-30 mark echo "date: $d" >> $testroot/stdout.expected
1893 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1894 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1895 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1896 def2bea2 2023-01-30 mark echo " M gamma/delta" >> $testroot/stdout.expected
1897 def2bea2 2023-01-30 mark echo >> $testroot/stdout.expected
1898 def2bea2 2023-01-30 mark
1899 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick -l > $testroot/stdout)
1900 def2bea2 2023-01-30 mark
1901 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1902 def2bea2 2023-01-30 mark ret=$?
1903 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1904 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1905 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1906 def2bea2 2023-01-30 mark return 1
1907 def2bea2 2023-01-30 mark fi
1908 def2bea2 2023-01-30 mark
1909 def2bea2 2023-01-30 mark # confirm a previously unused logmsg ref is picked up
1910 def2bea2 2023-01-30 mark # when an affected path is actually committed
1911 def2bea2 2023-01-30 mark (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1912 def2bea2 2023-01-30 mark got commit > /dev/null)
1913 def2bea2 2023-01-30 mark ret=$?
1914 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1915 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1916 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1917 def2bea2 2023-01-30 mark return 1
1918 def2bea2 2023-01-30 mark fi
1919 def2bea2 2023-01-30 mark
1920 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1921 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1922 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1923 def2bea2 2023-01-30 mark
1924 def2bea2 2023-01-30 mark (cd $testroot/wt && got log -l1 | \
1925 def2bea2 2023-01-30 mark grep -A2 'log message' > $testroot/stdout)
1926 def2bea2 2023-01-30 mark
1927 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1928 def2bea2 2023-01-30 mark ret=$?
1929 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1930 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1931 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1932 def2bea2 2023-01-30 mark return 1
1933 def2bea2 2023-01-30 mark fi
1934 def2bea2 2023-01-30 mark
1935 def2bea2 2023-01-30 mark # make sure we are not littering work trees
1936 def2bea2 2023-01-30 mark # by leaving temp got-logmsg-* files behind
1937 def2bea2 2023-01-30 mark echo -n > $testroot/stdout.expected
1938 def2bea2 2023-01-30 mark (cd $testroot/wt && got status > $testroot/stdout)
1939 def2bea2 2023-01-30 mark
1940 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1941 def2bea2 2023-01-30 mark ret=$?
1942 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1943 def2bea2 2023-01-30 mark echo "$testroot/wt is not clean"
1944 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1945 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1946 def2bea2 2023-01-30 mark return 1
1947 def2bea2 2023-01-30 mark fi
1948 def2bea2 2023-01-30 mark
1949 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got status > $testroot/stdout)
1950 def2bea2 2023-01-30 mark
1951 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1952 def2bea2 2023-01-30 mark ret=$?
1953 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1954 def2bea2 2023-01-30 mark echo "$testroot/repo is not clean"
1955 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1956 def2bea2 2023-01-30 mark fi
1957 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1958 def2bea2 2023-01-30 mark }
1959 def2bea2 2023-01-30 mark
1960 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1961 c4296144 2019-05-09 stsp run_test test_commit_basic
1962 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
1963 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
1964 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
1965 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
1966 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
1967 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
1968 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
1969 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
1970 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
1971 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
1972 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
1973 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
1974 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
1975 84792843 2019-08-09 stsp run_test test_commit_no_email
1976 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
1977 62b21d33 2022-07-19 op run_test test_commit_cmdline_author
1978 257add31 2020-09-09 stsp run_test test_commit_gotconfig_author
1979 50b0790e 2020-09-11 stsp run_test test_commit_gotconfig_worktree_author
1980 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
1981 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
1982 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
1983 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
1984 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
1985 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink
1986 28cf319f 2021-01-28 stsp run_test test_commit_prepared_logmsg
1987 72840534 2022-01-19 stsp run_test test_commit_large_file
1988 4ba2e955 2022-09-02 sh+got run_test test_commit_gitignore
1989 21f07726 2022-10-31 stsp run_test test_commit_bad_author
1990 def2bea2 2023-01-30 mark run_test test_commit_logmsg_ref