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 12383673 2023-02-18 mark local commit_id1=`git_show_head $testroot/repo`
298 f363d663 2019-05-23 stsp
299 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
300 f363d663 2019-05-23 stsp
301 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
302 f363d663 2019-05-23 stsp
303 f363d663 2019-05-23 stsp echo "C alpha" > $testroot/stdout.expected
304 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
305 f363d663 2019-05-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
306 f363d663 2019-05-23 stsp echo >> $testroot/stdout.expected
307 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
308 f363d663 2019-05-23 stsp
309 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
310 f363d663 2019-05-23 stsp
311 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
312 49c543a6 2022-03-31 naddy ret=$?
313 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
314 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
315 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
316 f363d663 2019-05-23 stsp return 1
317 f363d663 2019-05-23 stsp fi
318 f363d663 2019-05-23 stsp
319 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
320 f363d663 2019-05-23 stsp 2> $testroot/stderr)
321 12383673 2023-02-18 mark ret=$?
322 12383673 2023-02-18 mark if [ $ret -eq 0 ]; then
323 12383673 2023-02-18 mark echo "got commit succeeded unexpectedly"
324 12383673 2023-02-18 mark test_done "$testroot" "$ret"
325 12383673 2023-02-18 mark return 1
326 12383673 2023-02-18 mark fi
327 f363d663 2019-05-23 stsp
328 12383673 2023-02-18 mark echo "C alpha" > $testroot/stdout.expected
329 f363d663 2019-05-23 stsp echo "got: cannot commit file in conflicted status" \
330 f363d663 2019-05-23 stsp > $testroot/stderr.expected
331 f363d663 2019-05-23 stsp
332 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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/stdout.expected $testroot/stdout
336 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
337 f363d663 2019-05-23 stsp return 1
338 f363d663 2019-05-23 stsp fi
339 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
340 49c543a6 2022-03-31 naddy ret=$?
341 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
342 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
343 12383673 2023-02-18 mark test_done "$testroot" "$ret"
344 12383673 2023-02-18 mark return 1
345 12383673 2023-02-18 mark fi
346 12383673 2023-02-18 mark
347 12383673 2023-02-18 mark (cd $testroot/wt && got commit -C -m 'commit it' > $testroot/stdout \
348 12383673 2023-02-18 mark 2> $testroot/stderr)
349 12383673 2023-02-18 mark ret=$?
350 12383673 2023-02-18 mark if [ $ret -ne 0 ]; then
351 12383673 2023-02-18 mark echo "got commit failed unexpectedly"
352 12383673 2023-02-18 mark test_done "$testroot" "$ret"
353 12383673 2023-02-18 mark return 1
354 12383673 2023-02-18 mark fi
355 12383673 2023-02-18 mark
356 12383673 2023-02-18 mark # make sure the conflicted commit produces a diff
357 12383673 2023-02-18 mark local conflict_commit=`git_show_head $testroot/repo`
358 12383673 2023-02-18 mark local blob_minus=`got tree -r $testroot/repo -c $commit_id1 -i | \
359 12383673 2023-02-18 mark grep 'alpha$' | cut -d' ' -f1`
360 12383673 2023-02-18 mark local blob_plus=`got tree -r $testroot/repo -c $conflict_commit -i | \
361 12383673 2023-02-18 mark grep 'alpha$' | cut -d' ' -f1`
362 12383673 2023-02-18 mark
363 12383673 2023-02-18 mark echo -n > $testroot/stderr.expected
364 12383673 2023-02-18 mark cmp -s $testroot/stderr.expected $testroot/stderr
365 12383673 2023-02-18 mark ret=$?
366 12383673 2023-02-18 mark if [ $ret -ne 0 ]; then
367 12383673 2023-02-18 mark diff -u $testroot/stderr.expected $testroot/stderr
368 12383673 2023-02-18 mark test_done "$testroot" "$ret"
369 12383673 2023-02-18 mark return 1
370 12383673 2023-02-18 mark fi
371 12383673 2023-02-18 mark
372 12383673 2023-02-18 mark (cd $testroot/wt && got diff -c master > $testroot/stdout)
373 12383673 2023-02-18 mark
374 12383673 2023-02-18 mark echo -n > $testroot/stdout.expected
375 12383673 2023-02-18 mark cat > $testroot/stdout.expected <<EOF
376 12383673 2023-02-18 mark diff $commit_id1 refs/heads/master
377 12383673 2023-02-18 mark commit - $commit_id1
378 12383673 2023-02-18 mark commit + $conflict_commit
379 12383673 2023-02-18 mark blob - $blob_minus
380 12383673 2023-02-18 mark blob + $blob_plus
381 12383673 2023-02-18 mark --- alpha
382 12383673 2023-02-18 mark +++ alpha
383 12383673 2023-02-18 mark @@ -1 +1,7 @@
384 12383673 2023-02-18 mark +<<<<<<< merged change: commit $commit_id1
385 12383673 2023-02-18 mark modified alpha
386 12383673 2023-02-18 mark +||||||| 3-way merge base: commit $initial_rev
387 12383673 2023-02-18 mark +alpha
388 12383673 2023-02-18 mark +=======
389 12383673 2023-02-18 mark +modified alpha, too
390 12383673 2023-02-18 mark +>>>>>>>
391 12383673 2023-02-18 mark EOF
392 12383673 2023-02-18 mark
393 12383673 2023-02-18 mark cmp -s $testroot/stdout.expected $testroot/stdout
394 12383673 2023-02-18 mark ret=$?
395 12383673 2023-02-18 mark if [ $ret -ne 0 ]; then
396 12383673 2023-02-18 mark diff -u $testroot/stdout.expected $testroot/stdout
397 12383673 2023-02-18 mark test_done "$testroot" "$ret"
398 12383673 2023-02-18 mark return 1
399 f363d663 2019-05-23 stsp fi
400 12383673 2023-02-18 mark
401 12383673 2023-02-18 mark (cd $testroot/wt && got status > $testroot/stdout)
402 12383673 2023-02-18 mark
403 12383673 2023-02-18 mark echo -n > $testroot/stdout.expected
404 12383673 2023-02-18 mark cmp -s $testroot/stdout.expected $testroot/stdout
405 12383673 2023-02-18 mark ret=$?
406 12383673 2023-02-18 mark if [ $ret -ne 0 ]; then
407 12383673 2023-02-18 mark diff -u $testroot/stdout.expected $testroot/stdout
408 12383673 2023-02-18 mark fi
409 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
410 f363d663 2019-05-23 stsp }
411 1a36436d 2019-06-10 stsp
412 f6cae3ed 2020-09-13 naddy test_commit_single_file_multiple() {
413 1a36436d 2019-06-10 stsp local testroot=`test_init commit_single_file_multiple`
414 f363d663 2019-05-23 stsp
415 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
416 49c543a6 2022-03-31 naddy ret=$?
417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
418 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
419 1a36436d 2019-06-10 stsp return 1
420 1a36436d 2019-06-10 stsp fi
421 1a36436d 2019-06-10 stsp
422 1a36436d 2019-06-10 stsp for i in 1 2 3 4; do
423 1a36436d 2019-06-10 stsp echo "modified alpha" >> $testroot/wt/alpha
424 1a36436d 2019-06-10 stsp
425 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
426 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
427 1a36436d 2019-06-10 stsp
428 1a36436d 2019-06-10 stsp local head_rev=`git_show_head $testroot/repo`
429 1a36436d 2019-06-10 stsp echo "M alpha" > $testroot/stdout.expected
430 1a36436d 2019-06-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
431 1a36436d 2019-06-10 stsp
432 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
433 49c543a6 2022-03-31 naddy ret=$?
434 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
435 1a36436d 2019-06-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
436 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
437 1a36436d 2019-06-10 stsp return 1
438 1a36436d 2019-06-10 stsp fi
439 1a36436d 2019-06-10 stsp done
440 1a36436d 2019-06-10 stsp
441 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
442 1a36436d 2019-06-10 stsp }
443 4866d084 2019-07-10 stsp
444 f6cae3ed 2020-09-13 naddy test_commit_added_and_modified_in_same_dir() {
445 4866d084 2019-07-10 stsp local testroot=`test_init commit_added_and_modified_in_same_dir`
446 1a36436d 2019-06-10 stsp
447 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
448 49c543a6 2022-03-31 naddy ret=$?
449 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
450 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
451 4866d084 2019-07-10 stsp return 1
452 4866d084 2019-07-10 stsp fi
453 4866d084 2019-07-10 stsp
454 4866d084 2019-07-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
455 4866d084 2019-07-10 stsp echo "new file" > $testroot/wt/epsilon/new
456 4866d084 2019-07-10 stsp (cd $testroot/wt && got add epsilon/new >/dev/null)
457 4866d084 2019-07-10 stsp
458 4866d084 2019-07-10 stsp (cd $testroot/wt && got commit \
459 4866d084 2019-07-10 stsp -m 'added and modified in same dir' > $testroot/stdout \
460 4866d084 2019-07-10 stsp 2> $testroot/stderr)
461 4866d084 2019-07-10 stsp
462 4866d084 2019-07-10 stsp local head_rev=`git_show_head $testroot/repo`
463 4866d084 2019-07-10 stsp echo "A epsilon/new" > $testroot/stdout.expected
464 4866d084 2019-07-10 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
465 4866d084 2019-07-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
466 e0233cea 2019-07-25 stsp
467 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
468 49c543a6 2022-03-31 naddy ret=$?
469 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
470 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
471 e0233cea 2019-07-25 stsp fi
472 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
473 e0233cea 2019-07-25 stsp }
474 e0233cea 2019-07-25 stsp
475 f6cae3ed 2020-09-13 naddy test_commit_path_prefix() {
476 e0233cea 2019-07-25 stsp local testroot=`test_init commit_path_prefix`
477 e0233cea 2019-07-25 stsp local commit1=`git_show_head $testroot/repo`
478 e0233cea 2019-07-25 stsp
479 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
480 49c543a6 2022-03-31 naddy ret=$?
481 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
482 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
483 e0233cea 2019-07-25 stsp return 1
484 e0233cea 2019-07-25 stsp fi
485 e0233cea 2019-07-25 stsp
486 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
487 e0233cea 2019-07-25 stsp
488 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
489 e0233cea 2019-07-25 stsp
490 e0233cea 2019-07-25 stsp local commit2=`git_show_head $testroot/repo`
491 e0233cea 2019-07-25 stsp echo "M delta" > $testroot/stdout.expected
492 e0233cea 2019-07-25 stsp echo "Created commit $commit2" >> $testroot/stdout.expected
493 4866d084 2019-07-10 stsp
494 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
495 49c543a6 2022-03-31 naddy ret=$?
496 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
497 2b496619 2019-07-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
498 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
499 e0233cea 2019-07-25 stsp return 1
500 4866d084 2019-07-10 stsp fi
501 e0233cea 2019-07-25 stsp
502 e0233cea 2019-07-25 stsp echo "diff $commit1 $commit2" > $testroot/stdout.expected
503 8469d821 2022-06-25 stsp echo "commit - $commit1" >> $testroot/stdout.expected
504 8469d821 2022-06-25 stsp echo "commit + $commit2" >> $testroot/stdout.expected
505 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
506 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
507 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $testroot/stdout.expected
508 e0233cea 2019-07-25 stsp echo -n 'blob + ' >> $testroot/stdout.expected
509 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
510 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
511 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
512 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
513 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
514 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
515 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
516 e0233cea 2019-07-25 stsp
517 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
518 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
519 49c543a6 2022-03-31 naddy ret=$?
520 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
521 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
522 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
523 f2b0a8b0 2020-07-31 stsp return 1
524 f2b0a8b0 2020-07-31 stsp fi
525 f2b0a8b0 2020-07-31 stsp
526 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got rm delta > /dev/null)
527 f2b0a8b0 2020-07-31 stsp echo new > $testroot/wt/new
528 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got add new > /dev/null)
529 f2b0a8b0 2020-07-31 stsp
530 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
531 f2b0a8b0 2020-07-31 stsp > $testroot/stdout)
532 f2b0a8b0 2020-07-31 stsp
533 f2b0a8b0 2020-07-31 stsp local commit3=`git_show_head $testroot/repo`
534 f2b0a8b0 2020-07-31 stsp echo "A new" > $testroot/stdout.expected
535 f2b0a8b0 2020-07-31 stsp echo "D delta" >> $testroot/stdout.expected
536 f2b0a8b0 2020-07-31 stsp echo "Created commit $commit3" >> $testroot/stdout.expected
537 f2b0a8b0 2020-07-31 stsp
538 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
539 49c543a6 2022-03-31 naddy ret=$?
540 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
541 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
542 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
543 f2b0a8b0 2020-07-31 stsp return 1
544 f2b0a8b0 2020-07-31 stsp fi
545 f2b0a8b0 2020-07-31 stsp
546 f2b0a8b0 2020-07-31 stsp echo "diff $commit2 $commit3" > $testroot/stdout.expected
547 8469d821 2022-06-25 stsp echo "commit - $commit2" >> $testroot/stdout.expected
548 8469d821 2022-06-25 stsp echo "commit + $commit3" >> $testroot/stdout.expected
549 f2b0a8b0 2020-07-31 stsp echo -n 'blob - ' >> $testroot/stdout.expected
550 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
551 f2b0a8b0 2020-07-31 stsp | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
552 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
553 f2b0a8b0 2020-07-31 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
554 f2b0a8b0 2020-07-31 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
555 f2b0a8b0 2020-07-31 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
556 f2b0a8b0 2020-07-31 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
557 f2b0a8b0 2020-07-31 stsp echo '-modified delta' >> $testroot/stdout.expected
558 f2b0a8b0 2020-07-31 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
559 f2b0a8b0 2020-07-31 stsp echo -n 'blob + ' >> $testroot/stdout.expected
560 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
561 f2b0a8b0 2020-07-31 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
562 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
563 f2b0a8b0 2020-07-31 stsp echo '--- /dev/null' >> $testroot/stdout.expected
564 f2b0a8b0 2020-07-31 stsp echo '+++ gamma/new' >> $testroot/stdout.expected
565 f2b0a8b0 2020-07-31 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
566 f2b0a8b0 2020-07-31 stsp echo '+new' >> $testroot/stdout.expected
567 f2b0a8b0 2020-07-31 stsp
568 f2b0a8b0 2020-07-31 stsp got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
569 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
570 49c543a6 2022-03-31 naddy ret=$?
571 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
572 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
573 e0233cea 2019-07-25 stsp fi
574 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
575 f2b0a8b0 2020-07-31 stsp return "$ret"
576 4866d084 2019-07-10 stsp }
577 90e8619e 2019-07-25 stsp
578 f6cae3ed 2020-09-13 naddy test_commit_dir_path() {
579 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
580 4866d084 2019-07-10 stsp
581 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
582 49c543a6 2022-03-31 naddy ret=$?
583 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
584 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
585 90e8619e 2019-07-25 stsp return 1
586 90e8619e 2019-07-25 stsp fi
587 90e8619e 2019-07-25 stsp
588 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
589 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
590 90e8619e 2019-07-25 stsp
591 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
592 90e8619e 2019-07-25 stsp > $testroot/stdout)
593 90e8619e 2019-07-25 stsp
594 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
595 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
596 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
597 90e8619e 2019-07-25 stsp
598 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
599 49c543a6 2022-03-31 naddy ret=$?
600 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
601 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
602 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
603 90e8619e 2019-07-25 stsp return 1
604 90e8619e 2019-07-25 stsp fi
605 90e8619e 2019-07-25 stsp
606 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
607 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
608 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
609 49c543a6 2022-03-31 naddy ret=$?
610 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
611 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
612 90e8619e 2019-07-25 stsp fi
613 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
614 90e8619e 2019-07-25 stsp }
615 5c1e53bc 2019-07-28 stsp
616 f6cae3ed 2020-09-13 naddy test_commit_selected_paths() {
617 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
618 5c1e53bc 2019-07-28 stsp
619 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
620 49c543a6 2022-03-31 naddy ret=$?
621 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
622 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
623 5c1e53bc 2019-07-28 stsp return 1
624 5c1e53bc 2019-07-28 stsp fi
625 5c1e53bc 2019-07-28 stsp
626 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
627 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
628 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
629 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
630 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
631 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
632 90e8619e 2019-07-25 stsp
633 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
634 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
635 49c543a6 2022-03-31 naddy ret=$?
636 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
637 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
638 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
639 5c1e53bc 2019-07-28 stsp return 1
640 5c1e53bc 2019-07-28 stsp fi
641 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
642 5c1e53bc 2019-07-28 stsp
643 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
644 49c543a6 2022-03-31 naddy ret=$?
645 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
646 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
647 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
648 5c1e53bc 2019-07-28 stsp return 1
649 5c1e53bc 2019-07-28 stsp fi
650 5c1e53bc 2019-07-28 stsp
651 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
652 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
653 5c1e53bc 2019-07-28 stsp
654 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
655 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
656 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
657 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
658 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
659 5c1e53bc 2019-07-28 stsp
660 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
661 49c543a6 2022-03-31 naddy ret=$?
662 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
663 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
664 5c1e53bc 2019-07-28 stsp fi
665 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
666 5c1e53bc 2019-07-28 stsp }
667 5c1e53bc 2019-07-28 stsp
668 f6cae3ed 2020-09-13 naddy test_commit_outside_refs_heads() {
669 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
670 916f288c 2019-07-30 stsp
671 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
672 916f288c 2019-07-30 stsp
673 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
674 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
675 49c543a6 2022-03-31 naddy ret=$?
676 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
677 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
678 916f288c 2019-07-30 stsp return 1
679 916f288c 2019-07-30 stsp fi
680 916f288c 2019-07-30 stsp
681 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
682 916f288c 2019-07-30 stsp
683 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
684 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
685 49c543a6 2022-03-31 naddy ret=$?
686 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
687 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
688 916f288c 2019-07-30 stsp test_done "$testroot" "1"
689 916f288c 2019-07-30 stsp return 1
690 916f288c 2019-07-30 stsp fi
691 916f288c 2019-07-30 stsp
692 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
693 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
694 49c543a6 2022-03-31 naddy ret=$?
695 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
696 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
697 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
698 916f288c 2019-07-30 stsp return 1
699 916f288c 2019-07-30 stsp fi
700 916f288c 2019-07-30 stsp
701 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
702 916f288c 2019-07-30 stsp > $testroot/stderr.expected
703 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
704 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
705 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
706 49c543a6 2022-03-31 naddy ret=$?
707 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
708 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
709 916f288c 2019-07-30 stsp fi
710 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
711 916f288c 2019-07-30 stsp }
712 916f288c 2019-07-30 stsp
713 f6cae3ed 2020-09-13 naddy test_commit_no_email() {
714 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
715 cf208ddd 2022-07-19 op local errmsg=""
716 cf208ddd 2022-07-19 op
717 cf208ddd 2022-07-19 op errmsg="commit author's email address is required for"
718 cf208ddd 2022-07-19 op errmsg="$errmsg compatibility with Git"
719 916f288c 2019-07-30 stsp
720 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
721 49c543a6 2022-03-31 naddy ret=$?
722 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
723 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
724 84792843 2019-08-09 stsp return 1
725 84792843 2019-08-09 stsp fi
726 84792843 2019-08-09 stsp
727 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
728 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
729 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
730 84792843 2019-08-09 stsp 2> $testroot/stderr)
731 84792843 2019-08-09 stsp
732 cf208ddd 2022-07-19 op printf "got: :flan_hacker:: %s\n" "$errmsg" > $testroot/stderr.expected
733 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
734 49c543a6 2022-03-31 naddy ret=$?
735 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
736 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
737 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
738 84792843 2019-08-09 stsp return 1
739 84792843 2019-08-09 stsp fi
740 84792843 2019-08-09 stsp
741 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
742 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
743 49c543a6 2022-03-31 naddy ret=$?
744 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
745 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
746 cf208ddd 2022-07-19 op test_done "$testroot" $ret
747 cf208ddd 2022-07-19 op return 1
748 84792843 2019-08-09 stsp fi
749 cf208ddd 2022-07-19 op
750 cf208ddd 2022-07-19 op # try again with a newline inside the email
751 cf208ddd 2022-07-19 op (cd $testroot/wt \
752 cf208ddd 2022-07-19 op && FS=' ' env GOT_AUTHOR="$(printf "Flan <hack\ner>")" \
753 cf208ddd 2022-07-19 op got commit -m 'test invalid email' > $testroot/stdout \
754 cf208ddd 2022-07-19 op 2> $testroot/stderr)
755 cf208ddd 2022-07-19 op
756 cf208ddd 2022-07-19 op printf "got: Flan <hack\ner>: %s\n" "$errmsg" \
757 cf208ddd 2022-07-19 op > $testroot/stderr.expected
758 cf208ddd 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
759 cf208ddd 2022-07-19 op ret=$?
760 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
761 cf208ddd 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
762 cf208ddd 2022-07-19 op test_done "$testroot" $ret
763 cf208ddd 2022-07-19 op return 1
764 cf208ddd 2022-07-19 op fi
765 cf208ddd 2022-07-19 op
766 cf208ddd 2022-07-19 op echo -n > $testroot/stdout.expected
767 cf208ddd 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
768 cf208ddd 2022-07-19 op ret=$?
769 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
770 cf208ddd 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
771 cf208ddd 2022-07-19 op test_done "$testroot" $ret
772 cf208ddd 2022-07-19 op return 1
773 cf208ddd 2022-07-19 op fi
774 cf208ddd 2022-07-19 op
775 cf208ddd 2022-07-19 op # try again with a < inside the email
776 cf208ddd 2022-07-19 op (cd $testroot/wt && env GOT_AUTHOR="$(printf "Flan <ha<ker>")" \
777 cf208ddd 2022-07-19 op got commit -m 'test invalid email' > $testroot/stdout \
778 cf208ddd 2022-07-19 op 2> $testroot/stderr)
779 cf208ddd 2022-07-19 op
780 cf208ddd 2022-07-19 op printf "got: Flan <ha<ker>: %s\n" "$errmsg" > $testroot/stderr.expected
781 cf208ddd 2022-07-19 op cmp -s $testroot/stderr.expected $testroot/stderr
782 cf208ddd 2022-07-19 op ret=$?
783 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
784 cf208ddd 2022-07-19 op diff -u $testroot/stderr.expected $testroot/stderr
785 cf208ddd 2022-07-19 op test_done "$testroot" $ret
786 cf208ddd 2022-07-19 op return 1
787 cf208ddd 2022-07-19 op fi
788 cf208ddd 2022-07-19 op
789 cf208ddd 2022-07-19 op echo -n > $testroot/stdout.expected
790 cf208ddd 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
791 cf208ddd 2022-07-19 op ret=$?
792 cf208ddd 2022-07-19 op if [ $ret -ne 0 ]; then
793 cf208ddd 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
794 cf208ddd 2022-07-19 op fi
795 cf208ddd 2022-07-19 op test_done "$testroot" $ret
796 84792843 2019-08-09 stsp }
797 6af1ccbd 2019-08-16 stsp
798 f6cae3ed 2020-09-13 naddy test_commit_tree_entry_sorting() {
799 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
800 6af1ccbd 2019-08-16 stsp
801 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
802 49c543a6 2022-03-31 naddy ret=$?
803 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
804 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
805 6af1ccbd 2019-08-16 stsp return 1
806 6af1ccbd 2019-08-16 stsp fi
807 6af1ccbd 2019-08-16 stsp
808 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
809 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
810 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
811 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
812 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
813 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
814 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
815 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
816 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
817 84792843 2019-08-09 stsp
818 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
819 84792843 2019-08-09 stsp
820 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
821 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
822 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
823 49c543a6 2022-03-31 naddy ret=$?
824 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
825 62b21d33 2022-07-19 op }
826 62b21d33 2022-07-19 op
827 62b21d33 2022-07-19 op test_commit_cmdline_author() {
828 62b21d33 2022-07-19 op local testroot=`test_init commit_cmdline_author`
829 62b21d33 2022-07-19 op
830 62b21d33 2022-07-19 op got checkout $testroot/repo $testroot/wt > /dev/null
831 62b21d33 2022-07-19 op ret=$?
832 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
833 62b21d33 2022-07-19 op test_done "$testroot" $ret
834 62b21d33 2022-07-19 op return 1
835 62b21d33 2022-07-19 op fi
836 62b21d33 2022-07-19 op
837 62b21d33 2022-07-19 op echo "modified alpha" > $testroot/wt/alpha
838 62b21d33 2022-07-19 op
839 62b21d33 2022-07-19 op local author="Foo <foo@example.com>"
840 62b21d33 2022-07-19 op (cd $testroot/wt && got commit -A "$author" -m 'edit alpha') \
841 62b21d33 2022-07-19 op > /dev/null
842 62b21d33 2022-07-19 op ret=$?
843 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
844 62b21d33 2022-07-19 op test_done "$testroot" $ret
845 62b21d33 2022-07-19 op return 1
846 62b21d33 2022-07-19 op fi
847 62b21d33 2022-07-19 op
848 62b21d33 2022-07-19 op (cd $testroot/repo && got log -l1 | egrep '^(from|via):') \
849 62b21d33 2022-07-19 op > $testroot/stdout
850 62b21d33 2022-07-19 op ret=$?
851 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
852 62b21d33 2022-07-19 op test_done "$testroot" $ret
853 62b21d33 2022-07-19 op return 1
854 62b21d33 2022-07-19 op fi
855 62b21d33 2022-07-19 op
856 62b21d33 2022-07-19 op echo "from: $author" > $testroot/stdout.expected
857 62b21d33 2022-07-19 op echo "via: $GOT_AUTHOR" >> $testroot/stdout.expected
858 62b21d33 2022-07-19 op cmp -s $testroot/stdout.expected $testroot/stdout
859 62b21d33 2022-07-19 op ret=$?
860 62b21d33 2022-07-19 op if [ $ret -ne 0 ]; then
861 62b21d33 2022-07-19 op diff -u $testroot/stdout.expected $testroot/stdout
862 62b21d33 2022-07-19 op fi
863 62b21d33 2022-07-19 op test_done "$testroot" $ret
864 257add31 2020-09-09 stsp }
865 257add31 2020-09-09 stsp
866 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_author() {
867 257add31 2020-09-09 stsp local testroot=`test_init commit_gotconfig_author`
868 257add31 2020-09-09 stsp
869 257add31 2020-09-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
870 49c543a6 2022-03-31 naddy ret=$?
871 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
872 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
873 257add31 2020-09-09 stsp return 1
874 257add31 2020-09-09 stsp fi
875 257add31 2020-09-09 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
876 257add31 2020-09-09 stsp > $testroot/repo/.git/got.conf
877 257add31 2020-09-09 stsp
878 257add31 2020-09-09 stsp echo "modified alpha" > $testroot/wt/alpha
879 257add31 2020-09-09 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
880 49c543a6 2022-03-31 naddy ret=$?
881 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
882 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
883 257add31 2020-09-09 stsp return 1
884 257add31 2020-09-09 stsp fi
885 257add31 2020-09-09 stsp
886 257add31 2020-09-09 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
887 49c543a6 2022-03-31 naddy ret=$?
888 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
889 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
890 257add31 2020-09-09 stsp return 1
891 257add31 2020-09-09 stsp fi
892 257add31 2020-09-09 stsp
893 257add31 2020-09-09 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
894 50b0790e 2020-09-11 stsp > $testroot/stdout.expected
895 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
896 49c543a6 2022-03-31 naddy ret=$?
897 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
898 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
899 50b0790e 2020-09-11 stsp fi
900 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
901 50b0790e 2020-09-11 stsp }
902 50b0790e 2020-09-11 stsp
903 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_worktree_author() {
904 50b0790e 2020-09-11 stsp local testroot=`test_init commit_gotconfig_worktree_author`
905 50b0790e 2020-09-11 stsp
906 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
907 49c543a6 2022-03-31 naddy ret=$?
908 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
909 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
910 50b0790e 2020-09-11 stsp return 1
911 50b0790e 2020-09-11 stsp fi
912 50b0790e 2020-09-11 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
913 50b0790e 2020-09-11 stsp > $testroot/repo/.git/got.conf
914 50b0790e 2020-09-11 stsp echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
915 50b0790e 2020-09-11 stsp > $testroot/wt/.got/got.conf
916 50b0790e 2020-09-11 stsp
917 50b0790e 2020-09-11 stsp echo "modified alpha" > $testroot/wt/alpha
918 50b0790e 2020-09-11 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
919 49c543a6 2022-03-31 naddy ret=$?
920 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
921 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
922 50b0790e 2020-09-11 stsp return 1
923 50b0790e 2020-09-11 stsp fi
924 50b0790e 2020-09-11 stsp
925 50b0790e 2020-09-11 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
926 49c543a6 2022-03-31 naddy ret=$?
927 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
928 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
929 50b0790e 2020-09-11 stsp return 1
930 50b0790e 2020-09-11 stsp fi
931 50b0790e 2020-09-11 stsp
932 50b0790e 2020-09-11 stsp echo "from: Flan Squee <flan_squee@openbsd.org>" \
933 257add31 2020-09-09 stsp > $testroot/stdout.expected
934 257add31 2020-09-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
935 49c543a6 2022-03-31 naddy ret=$?
936 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
937 257add31 2020-09-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
938 257add31 2020-09-09 stsp fi
939 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
940 6af1ccbd 2019-08-16 stsp }
941 aba9c984 2019-09-08 stsp
942 f6cae3ed 2020-09-13 naddy test_commit_gitconfig_author() {
943 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
944 84792843 2019-08-09 stsp
945 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
946 49c543a6 2022-03-31 naddy ret=$?
947 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
948 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
949 aba9c984 2019-09-08 stsp return 1
950 aba9c984 2019-09-08 stsp fi
951 aba9c984 2019-09-08 stsp
952 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
953 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
954 aba9c984 2019-09-08 stsp
955 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
956 7370f802 2022-07-24 op
957 7370f802 2022-07-24 op # unset in a subshell to avoid affecting our environment
958 7370f802 2022-07-24 op (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
959 7370f802 2022-07-24 op got commit -m 'test gitconfig author' > /dev/null)
960 49c543a6 2022-03-31 naddy ret=$?
961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
962 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
963 aba9c984 2019-09-08 stsp return 1
964 aba9c984 2019-09-08 stsp fi
965 aba9c984 2019-09-08 stsp
966 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
967 49c543a6 2022-03-31 naddy ret=$?
968 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
969 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
970 aba9c984 2019-09-08 stsp return 1
971 aba9c984 2019-09-08 stsp fi
972 aba9c984 2019-09-08 stsp
973 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
974 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
975 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
976 49c543a6 2022-03-31 naddy ret=$?
977 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
978 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
979 2b5b5879 2023-02-19 op test_done "$testroot" "$ret"
980 2b5b5879 2023-02-19 op return 1
981 aba9c984 2019-09-08 stsp fi
982 2b5b5879 2023-02-19 op
983 2b5b5879 2023-02-19 op # retry with spaces in the git config
984 2b5b5879 2023-02-19 op ed -s "$testroot/repo/.git/config" <<EOF
985 de51a12a 2023-02-21 op /^\[user/ a
986 de51a12a 2023-02-21 op # it's me!
987 de51a12a 2023-02-21 op .
988 2b5b5879 2023-02-19 op ,s/ / /g
989 2b5b5879 2023-02-19 op wq
990 2b5b5879 2023-02-19 op EOF
991 2b5b5879 2023-02-19 op echo "modified again" > $testroot/wt/alpha
992 2b5b5879 2023-02-19 op
993 2b5b5879 2023-02-19 op # unset in a subshell to avoid affecting our environment
994 2b5b5879 2023-02-19 op (unset GOT_IGNORE_GITCONFIG && cd "$testroot/wt" && \
995 de51a12a 2023-02-21 op got commit -m 'test gitconfig author again' \
996 de51a12a 2023-02-21 op >/dev/null 2>$testroot/stderr)
997 de51a12a 2023-02-21 op ret=$?
998 de51a12a 2023-02-21 op if [ $ret -ne 0 ]; then
999 de51a12a 2023-02-21 op test_done "$testroot" "$ret"
1000 de51a12a 2023-02-21 op return 1
1001 de51a12a 2023-02-21 op fi
1002 de51a12a 2023-02-21 op
1003 de51a12a 2023-02-21 op # shouldn't have triggered any parsing error
1004 de51a12a 2023-02-21 op echo -n > $testroot/stderr.expected
1005 de51a12a 2023-02-21 op cmp -s $testroot/stderr.expected $testroot/stderr
1006 2b5b5879 2023-02-19 op ret=$?
1007 2b5b5879 2023-02-19 op if [ $ret -ne 0 ]; then
1008 de51a12a 2023-02-21 op diff -u $testroot/stderr.expected $testroot/stderr
1009 2b5b5879 2023-02-19 op test_done "$testroot" "$ret"
1010 2b5b5879 2023-02-19 op return 1
1011 2b5b5879 2023-02-19 op fi
1012 2b5b5879 2023-02-19 op
1013 2b5b5879 2023-02-19 op (cd "$testroot/repo" && got log -l1 | grep ^from: > $testroot/stdout)
1014 2b5b5879 2023-02-19 op ret=$?
1015 2b5b5879 2023-02-19 op if [ $ret -ne 0 ]; then
1016 2b5b5879 2023-02-19 op test_done "$testroot" "$ret"
1017 2b5b5879 2023-02-19 op return 1
1018 2b5b5879 2023-02-19 op fi
1019 2b5b5879 2023-02-19 op
1020 2b5b5879 2023-02-19 op echo "from: Flan Luck <flan_luck@openbsd.org>" \
1021 2b5b5879 2023-02-19 op > $testroot/stdout.expected
1022 2b5b5879 2023-02-19 op cmp -s $testroot/stdout.expected $testroot/stdout
1023 2b5b5879 2023-02-19 op ret=$?
1024 2b5b5879 2023-02-19 op if [ $ret -ne 0 ]; then
1025 2b5b5879 2023-02-19 op diff -u $testroot/stdout.expected $testroot/stdout
1026 2b5b5879 2023-02-19 op fi
1027 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
1028 aba9c984 2019-09-08 stsp }
1029 1ebedb77 2019-10-19 stsp
1030 f6cae3ed 2020-09-13 naddy test_commit_xbit_change() {
1031 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
1032 1ebedb77 2019-10-19 stsp
1033 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1034 49c543a6 2022-03-31 naddy ret=$?
1035 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1036 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1037 1ebedb77 2019-10-19 stsp return 1
1038 1ebedb77 2019-10-19 stsp fi
1039 1ebedb77 2019-10-19 stsp
1040 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
1041 1ebedb77 2019-10-19 stsp
1042 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1043 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1044 aba9c984 2019-09-08 stsp
1045 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1046 49c543a6 2022-03-31 naddy ret=$?
1047 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1048 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1049 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1050 1ebedb77 2019-10-19 stsp return 1
1051 1ebedb77 2019-10-19 stsp fi
1052 1ebedb77 2019-10-19 stsp
1053 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
1054 49c543a6 2022-03-31 naddy ret=$?
1055 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1056 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
1057 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1058 1ebedb77 2019-10-19 stsp return 1
1059 1ebedb77 2019-10-19 stsp fi
1060 1ebedb77 2019-10-19 stsp
1061 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
1062 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1063 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1064 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1065 49c543a6 2022-03-31 naddy ret=$?
1066 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1067 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1068 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1069 1ebedb77 2019-10-19 stsp return 1
1070 1ebedb77 2019-10-19 stsp fi
1071 1ebedb77 2019-10-19 stsp
1072 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1073 1ebedb77 2019-10-19 stsp
1074 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
1075 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1076 49c543a6 2022-03-31 naddy ret=$?
1077 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1078 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1079 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1080 1ebedb77 2019-10-19 stsp return 1
1081 1ebedb77 2019-10-19 stsp fi
1082 1ebedb77 2019-10-19 stsp
1083 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
1084 1ebedb77 2019-10-19 stsp
1085 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1086 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1087 1ebedb77 2019-10-19 stsp
1088 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1089 49c543a6 2022-03-31 naddy ret=$?
1090 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1091 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1092 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1093 1ebedb77 2019-10-19 stsp return 1
1094 1ebedb77 2019-10-19 stsp fi
1095 1ebedb77 2019-10-19 stsp
1096 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
1097 49c543a6 2022-03-31 naddy ret=$?
1098 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1099 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
1100 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1101 1ebedb77 2019-10-19 stsp return 1
1102 1ebedb77 2019-10-19 stsp fi
1103 1ebedb77 2019-10-19 stsp
1104 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
1105 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1106 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1107 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1108 49c543a6 2022-03-31 naddy ret=$?
1109 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1110 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1111 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
1112 1ebedb77 2019-10-19 stsp return 1
1113 1ebedb77 2019-10-19 stsp fi
1114 1ebedb77 2019-10-19 stsp
1115 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
1116 1ebedb77 2019-10-19 stsp
1117 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
1118 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
1119 f7b97ccb 2020-04-14 stsp
1120 f7b97ccb 2020-04-14 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 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1124 f7b97ccb 2020-04-14 stsp fi
1125 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1126 f7b97ccb 2020-04-14 stsp }
1127 f7b97ccb 2020-04-14 stsp
1128 f6cae3ed 2020-09-13 naddy commit_check_mode() {
1129 f7b97ccb 2020-04-14 stsp local mode="$1"
1130 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
1131 f7b97ccb 2020-04-14 stsp
1132 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
1133 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
1134 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
1135 f7b97ccb 2020-04-14 stsp
1136 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
1137 49c543a6 2022-03-31 naddy ret=$?
1138 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1139 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
1140 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1141 f7b97ccb 2020-04-14 stsp return 1
1142 f7b97ccb 2020-04-14 stsp fi
1143 1ebedb77 2019-10-19 stsp
1144 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
1145 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
1146 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1147 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1148 49c543a6 2022-03-31 naddy ret=$?
1149 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1150 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1151 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1152 a9662115 2021-08-29 naddy return 1
1153 f7b97ccb 2020-04-14 stsp fi
1154 f7b97ccb 2020-04-14 stsp
1155 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
1156 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
1157 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
1158 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
1159 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
1160 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
1161 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1162 49c543a6 2022-03-31 naddy ret=$?
1163 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1164 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1165 1ebedb77 2019-10-19 stsp fi
1166 f7b97ccb 2020-04-14 stsp return $ret
1167 f7b97ccb 2020-04-14 stsp }
1168 f7b97ccb 2020-04-14 stsp
1169 f6cae3ed 2020-09-13 naddy test_commit_normalizes_filemodes() {
1170 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
1171 f7b97ccb 2020-04-14 stsp
1172 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1173 49c543a6 2022-03-31 naddy ret=$?
1174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1175 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1176 f7b97ccb 2020-04-14 stsp return 1
1177 f7b97ccb 2020-04-14 stsp fi
1178 f7b97ccb 2020-04-14 stsp
1179 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
1180 f7b97ccb 2020-04-14 stsp for m in $modes; do
1181 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
1182 49c543a6 2022-03-31 naddy ret=$?
1183 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1184 f7b97ccb 2020-04-14 stsp break
1185 f7b97ccb 2020-04-14 stsp fi
1186 f7b97ccb 2020-04-14 stsp done
1187 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1188 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1189 f7b97ccb 2020-04-14 stsp return 1
1190 f7b97ccb 2020-04-14 stsp fi
1191 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
1192 f7b97ccb 2020-04-14 stsp for m in $modes; do
1193 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
1194 49c543a6 2022-03-31 naddy ret=$?
1195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1196 f7b97ccb 2020-04-14 stsp break
1197 f7b97ccb 2020-04-14 stsp fi
1198 f7b97ccb 2020-04-14 stsp done
1199 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1200 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
1201 e7303626 2020-05-14 stsp return 1
1202 e7303626 2020-05-14 stsp fi
1203 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1204 e7303626 2020-05-14 stsp }
1205 e7303626 2020-05-14 stsp
1206 f6cae3ed 2020-09-13 naddy test_commit_with_unrelated_submodule() {
1207 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
1208 e7303626 2020-05-14 stsp
1209 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1210 e7303626 2020-05-14 stsp
1211 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
1212 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
1213 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1214 e7303626 2020-05-14 stsp
1215 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1216 49c543a6 2022-03-31 naddy ret=$?
1217 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1218 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
1219 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1220 e7303626 2020-05-14 stsp return 1
1221 e7303626 2020-05-14 stsp fi
1222 e7303626 2020-05-14 stsp
1223 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
1224 e7303626 2020-05-14 stsp
1225 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
1226 7aadece8 2020-05-17 stsp
1227 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1228 49c543a6 2022-03-31 naddy ret=$?
1229 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1230 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
1231 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
1232 f7b97ccb 2020-04-14 stsp return 1
1233 f7b97ccb 2020-04-14 stsp fi
1234 e7303626 2020-05-14 stsp
1235 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
1236 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
1237 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1238 3d9a4ec4 2020-07-23 stsp
1239 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1240 49c543a6 2022-03-31 naddy ret=$?
1241 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1242 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1243 3d9a4ec4 2020-07-23 stsp fi
1244 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1245 3d9a4ec4 2020-07-23 stsp }
1246 3d9a4ec4 2020-07-23 stsp
1247 f6cae3ed 2020-09-13 naddy check_symlinks() {
1248 bd6aa359 2020-07-23 stsp local wtpath="$1"
1249 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
1250 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
1251 bd6aa359 2020-07-23 stsp return 1
1252 bd6aa359 2020-07-23 stsp fi
1253 3d9a4ec4 2020-07-23 stsp
1254 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
1255 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1256 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1257 49c543a6 2022-03-31 naddy ret=$?
1258 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1259 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1260 3d9a4ec4 2020-07-23 stsp return 1
1261 3d9a4ec4 2020-07-23 stsp fi
1262 3d9a4ec4 2020-07-23 stsp
1263 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
1264 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
1265 bd6aa359 2020-07-23 stsp return 1
1266 bd6aa359 2020-07-23 stsp fi
1267 3d9a4ec4 2020-07-23 stsp
1268 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
1269 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1270 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1271 49c543a6 2022-03-31 naddy ret=$?
1272 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1273 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1274 3d9a4ec4 2020-07-23 stsp return 1
1275 3d9a4ec4 2020-07-23 stsp fi
1276 3d9a4ec4 2020-07-23 stsp
1277 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
1278 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1279 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
1280 bd6aa359 2020-07-23 stsp return 1
1281 bd6aa359 2020-07-23 stsp fi
1282 bd6aa359 2020-07-23 stsp
1283 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1284 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
1285 49c543a6 2022-03-31 naddy ret=$?
1286 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1287 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
1288 3d9a4ec4 2020-07-23 stsp return 1
1289 3d9a4ec4 2020-07-23 stsp fi
1290 3d9a4ec4 2020-07-23 stsp
1291 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1292 49c543a6 2022-03-31 naddy ret=$?
1293 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1294 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1295 3d9a4ec4 2020-07-23 stsp return 1
1296 3d9a4ec4 2020-07-23 stsp fi
1297 3d9a4ec4 2020-07-23 stsp
1298 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
1299 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1300 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1301 49c543a6 2022-03-31 naddy ret=$?
1302 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1303 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1304 3d9a4ec4 2020-07-23 stsp return 1
1305 3d9a4ec4 2020-07-23 stsp fi
1306 7aadece8 2020-05-17 stsp
1307 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
1308 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1309 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1310 49c543a6 2022-03-31 naddy ret=$?
1311 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1312 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1313 3d9a4ec4 2020-07-23 stsp return 1
1314 e7303626 2020-05-14 stsp fi
1315 3d9a4ec4 2020-07-23 stsp
1316 bd6aa359 2020-07-23 stsp return 0
1317 bd6aa359 2020-07-23 stsp }
1318 3d9a4ec4 2020-07-23 stsp
1319 f6cae3ed 2020-09-13 naddy test_commit_symlink() {
1320 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
1321 3d9a4ec4 2020-07-23 stsp
1322 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1323 49c543a6 2022-03-31 naddy ret=$?
1324 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1325 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1326 3d9a4ec4 2020-07-23 stsp return 1
1327 3d9a4ec4 2020-07-23 stsp fi
1328 3d9a4ec4 2020-07-23 stsp
1329 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
1330 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
1331 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1332 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1333 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1334 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1335 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
1336 bd6aa359 2020-07-23 stsp
1337 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1338 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1339 49c543a6 2022-03-31 naddy ret=$?
1340 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1341 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1342 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1343 35213c7c 2020-07-23 stsp return 1
1344 35213c7c 2020-07-23 stsp fi
1345 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1346 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1347 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1348 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1349 49c543a6 2022-03-31 naddy ret=$?
1350 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1351 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1352 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1353 35213c7c 2020-07-23 stsp return 1
1354 35213c7c 2020-07-23 stsp fi
1355 bd6aa359 2020-07-23 stsp
1356 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1357 35213c7c 2020-07-23 stsp > $testroot/stdout)
1358 35213c7c 2020-07-23 stsp
1359 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1360 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1361 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1362 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1363 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1364 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1365 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1366 bd6aa359 2020-07-23 stsp
1367 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1368 49c543a6 2022-03-31 naddy ret=$?
1369 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1370 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1371 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1372 3d9a4ec4 2020-07-23 stsp return 1
1373 3d9a4ec4 2020-07-23 stsp fi
1374 3d9a4ec4 2020-07-23 stsp
1375 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1376 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1377 49c543a6 2022-03-31 naddy ret=$?
1378 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1379 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1380 bd6aa359 2020-07-23 stsp return 1
1381 3d9a4ec4 2020-07-23 stsp fi
1382 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1383 49c543a6 2022-03-31 naddy ret=$?
1384 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1385 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1386 bd6aa359 2020-07-23 stsp return 1
1387 bd6aa359 2020-07-23 stsp fi
1388 bd6aa359 2020-07-23 stsp
1389 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1390 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1391 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1392 75f0a0fb 2020-07-23 stsp return 1
1393 75f0a0fb 2020-07-23 stsp fi
1394 75f0a0fb 2020-07-23 stsp
1395 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1396 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1397 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1398 49c543a6 2022-03-31 naddy ret=$?
1399 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1400 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1401 5a1fbc73 2020-07-23 stsp return 1
1402 5a1fbc73 2020-07-23 stsp fi
1403 88fb31d4 2020-07-23 stsp
1404 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1405 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
1406 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1407 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1408 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1409 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1410 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1411 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1412 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1413 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1414 88fb31d4 2020-07-23 stsp
1415 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1416 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1417 49c543a6 2022-03-31 naddy ret=$?
1418 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1419 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1420 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1421 35213c7c 2020-07-23 stsp return 1
1422 35213c7c 2020-07-23 stsp fi
1423 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1424 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1425 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1426 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1427 49c543a6 2022-03-31 naddy ret=$?
1428 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1429 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1430 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1431 35213c7c 2020-07-23 stsp return 1
1432 35213c7c 2020-07-23 stsp fi
1433 88fb31d4 2020-07-23 stsp
1434 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1435 35213c7c 2020-07-23 stsp > $testroot/stdout)
1436 35213c7c 2020-07-23 stsp
1437 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1438 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1439 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1440 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1441 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1442 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1443 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1444 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1445 88fb31d4 2020-07-23 stsp
1446 88fb31d4 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 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1450 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1451 88fb31d4 2020-07-23 stsp return 1
1452 88fb31d4 2020-07-23 stsp fi
1453 88fb31d4 2020-07-23 stsp
1454 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1455 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1456 88fb31d4 2020-07-23 stsp alpha
1457 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1458 88fb31d4 2020-07-23 stsp beta
1459 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1460 88fb31d4 2020-07-23 stsp epsilon/
1461 88fb31d4 2020-07-23 stsp epsilon/beta.link
1462 88fb31d4 2020-07-23 stsp epsilon/zeta
1463 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1464 88fb31d4 2020-07-23 stsp gamma/
1465 88fb31d4 2020-07-23 stsp gamma/delta
1466 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1467 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1468 88fb31d4 2020-07-23 stsp EOF
1469 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1470 49c543a6 2022-03-31 naddy ret=$?
1471 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1472 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1473 88fb31d4 2020-07-23 stsp fi
1474 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1475 5a1fbc73 2020-07-23 stsp }
1476 5a1fbc73 2020-07-23 stsp
1477 f6cae3ed 2020-09-13 naddy test_commit_fix_bad_symlink() {
1478 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1479 5a1fbc73 2020-07-23 stsp
1480 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1481 49c543a6 2022-03-31 naddy ret=$?
1482 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1483 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1484 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1485 5a1fbc73 2020-07-23 stsp return 1
1486 5a1fbc73 2020-07-23 stsp fi
1487 5a1fbc73 2020-07-23 stsp
1488 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1489 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1490 5a1fbc73 2020-07-23 stsp
1491 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1492 35213c7c 2020-07-23 stsp > $testroot/stdout)
1493 5a1fbc73 2020-07-23 stsp
1494 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1495 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1496 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1497 75f0a0fb 2020-07-23 stsp return 1
1498 75f0a0fb 2020-07-23 stsp fi
1499 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1500 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1501 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1502 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1503 5a1fbc73 2020-07-23 stsp return 1
1504 5a1fbc73 2020-07-23 stsp fi
1505 5a1fbc73 2020-07-23 stsp
1506 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1507 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1508 49c543a6 2022-03-31 naddy ret=$?
1509 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1510 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1511 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1512 5a1fbc73 2020-07-23 stsp return 1
1513 5a1fbc73 2020-07-23 stsp fi
1514 5a1fbc73 2020-07-23 stsp
1515 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1516 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm passwd.link && ln -s alpha passwd.link)
1517 5a1fbc73 2020-07-23 stsp
1518 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1519 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1520 5a1fbc73 2020-07-23 stsp
1521 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1522 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1523 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1524 5a1fbc73 2020-07-23 stsp
1525 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1526 49c543a6 2022-03-31 naddy ret=$?
1527 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1528 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1529 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1530 bd6aa359 2020-07-23 stsp return 1
1531 bd6aa359 2020-07-23 stsp fi
1532 5a1fbc73 2020-07-23 stsp
1533 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1534 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1535 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1536 5a1fbc73 2020-07-23 stsp return 1
1537 5a1fbc73 2020-07-23 stsp fi
1538 5a1fbc73 2020-07-23 stsp
1539 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1540 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1541 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1542 49c543a6 2022-03-31 naddy ret=$?
1543 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1544 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1545 5a1fbc73 2020-07-23 stsp return 1
1546 5a1fbc73 2020-07-23 stsp fi
1547 5a1fbc73 2020-07-23 stsp
1548 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1549 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1550 49c543a6 2022-03-31 naddy ret=$?
1551 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1552 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1553 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1554 5a1fbc73 2020-07-23 stsp return 1
1555 5a1fbc73 2020-07-23 stsp fi
1556 5a1fbc73 2020-07-23 stsp
1557 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1558 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1559 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1560 5a1fbc73 2020-07-23 stsp return 1
1561 5a1fbc73 2020-07-23 stsp fi
1562 5a1fbc73 2020-07-23 stsp
1563 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1564 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1565 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1566 49c543a6 2022-03-31 naddy ret=$?
1567 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1568 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1569 5a1fbc73 2020-07-23 stsp return 1
1570 5a1fbc73 2020-07-23 stsp fi
1571 5a1fbc73 2020-07-23 stsp
1572 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1573 1ebedb77 2019-10-19 stsp }
1574 28cf319f 2021-01-28 stsp
1575 28cf319f 2021-01-28 stsp test_commit_prepared_logmsg() {
1576 28cf319f 2021-01-28 stsp local testroot=`test_init commit_prepared_logmsg`
1577 28cf319f 2021-01-28 stsp
1578 28cf319f 2021-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1579 49c543a6 2022-03-31 naddy ret=$?
1580 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1581 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1582 28cf319f 2021-01-28 stsp return 1
1583 28cf319f 2021-01-28 stsp fi
1584 28cf319f 2021-01-28 stsp
1585 28cf319f 2021-01-28 stsp echo "modified alpha" > $testroot/wt/alpha
1586 28cf319f 2021-01-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
1587 28cf319f 2021-01-28 stsp echo "new file" > $testroot/wt/new
1588 28cf319f 2021-01-28 stsp (cd $testroot/wt && got add new >/dev/null)
1589 28cf319f 2021-01-28 stsp
1590 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg' > $testroot/logmsg
1591 28cf319f 2021-01-28 stsp
1592 57993930 2023-03-05 op # a no-op editor script
1593 57993930 2023-03-05 op > $testroot/editor.sh
1594 28cf319f 2021-01-28 stsp chmod +x $testroot/editor.sh
1595 28cf319f 2021-01-28 stsp
1596 8e09a168 2021-06-17 tracey (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1597 28cf319f 2021-01-28 stsp got commit -F "$testroot/logmsg" > $testroot/stdout)
1598 1ebedb77 2019-10-19 stsp
1599 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1600 28cf319f 2021-01-28 stsp echo "A new" > $testroot/stdout.expected
1601 28cf319f 2021-01-28 stsp echo "M alpha" >> $testroot/stdout.expected
1602 28cf319f 2021-01-28 stsp echo "D beta" >> $testroot/stdout.expected
1603 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1604 28cf319f 2021-01-28 stsp
1605 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1606 49c543a6 2022-03-31 naddy ret=$?
1607 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1608 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1609 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1610 28cf319f 2021-01-28 stsp return 1
1611 28cf319f 2021-01-28 stsp fi
1612 28cf319f 2021-01-28 stsp
1613 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1614 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1615 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" > $testroot/stdout.expected
1616 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1617 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1618 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1619 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1620 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1621 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1622 28cf319f 2021-01-28 stsp
1623 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1624 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1625 49c543a6 2022-03-31 naddy ret=$?
1626 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1627 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1628 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1629 28cf319f 2021-01-28 stsp return 1
1630 28cf319f 2021-01-28 stsp fi
1631 28cf319f 2021-01-28 stsp
1632 28cf319f 2021-01-28 stsp echo "modified alpha again" > $testroot/wt/alpha
1633 28cf319f 2021-01-28 stsp
1634 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg non-interactive' \
1635 28cf319f 2021-01-28 stsp > $testroot/logmsg
1636 28cf319f 2021-01-28 stsp
1637 28cf319f 2021-01-28 stsp (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1638 28cf319f 2021-01-28 stsp > $testroot/stdout)
1639 28cf319f 2021-01-28 stsp
1640 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1641 28cf319f 2021-01-28 stsp echo "M alpha" > $testroot/stdout.expected
1642 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1643 28cf319f 2021-01-28 stsp
1644 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1645 49c543a6 2022-03-31 naddy ret=$?
1646 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1647 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1648 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1649 28cf319f 2021-01-28 stsp return 1
1650 28cf319f 2021-01-28 stsp fi
1651 28cf319f 2021-01-28 stsp
1652 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1653 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1654 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" \
1655 28cf319f 2021-01-28 stsp > $testroot/stdout.expected
1656 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1657 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1658 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1659 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1660 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg non-interactive" \
1661 28cf319f 2021-01-28 stsp >> $testroot/stdout.expected
1662 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1663 28cf319f 2021-01-28 stsp
1664 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1665 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1666 49c543a6 2022-03-31 naddy ret=$?
1667 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1668 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1669 28cf319f 2021-01-28 stsp fi
1670 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1671 28cf319f 2021-01-28 stsp }
1672 72840534 2022-01-19 stsp
1673 72840534 2022-01-19 stsp test_commit_large_file() {
1674 72840534 2022-01-19 stsp local testroot=`test_init commit_large_file`
1675 72840534 2022-01-19 stsp
1676 72840534 2022-01-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1677 49c543a6 2022-03-31 naddy ret=$?
1678 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1679 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1680 72840534 2022-01-19 stsp return 1
1681 72840534 2022-01-19 stsp fi
1682 72840534 2022-01-19 stsp
1683 230e1f1b 2022-07-05 stsp dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1684 72840534 2022-01-19 stsp (cd $testroot/wt && got add new >/dev/null)
1685 28cf319f 2021-01-28 stsp
1686 72840534 2022-01-19 stsp (cd $testroot/wt && got commit -m 'test commit_large_file' \
1687 72840534 2022-01-19 stsp > $testroot/stdout)
1688 72840534 2022-01-19 stsp
1689 72840534 2022-01-19 stsp local head_rev=`git_show_head $testroot/repo`
1690 72840534 2022-01-19 stsp echo "A new" > $testroot/stdout.expected
1691 72840534 2022-01-19 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1692 72840534 2022-01-19 stsp
1693 72840534 2022-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1694 49c543a6 2022-03-31 naddy ret=$?
1695 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1696 72840534 2022-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1697 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1698 72840534 2022-01-19 stsp return 1
1699 72840534 2022-01-19 stsp fi
1700 72840534 2022-01-19 stsp
1701 72840534 2022-01-19 stsp new_id=`get_blob_id $testroot/repo "" new`
1702 72840534 2022-01-19 stsp got cat -r $testroot/repo $new_id > $testroot/new
1703 49c543a6 2022-03-31 naddy ret=$?
1704 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1705 72840534 2022-01-19 stsp echo "commit failed unexpectedly" >&2
1706 72840534 2022-01-19 stsp test_done "$testroot" "1"
1707 72840534 2022-01-19 stsp return 1
1708 72840534 2022-01-19 stsp fi
1709 72840534 2022-01-19 stsp
1710 72840534 2022-01-19 stsp cmp -s $testroot/new $testroot/wt/new
1711 49c543a6 2022-03-31 naddy ret=$?
1712 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1713 72840534 2022-01-19 stsp diff -u $testroot/new $testroot/wt/new
1714 72840534 2022-01-19 stsp fi
1715 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1716 4ba2e955 2022-09-02 sh+got
1717 4ba2e955 2022-09-02 sh+got
1718 4ba2e955 2022-09-02 sh+got }
1719 4ba2e955 2022-09-02 sh+got
1720 4ba2e955 2022-09-02 sh+got test_commit_gitignore() {
1721 4ba2e955 2022-09-02 sh+got local testroot=`test_init commit_gitignores`
1722 4ba2e955 2022-09-02 sh+got
1723 4ba2e955 2022-09-02 sh+got got checkout $testroot/repo $testroot/wt > /dev/null
1724 4ba2e955 2022-09-02 sh+got ret=$?
1725 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1726 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1727 4ba2e955 2022-09-02 sh+got return 1
1728 4ba2e955 2022-09-02 sh+got fi
1729 4ba2e955 2022-09-02 sh+got
1730 4ba2e955 2022-09-02 sh+got mkdir -p $testroot/wt/tree1/foo
1731 4ba2e955 2022-09-02 sh+got mkdir -p $testroot/wt/tree2/foo
1732 4ba2e955 2022-09-02 sh+got echo "tree1/**" > $testroot/wt/.gitignore
1733 4ba2e955 2022-09-02 sh+got echo "tree2/**" >> $testroot/wt/.gitignore
1734 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree1/bar
1735 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree1/foo/baz
1736 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree2/bar
1737 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/tree2/foo/baz
1738 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/epsilon/zeta1
1739 4ba2e955 2022-09-02 sh+got echo -n > $testroot/wt/epsilon/zeta2
1740 4ba2e955 2022-09-02 sh+got
1741 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got add -I -R tree1 > /dev/null)
1742 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got add -I tree2/foo/baz > /dev/null)
1743 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got commit -m "gitignore add" > /dev/null)
1744 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1745 4ba2e955 2022-09-02 sh+got
1746 4ba2e955 2022-09-02 sh+got echo ' gitignore add' > $testroot/stdout.expected
1747 4ba2e955 2022-09-02 sh+got echo ' A tree1/bar' >> $testroot/stdout.expected
1748 4ba2e955 2022-09-02 sh+got echo ' A tree1/foo/baz' >> $testroot/stdout.expected
1749 4ba2e955 2022-09-02 sh+got echo ' A tree2/foo/baz' >> $testroot/stdout.expected
1750 72840534 2022-01-19 stsp
1751 4ba2e955 2022-09-02 sh+got cmp -s $testroot/stdout.expected $testroot/stdout
1752 4ba2e955 2022-09-02 sh+got ret=$?
1753 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1754 4ba2e955 2022-09-02 sh+got diff -u $testroot/stdout.expected $testroot/stdout
1755 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1756 4ba2e955 2022-09-02 sh+got return 1
1757 4ba2e955 2022-09-02 sh+got fi
1758 72840534 2022-01-19 stsp
1759 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/tree1/bar
1760 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/tree1/foo/baz
1761 4ba2e955 2022-09-02 sh+got echo touch > $testroot/wt/epsilon/zeta1
1762 4ba2e955 2022-09-02 sh+got
1763 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got commit -m "gitignore change" > /dev/null)
1764 4ba2e955 2022-09-02 sh+got (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1765 4ba2e955 2022-09-02 sh+got
1766 4ba2e955 2022-09-02 sh+got echo ' gitignore change' > $testroot/stdout.expected
1767 4ba2e955 2022-09-02 sh+got echo ' M tree1/bar' >> $testroot/stdout.expected
1768 4ba2e955 2022-09-02 sh+got echo ' M tree1/foo/baz' >> $testroot/stdout.expected
1769 4ba2e955 2022-09-02 sh+got
1770 4ba2e955 2022-09-02 sh+got cmp -s $testroot/stdout.expected $testroot/stdout
1771 4ba2e955 2022-09-02 sh+got ret=$?
1772 4ba2e955 2022-09-02 sh+got if [ $ret -ne 0 ]; then
1773 4ba2e955 2022-09-02 sh+got diff -u $testroot/stdout.expected $testroot/stdout
1774 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1775 4ba2e955 2022-09-02 sh+got return 1
1776 4ba2e955 2022-09-02 sh+got fi
1777 4ba2e955 2022-09-02 sh+got
1778 4ba2e955 2022-09-02 sh+got test_done "$testroot" "$ret"
1779 72840534 2022-01-19 stsp }
1780 21f07726 2022-10-31 stsp
1781 21f07726 2022-10-31 stsp test_commit_bad_author() {
1782 21f07726 2022-10-31 stsp local testroot=`test_init commit_bad_author`
1783 21f07726 2022-10-31 stsp
1784 21f07726 2022-10-31 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1785 21f07726 2022-10-31 stsp ret=$?
1786 21f07726 2022-10-31 stsp if [ $ret -ne 0 ]; then
1787 21f07726 2022-10-31 stsp test_done "$testroot" $ret
1788 21f07726 2022-10-31 stsp return 1
1789 21f07726 2022-10-31 stsp fi
1790 21f07726 2022-10-31 stsp
1791 21f07726 2022-10-31 stsp echo "modified alpha" > $testroot/wt/alpha
1792 21f07726 2022-10-31 stsp
1793 21f07726 2022-10-31 stsp (cd $testroot/wt && got commit \
1794 21f07726 2022-10-31 stsp -A "${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>" -m 'edit alpha') \
1795 21f07726 2022-10-31 stsp > /dev/null 2> $testroot/stderr
1796 21f07726 2022-10-31 stsp ret=$?
1797 21f07726 2022-10-31 stsp if [ $ret -eq 0 ]; then
1798 21f07726 2022-10-31 stsp test_done "$testroot" 1
1799 21f07726 2022-10-31 stsp return 1
1800 21f07726 2022-10-31 stsp fi
1801 72840534 2022-01-19 stsp
1802 21f07726 2022-10-31 stsp echo -n "got: ${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>: " \
1803 21f07726 2022-10-31 stsp > $testroot/stderr.expected
1804 21f07726 2022-10-31 stsp echo -n 'space between author name and email required: ' \
1805 21f07726 2022-10-31 stsp >> $testroot/stderr.expected
1806 21f07726 2022-10-31 stsp echo 'commit author formatting would make Git unhappy' \
1807 21f07726 2022-10-31 stsp >> $testroot/stderr.expected
1808 21f07726 2022-10-31 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1809 21f07726 2022-10-31 stsp ret=$?
1810 21f07726 2022-10-31 stsp if [ $ret -ne 0 ]; then
1811 21f07726 2022-10-31 stsp diff -u $testroot/stderr.expected $testroot/stderr
1812 21f07726 2022-10-31 stsp test_done "$testroot" $ret
1813 21f07726 2022-10-31 stsp return 1
1814 21f07726 2022-10-31 stsp fi
1815 72840534 2022-01-19 stsp
1816 21f07726 2022-10-31 stsp test_done "$testroot" 0
1817 21f07726 2022-10-31 stsp }
1818 def2bea2 2023-01-30 mark
1819 def2bea2 2023-01-30 mark test_commit_logmsg_ref() {
1820 def2bea2 2023-01-30 mark local testroot=`test_init commit_logmsg_ref`
1821 def2bea2 2023-01-30 mark
1822 def2bea2 2023-01-30 mark got checkout $testroot/repo $testroot/wt > /dev/null
1823 def2bea2 2023-01-30 mark ret=$?
1824 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1825 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1826 def2bea2 2023-01-30 mark return 1
1827 def2bea2 2023-01-30 mark fi
1828 def2bea2 2023-01-30 mark
1829 def2bea2 2023-01-30 mark (cd $testroot/repo && git checkout -q -b newbranch)
1830 def2bea2 2023-01-30 mark
1831 def2bea2 2023-01-30 mark local bo_logmsg_prefix="log message of backed-out commit"
1832 def2bea2 2023-01-30 mark local cy_logmsg_prefix="log message of cherrypicked commit"
1833 def2bea2 2023-01-30 mark local branch_rev_logmsg="changes on newbranch to cherrypick"
1834 def2bea2 2023-01-30 mark local branch_rev2_logmsg="modified zeta on newbranch to cherrypick"
1835 def2bea2 2023-01-30 mark
1836 def2bea2 2023-01-30 mark echo "modified delta on branch" > $testroot/repo/gamma/delta
1837 def2bea2 2023-01-30 mark echo "modified alpha on branch" > $testroot/repo/alpha
1838 def2bea2 2023-01-30 mark (cd $testroot/repo && git rm -q beta)
1839 def2bea2 2023-01-30 mark echo "new file on branch" > $testroot/repo/epsilon/new
1840 def2bea2 2023-01-30 mark (cd $testroot/repo && git add epsilon/new)
1841 def2bea2 2023-01-30 mark
1842 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev_logmsg"
1843 def2bea2 2023-01-30 mark local branch_rev=`git_show_head $testroot/repo`
1844 def2bea2 2023-01-30 mark
1845 def2bea2 2023-01-30 mark echo "modified zeta on branch" > $testroot/repo/epsilon/zeta
1846 def2bea2 2023-01-30 mark
1847 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev2_logmsg"
1848 def2bea2 2023-01-30 mark local branch_rev2=`git_show_head $testroot/repo`
1849 def2bea2 2023-01-30 mark
1850 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1851 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev2 > /dev/null)
1852 21f07726 2022-10-31 stsp
1853 def2bea2 2023-01-30 mark cat > $testroot/editor.sh <<EOF
1854 def2bea2 2023-01-30 mark #!/bin/sh
1855 885e96df 2023-03-06 naddy ed -s "\$1" <<-EOF
1856 885e96df 2023-03-06 naddy ,s/# l/l/
1857 885e96df 2023-03-06 naddy w
1858 885e96df 2023-03-06 naddy EOF
1859 def2bea2 2023-01-30 mark EOF
1860 def2bea2 2023-01-30 mark chmod +x $testroot/editor.sh
1861 def2bea2 2023-01-30 mark
1862 def2bea2 2023-01-30 mark (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1863 def2bea2 2023-01-30 mark got commit > /dev/null)
1864 def2bea2 2023-01-30 mark ret=$?
1865 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1866 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1867 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1868 def2bea2 2023-01-30 mark return 1
1869 def2bea2 2023-01-30 mark fi
1870 def2bea2 2023-01-30 mark
1871 def2bea2 2023-01-30 mark # check that multiple cherrypicked log messages populate the editor
1872 def2bea2 2023-01-30 mark local first=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | head -1`
1873 def2bea2 2023-01-30 mark local second=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | tail -1`
1874 def2bea2 2023-01-30 mark
1875 1a4be250 2023-03-03 thomas if [ $branch_rev = $first ]; then
1876 def2bea2 2023-01-30 mark local first_msg=$branch_rev_logmsg
1877 def2bea2 2023-01-30 mark local second_msg=$branch_rev2_logmsg
1878 def2bea2 2023-01-30 mark else
1879 def2bea2 2023-01-30 mark local first_msg=$branch_rev2_logmsg
1880 def2bea2 2023-01-30 mark local second_msg=$branch_rev_logmsg
1881 def2bea2 2023-01-30 mark fi
1882 def2bea2 2023-01-30 mark
1883 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $first:" > $testroot/stdout.expected
1884 def2bea2 2023-01-30 mark echo " $first_msg" >> $testroot/stdout.expected
1885 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1886 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $second:" >> $testroot/stdout.expected
1887 def2bea2 2023-01-30 mark echo " $second_msg" >> $testroot/stdout.expected
1888 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1889 def2bea2 2023-01-30 mark
1890 def2bea2 2023-01-30 mark (cd $testroot/wt && got log -l2 | \
1891 def2bea2 2023-01-30 mark grep -A2 'log message' | sed '/^--/d' > $testroot/stdout)
1892 def2bea2 2023-01-30 mark
1893 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1894 def2bea2 2023-01-30 mark ret=$?
1895 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1896 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1897 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1898 def2bea2 2023-01-30 mark return 1
1899 def2bea2 2023-01-30 mark fi
1900 def2bea2 2023-01-30 mark
1901 def2bea2 2023-01-30 mark # check that only the relevant log message populates the editor
1902 def2bea2 2023-01-30 mark # when the changes from one of two backout commits are reverted
1903 def2bea2 2023-01-30 mark got checkout $testroot/repo $testroot/wt2 > /dev/null
1904 def2bea2 2023-01-30 mark ret=$?
1905 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1906 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1907 def2bea2 2023-01-30 mark return 1
1908 def2bea2 2023-01-30 mark fi
1909 def2bea2 2023-01-30 mark
1910 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got backout $branch_rev > /dev/null)
1911 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got backout $branch_rev2 > /dev/null)
1912 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got revert epsilon/zeta > /dev/null)
1913 def2bea2 2023-01-30 mark
1914 def2bea2 2023-01-30 mark (cd $testroot/wt2 && env VISUAL="$testroot/editor.sh" \
1915 def2bea2 2023-01-30 mark got commit > /dev/null)
1916 def2bea2 2023-01-30 mark ret=$?
1917 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1918 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1919 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1920 def2bea2 2023-01-30 mark return 1
1921 def2bea2 2023-01-30 mark fi
1922 def2bea2 2023-01-30 mark
1923 def2bea2 2023-01-30 mark echo " $bo_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1924 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1925 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1926 def2bea2 2023-01-30 mark
1927 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got log -l1 | \
1928 def2bea2 2023-01-30 mark grep -A2 'log message' > $testroot/stdout)
1929 def2bea2 2023-01-30 mark
1930 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1931 def2bea2 2023-01-30 mark ret=$?
1932 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1933 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1934 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1935 def2bea2 2023-01-30 mark return 1
1936 def2bea2 2023-01-30 mark fi
1937 def2bea2 2023-01-30 mark
1938 def2bea2 2023-01-30 mark # check that a cherrypicked log message is still
1939 def2bea2 2023-01-30 mark # used when its changes are only partially reverted
1940 def2bea2 2023-01-30 mark branch_rev_logmsg="changes to cherrypick and partially revert"
1941 def2bea2 2023-01-30 mark
1942 def2bea2 2023-01-30 mark echo "newline in alpha" >> $testroot/repo/alpha
1943 def2bea2 2023-01-30 mark echo "modified epsilon/zeta on branch" > $testroot/repo/epsilon/zeta
1944 def2bea2 2023-01-30 mark
1945 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev_logmsg"
1946 def2bea2 2023-01-30 mark branch_rev=`git_show_head $testroot/repo`
1947 def2bea2 2023-01-30 mark
1948 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1949 def2bea2 2023-01-30 mark (cd $testroot/wt && got revert alpha > /dev/null)
1950 def2bea2 2023-01-30 mark
1951 def2bea2 2023-01-30 mark (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1952 def2bea2 2023-01-30 mark got commit > /dev/null)
1953 def2bea2 2023-01-30 mark ret=$?
1954 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1955 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
1956 def2bea2 2023-01-30 mark test_done "$testroot" "1"
1957 def2bea2 2023-01-30 mark return 1
1958 def2bea2 2023-01-30 mark fi
1959 def2bea2 2023-01-30 mark
1960 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1961 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1962 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
1963 def2bea2 2023-01-30 mark
1964 def2bea2 2023-01-30 mark (cd $testroot/wt && got log -l1 | \
1965 def2bea2 2023-01-30 mark grep -A2 'log message' > $testroot/stdout)
1966 def2bea2 2023-01-30 mark
1967 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
1968 def2bea2 2023-01-30 mark ret=$?
1969 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1970 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
1971 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1972 def2bea2 2023-01-30 mark return 1
1973 def2bea2 2023-01-30 mark fi
1974 def2bea2 2023-01-30 mark
1975 def2bea2 2023-01-30 mark # check we don't use and consequently delete the logmsg ref of a
1976 def2bea2 2023-01-30 mark # cherrypicked commit when omitting its changed path from the commit
1977 def2bea2 2023-01-30 mark branch_rev_logmsg="changes to cherrypick but omit from the commit"
1978 def2bea2 2023-01-30 mark
1979 def2bea2 2023-01-30 mark echo "changed delta" >> $testroot/repo/gamma/delta
1980 def2bea2 2023-01-30 mark
1981 def2bea2 2023-01-30 mark git_commit $testroot/repo -m "$branch_rev_logmsg"
1982 def2bea2 2023-01-30 mark local author_time=`git_show_author_time $testroot/repo`
1983 def2bea2 2023-01-30 mark local d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1984 def2bea2 2023-01-30 mark branch_rev=`git_show_head $testroot/repo`
1985 def2bea2 2023-01-30 mark
1986 def2bea2 2023-01-30 mark (cd $testroot/wt && got update > /dev/null)
1987 def2bea2 2023-01-30 mark ret=$?
1988 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
1989 def2bea2 2023-01-30 mark echo "got update failed unexpectedly" >&2
1990 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
1991 def2bea2 2023-01-30 mark return 1
1992 def2bea2 2023-01-30 mark fi
1993 def2bea2 2023-01-30 mark
1994 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1995 def2bea2 2023-01-30 mark
1996 def2bea2 2023-01-30 mark echo "changed alpha" >> $testroot/wt/alpha
1997 def2bea2 2023-01-30 mark
1998 def2bea2 2023-01-30 mark (cd $testroot/wt && got commit -m \
1999 def2bea2 2023-01-30 mark "don't commit cy change to gamma/delta" alpha > /dev/null)
2000 def2bea2 2023-01-30 mark ret=$?
2001 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2002 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
2003 def2bea2 2023-01-30 mark test_done "$testroot" "1"
2004 def2bea2 2023-01-30 mark return 1
2005 def2bea2 2023-01-30 mark fi
2006 def2bea2 2023-01-30 mark
2007 def2bea2 2023-01-30 mark # confirm logmsg ref was not deleted with got cherrypick -l
2008 def2bea2 2023-01-30 mark echo "-----------------------------------------------" \
2009 def2bea2 2023-01-30 mark > $testroot/stdout.expected
2010 b584caa3 2023-01-30 mark echo "cherrypick $branch_rev (newbranch)" >> $testroot/stdout.expected
2011 def2bea2 2023-01-30 mark echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
2012 def2bea2 2023-01-30 mark echo "date: $d" >> $testroot/stdout.expected
2013 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
2014 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
2015 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
2016 def2bea2 2023-01-30 mark echo " M gamma/delta" >> $testroot/stdout.expected
2017 def2bea2 2023-01-30 mark echo >> $testroot/stdout.expected
2018 def2bea2 2023-01-30 mark
2019 def2bea2 2023-01-30 mark (cd $testroot/wt && got cherrypick -l > $testroot/stdout)
2020 def2bea2 2023-01-30 mark
2021 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2022 def2bea2 2023-01-30 mark ret=$?
2023 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2024 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2025 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
2026 def2bea2 2023-01-30 mark return 1
2027 def2bea2 2023-01-30 mark fi
2028 def2bea2 2023-01-30 mark
2029 def2bea2 2023-01-30 mark # confirm a previously unused logmsg ref is picked up
2030 def2bea2 2023-01-30 mark # when an affected path is actually committed
2031 def2bea2 2023-01-30 mark (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2032 def2bea2 2023-01-30 mark got commit > /dev/null)
2033 def2bea2 2023-01-30 mark ret=$?
2034 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2035 def2bea2 2023-01-30 mark echo "'got commit' failed unexpectedly" >&2
2036 def2bea2 2023-01-30 mark test_done "$testroot" "1"
2037 def2bea2 2023-01-30 mark return 1
2038 def2bea2 2023-01-30 mark fi
2039 def2bea2 2023-01-30 mark
2040 def2bea2 2023-01-30 mark echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
2041 def2bea2 2023-01-30 mark echo " $branch_rev_logmsg" >> $testroot/stdout.expected
2042 def2bea2 2023-01-30 mark echo " " >> $testroot/stdout.expected
2043 def2bea2 2023-01-30 mark
2044 def2bea2 2023-01-30 mark (cd $testroot/wt && got log -l1 | \
2045 def2bea2 2023-01-30 mark grep -A2 'log message' > $testroot/stdout)
2046 def2bea2 2023-01-30 mark
2047 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2048 def2bea2 2023-01-30 mark ret=$?
2049 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2050 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2051 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
2052 def2bea2 2023-01-30 mark return 1
2053 def2bea2 2023-01-30 mark fi
2054 def2bea2 2023-01-30 mark
2055 def2bea2 2023-01-30 mark # make sure we are not littering work trees
2056 def2bea2 2023-01-30 mark # by leaving temp got-logmsg-* files behind
2057 def2bea2 2023-01-30 mark echo -n > $testroot/stdout.expected
2058 def2bea2 2023-01-30 mark (cd $testroot/wt && got status > $testroot/stdout)
2059 def2bea2 2023-01-30 mark
2060 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2061 def2bea2 2023-01-30 mark ret=$?
2062 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2063 def2bea2 2023-01-30 mark echo "$testroot/wt is not clean"
2064 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2065 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
2066 def2bea2 2023-01-30 mark return 1
2067 def2bea2 2023-01-30 mark fi
2068 def2bea2 2023-01-30 mark
2069 def2bea2 2023-01-30 mark (cd $testroot/wt2 && got status > $testroot/stdout)
2070 def2bea2 2023-01-30 mark
2071 def2bea2 2023-01-30 mark cmp -s $testroot/stdout.expected $testroot/stdout
2072 def2bea2 2023-01-30 mark ret=$?
2073 def2bea2 2023-01-30 mark if [ $ret -ne 0 ]; then
2074 def2bea2 2023-01-30 mark echo "$testroot/repo is not clean"
2075 def2bea2 2023-01-30 mark diff -u $testroot/stdout.expected $testroot/stdout
2076 def2bea2 2023-01-30 mark fi
2077 def2bea2 2023-01-30 mark test_done "$testroot" "$ret"
2078 2b706956 2023-04-17 stsp }
2079 2b706956 2023-04-17 stsp
2080 2b706956 2023-04-17 stsp test_commit_from_different_worktrees() {
2081 2b706956 2023-04-17 stsp local testroot=$(test_init commit_from_different_worktrees)
2082 2b706956 2023-04-17 stsp
2083 2b706956 2023-04-17 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2084 2b706956 2023-04-17 stsp ret=$?
2085 2b706956 2023-04-17 stsp if [ $ret -ne 0 ]; then
2086 2b706956 2023-04-17 stsp test_done "$testroot" "$ret"
2087 2b706956 2023-04-17 stsp return 1
2088 2b706956 2023-04-17 stsp fi
2089 2b706956 2023-04-17 stsp
2090 2b706956 2023-04-17 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
2091 2b706956 2023-04-17 stsp ret=$?
2092 2b706956 2023-04-17 stsp if [ $ret -ne 0 ]; then
2093 2b706956 2023-04-17 stsp test_done "$testroot" "$ret"
2094 2b706956 2023-04-17 stsp return 1
2095 2b706956 2023-04-17 stsp fi
2096 2b706956 2023-04-17 stsp
2097 2b706956 2023-04-17 stsp echo "new file" > $testroot/wt2/new
2098 2b706956 2023-04-17 stsp (cd $testroot/wt2 && got add new >/dev/null)
2099 2b706956 2023-04-17 stsp (cd $testroot/wt2 && got commit -m 'add new file from wt2' > \
2100 2b706956 2023-04-17 stsp $testroot/stdout)
2101 2b706956 2023-04-17 stsp local wt2_head_id=$(git_show_head $testroot/repo)
2102 2b706956 2023-04-17 stsp
2103 2b706956 2023-04-17 stsp echo "modified alpha" > $testroot/wt/alpha
2104 2b706956 2023-04-17 stsp (cd $testroot/wt && got commit -m 'mod alpha in wt' > $testroot/stdout)
2105 2b706956 2023-04-17 stsp local wt1_parent_id=$(git_show_parent_commit $testroot/repo)
2106 2b706956 2023-04-17 stsp
2107 2b706956 2023-04-17 stsp if [ $wt2_head_id != $wt1_parent_id ]; then
2108 2b706956 2023-04-17 stsp echo "commit lost from different work tree" >&2
2109 2b706956 2023-04-17 stsp test_done "$testroot" "1"
2110 2b706956 2023-04-17 stsp fi
2111 2b706956 2023-04-17 stsp
2112 2b706956 2023-04-17 stsp test_done "$testroot" "0"
2113 def2bea2 2023-01-30 mark }
2114 def2bea2 2023-01-30 mark
2115 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2116 c4296144 2019-05-09 stsp run_test test_commit_basic
2117 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
2118 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
2119 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
2120 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
2121 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
2122 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
2123 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
2124 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
2125 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
2126 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
2127 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
2128 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
2129 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
2130 84792843 2019-08-09 stsp run_test test_commit_no_email
2131 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
2132 62b21d33 2022-07-19 op run_test test_commit_cmdline_author
2133 257add31 2020-09-09 stsp run_test test_commit_gotconfig_author
2134 50b0790e 2020-09-11 stsp run_test test_commit_gotconfig_worktree_author
2135 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
2136 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
2137 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
2138 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
2139 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
2140 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink
2141 28cf319f 2021-01-28 stsp run_test test_commit_prepared_logmsg
2142 72840534 2022-01-19 stsp run_test test_commit_large_file
2143 4ba2e955 2022-09-02 sh+got run_test test_commit_gitignore
2144 21f07726 2022-10-31 stsp run_test test_commit_bad_author
2145 def2bea2 2023-01-30 mark run_test test_commit_logmsg_ref
2146 2b706956 2023-04-17 stsp run_test test_commit_from_different_worktrees