Blame


1 c4296144 2019-05-09 stsp #!/bin/sh
2 c4296144 2019-05-09 stsp #
3 c4296144 2019-05-09 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 c4296144 2019-05-09 stsp #
5 c4296144 2019-05-09 stsp # Permission to use, copy, modify, and distribute this software for any
6 c4296144 2019-05-09 stsp # purpose with or without fee is hereby granted, provided that the above
7 c4296144 2019-05-09 stsp # copyright notice and this permission notice appear in all copies.
8 c4296144 2019-05-09 stsp #
9 c4296144 2019-05-09 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c4296144 2019-05-09 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c4296144 2019-05-09 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c4296144 2019-05-09 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c4296144 2019-05-09 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c4296144 2019-05-09 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c4296144 2019-05-09 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 c4296144 2019-05-09 stsp
17 c4296144 2019-05-09 stsp . ./common.sh
18 c4296144 2019-05-09 stsp
19 f6cae3ed 2020-09-13 naddy test_commit_basic() {
20 c4296144 2019-05-09 stsp local testroot=`test_init commit_basic`
21 c4296144 2019-05-09 stsp
22 c4296144 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 fc414659 2022-04-16 thomas ret=$?
24 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
25 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
26 c4296144 2019-05-09 stsp return 1
27 c4296144 2019-05-09 stsp fi
28 c4296144 2019-05-09 stsp
29 c4296144 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
30 c4296144 2019-05-09 stsp (cd $testroot/wt && got rm beta >/dev/null)
31 c4296144 2019-05-09 stsp echo "new file" > $testroot/wt/new
32 c4296144 2019-05-09 stsp (cd $testroot/wt && got add new >/dev/null)
33 c4296144 2019-05-09 stsp
34 83a7ae6d 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_basic' > $testroot/stdout)
35 c4296144 2019-05-09 stsp
36 c4296144 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
37 afa376bf 2019-05-09 stsp echo "A new" > $testroot/stdout.expected
38 afa376bf 2019-05-09 stsp echo "M alpha" >> $testroot/stdout.expected
39 afa376bf 2019-05-09 stsp echo "D beta" >> $testroot/stdout.expected
40 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
41 c4296144 2019-05-09 stsp
42 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
43 fc414659 2022-04-16 thomas ret=$?
44 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
45 c4296144 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
46 c4296144 2019-05-09 stsp fi
47 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
48 c4296144 2019-05-09 stsp }
49 c4296144 2019-05-09 stsp
50 f6cae3ed 2020-09-13 naddy test_commit_new_subdir() {
51 baa7dcfa 2019-05-09 stsp local testroot=`test_init commit_new_subdir`
52 baa7dcfa 2019-05-09 stsp
53 baa7dcfa 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
54 fc414659 2022-04-16 thomas ret=$?
55 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
56 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
57 baa7dcfa 2019-05-09 stsp return 1
58 baa7dcfa 2019-05-09 stsp fi
59 baa7dcfa 2019-05-09 stsp
60 baa7dcfa 2019-05-09 stsp mkdir -p $testroot/wt/d
61 baa7dcfa 2019-05-09 stsp echo "new file" > $testroot/wt/d/new
62 baa7dcfa 2019-05-09 stsp echo "another new file" > $testroot/wt/d/new2
63 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new >/dev/null)
64 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new2 >/dev/null)
65 baa7dcfa 2019-05-09 stsp
66 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && \
67 baa7dcfa 2019-05-09 stsp got commit -m 'test commit_new_subdir' > $testroot/stdout)
68 baa7dcfa 2019-05-09 stsp
69 baa7dcfa 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
70 baa7dcfa 2019-05-09 stsp echo "A d/new" > $testroot/stdout.expected
71 baa7dcfa 2019-05-09 stsp echo "A d/new2" >> $testroot/stdout.expected
72 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
73 baa7dcfa 2019-05-09 stsp
74 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
75 fc414659 2022-04-16 thomas ret=$?
76 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
77 baa7dcfa 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
78 baa7dcfa 2019-05-09 stsp fi
79 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
80 baa7dcfa 2019-05-09 stsp }
81 baa7dcfa 2019-05-09 stsp
82 f6cae3ed 2020-09-13 naddy test_commit_subdir() {
83 bc70eb79 2019-05-09 stsp local testroot=`test_init commit_subdir`
84 bc70eb79 2019-05-09 stsp
85 bc70eb79 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
86 fc414659 2022-04-16 thomas ret=$?
87 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
88 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
89 bc70eb79 2019-05-09 stsp return 1
90 bc70eb79 2019-05-09 stsp fi
91 bc70eb79 2019-05-09 stsp
92 bc70eb79 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
93 bc70eb79 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
94 bc70eb79 2019-05-09 stsp
95 bc70eb79 2019-05-09 stsp (cd $testroot/wt && \
96 bc70eb79 2019-05-09 stsp got commit -m 'test commit_subdir' epsilon > $testroot/stdout)
97 bc70eb79 2019-05-09 stsp
98 bc70eb79 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
99 bc70eb79 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
100 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
101 bc70eb79 2019-05-09 stsp
102 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
103 fc414659 2022-04-16 thomas ret=$?
104 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
105 bc70eb79 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
106 bc70eb79 2019-05-09 stsp fi
107 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
108 bc70eb79 2019-05-09 stsp }
109 bc70eb79 2019-05-09 stsp
110 f6cae3ed 2020-09-13 naddy test_commit_single_file() {
111 5bbcb68b 2019-05-09 stsp local testroot=`test_init commit_single_file`
112 5bbcb68b 2019-05-09 stsp
113 5bbcb68b 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
114 fc414659 2022-04-16 thomas ret=$?
115 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
116 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
117 5bbcb68b 2019-05-09 stsp return 1
118 5bbcb68b 2019-05-09 stsp fi
119 5bbcb68b 2019-05-09 stsp
120 5bbcb68b 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
121 5bbcb68b 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
122 5bbcb68b 2019-05-09 stsp
123 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon/zeta \
124 5bbcb68b 2019-05-09 stsp > $testroot/stdout)
125 5bbcb68b 2019-05-09 stsp
126 5bbcb68b 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
127 5bbcb68b 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
128 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
129 5bbcb68b 2019-05-09 stsp
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
131 fc414659 2022-04-16 thomas ret=$?
132 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
133 5bbcb68b 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
134 5bbcb68b 2019-05-09 stsp fi
135 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
136 5bbcb68b 2019-05-09 stsp }
137 5bbcb68b 2019-05-09 stsp
138 f6cae3ed 2020-09-13 naddy test_commit_out_of_date() {
139 819f385b 2019-05-10 stsp local testroot=`test_init commit_out_of_date`
140 f0b75401 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
141 819f385b 2019-05-10 stsp
142 819f385b 2019-05-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 fc414659 2022-04-16 thomas ret=$?
144 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
145 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
146 819f385b 2019-05-10 stsp return 1
147 819f385b 2019-05-10 stsp fi
148 819f385b 2019-05-10 stsp
149 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/repo/alpha
150 819f385b 2019-05-10 stsp git_commit $testroot/repo -m "modified alpha"
151 819f385b 2019-05-10 stsp
152 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/wt/alpha
153 819f385b 2019-05-10 stsp
154 819f385b 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_out_of_date' \
155 819f385b 2019-05-10 stsp > $testroot/stdout 2> $testroot/stderr)
156 819f385b 2019-05-10 stsp
157 819f385b 2019-05-10 stsp echo -n > $testroot/stdout.expected
158 819f385b 2019-05-10 stsp echo "got: work tree must be updated before these" \
159 819f385b 2019-05-10 stsp "changes can be committed" > $testroot/stderr.expected
160 819f385b 2019-05-10 stsp
161 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
162 fc414659 2022-04-16 thomas ret=$?
163 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
164 819f385b 2019-05-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
165 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
166 819f385b 2019-05-10 stsp return 1
167 819f385b 2019-05-10 stsp fi
168 819f385b 2019-05-10 stsp
169 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
170 fc414659 2022-04-16 thomas ret=$?
171 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
172 819f385b 2019-05-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
173 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
174 f0b75401 2019-08-03 stsp return 1
175 819f385b 2019-05-10 stsp fi
176 f0b75401 2019-08-03 stsp
177 f0b75401 2019-08-03 stsp echo "alpha" > $testroot/repo/alpha
178 f0b75401 2019-08-03 stsp git_commit $testroot/repo -m "reset alpha contents"
179 f0b75401 2019-08-03 stsp (cd $testroot/wt && got update -c $first_commit > /dev/null)
180 f0b75401 2019-08-03 stsp
181 f0b75401 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
182 f0b75401 2019-08-03 stsp
183 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m 'changed alpha ' > $testroot/stdout)
184 fc414659 2022-04-16 thomas ret=$?
185 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
186 f0b75401 2019-08-03 stsp echo "commit failed unexpectedly" >&2
187 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
188 f0b75401 2019-08-03 stsp return 1
189 f0b75401 2019-08-03 stsp fi
190 f0b75401 2019-08-03 stsp
191 f0b75401 2019-08-03 stsp local head_rev=`git_show_head $testroot/repo`
192 f0b75401 2019-08-03 stsp echo "M alpha" > $testroot/stdout.expected
193 f0b75401 2019-08-03 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
194 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
195 fc414659 2022-04-16 thomas ret=$?
196 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
197 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
198 f0b75401 2019-08-03 stsp fi
199 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
200 819f385b 2019-05-10 stsp }
201 819f385b 2019-05-10 stsp
202 f6cae3ed 2020-09-13 naddy test_commit_added_subdirs() {
203 8ba6ba2d 2019-05-14 stsp local testroot=`test_init commit_added_subdirs`
204 8ba6ba2d 2019-05-14 stsp
205 8ba6ba2d 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
206 fc414659 2022-04-16 thomas ret=$?
207 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
208 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
209 8ba6ba2d 2019-05-14 stsp return 1
210 8ba6ba2d 2019-05-14 stsp fi
211 8ba6ba2d 2019-05-14 stsp
212 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d
213 8ba6ba2d 2019-05-14 stsp echo "new file" > $testroot/wt/d/new
214 8ba6ba2d 2019-05-14 stsp echo "new file 2" > $testroot/wt/d/new2
215 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f
216 8ba6ba2d 2019-05-14 stsp echo "new file 3" > $testroot/wt/d/f/new3
217 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f/g
218 8ba6ba2d 2019-05-14 stsp echo "new file 4" > $testroot/wt/d/f/g/new4
219 8ba6ba2d 2019-05-14 stsp
220 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got add $testroot/wt/*/new* \
221 8ba6ba2d 2019-05-14 stsp $testroot/wt/*/*/new* $testroot/wt/*/*/*/new* > /dev/null)
222 8ba6ba2d 2019-05-14 stsp
223 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got commit -m 'test commit_added_subdirs' \
224 8ba6ba2d 2019-05-14 stsp > $testroot/stdout 2> $testroot/stderr)
225 8ba6ba2d 2019-05-14 stsp
226 8ba6ba2d 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
227 a3df2849 2019-05-20 stsp echo "A d/f/g/new4" > $testroot/stdout.expected
228 a3df2849 2019-05-20 stsp echo "A d/f/new3" >> $testroot/stdout.expected
229 8ba6ba2d 2019-05-14 stsp echo "A d/new" >> $testroot/stdout.expected
230 8ba6ba2d 2019-05-14 stsp echo "A d/new2" >> $testroot/stdout.expected
231 ba580f68 2020-03-22 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
232 ba580f68 2020-03-22 stsp
233 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
234 fc414659 2022-04-16 thomas ret=$?
235 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
236 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
237 ba580f68 2020-03-22 stsp fi
238 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
239 ba580f68 2020-03-22 stsp }
240 ba580f68 2020-03-22 stsp
241 f6cae3ed 2020-09-13 naddy test_commit_deleted_subdirs() {
242 ba580f68 2020-03-22 stsp local testroot=`test_init commit_deleted_subdirs`
243 ba580f68 2020-03-22 stsp
244 ba580f68 2020-03-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
245 fc414659 2022-04-16 thomas ret=$?
246 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
247 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
248 ba580f68 2020-03-22 stsp return 1
249 ba580f68 2020-03-22 stsp fi
250 ba580f68 2020-03-22 stsp
251 c8c7d149 2020-09-17 naddy (cd $testroot/wt && \
252 c8c7d149 2020-09-17 naddy got rm -R $testroot/wt/epsilon $testroot/wt/gamma >/dev/null)
253 ba580f68 2020-03-22 stsp
254 ba580f68 2020-03-22 stsp (cd $testroot/wt && got commit -m 'test commit_deleted_subdirs' \
255 ba580f68 2020-03-22 stsp > $testroot/stdout 2> $testroot/stderr)
256 ba580f68 2020-03-22 stsp
257 ba580f68 2020-03-22 stsp local head_rev=`git_show_head $testroot/repo`
258 ba580f68 2020-03-22 stsp echo "D epsilon/zeta" > $testroot/stdout.expected
259 ba580f68 2020-03-22 stsp echo "D gamma/delta" >> $testroot/stdout.expected
260 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
261 ba580f68 2020-03-22 stsp
262 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
263 fc414659 2022-04-16 thomas ret=$?
264 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
265 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
267 ba580f68 2020-03-22 stsp return 1
268 ba580f68 2020-03-22 stsp fi
269 8ba6ba2d 2019-05-14 stsp
270 ba580f68 2020-03-22 stsp got tree -r $testroot/repo > $testroot/stdout
271 ba580f68 2020-03-22 stsp
272 ba580f68 2020-03-22 stsp echo "alpha" > $testroot/stdout.expected
273 ba580f68 2020-03-22 stsp echo "beta" >> $testroot/stdout.expected
274 ba580f68 2020-03-22 stsp
275 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
276 fc414659 2022-04-16 thomas ret=$?
277 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
278 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
279 8ba6ba2d 2019-05-14 stsp fi
280 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
281 8ba6ba2d 2019-05-14 stsp }
282 8ba6ba2d 2019-05-14 stsp
283 f6cae3ed 2020-09-13 naddy test_commit_rejects_conflicted_file() {
284 461aee03 2019-06-29 stsp local testroot=`test_init commit_rejects_conflicted_file`
285 f363d663 2019-05-23 stsp
286 f363d663 2019-05-23 stsp local initial_rev=`git_show_head $testroot/repo`
287 f363d663 2019-05-23 stsp
288 f363d663 2019-05-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
289 fc414659 2022-04-16 thomas ret=$?
290 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
291 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
292 f363d663 2019-05-23 stsp return 1
293 f363d663 2019-05-23 stsp fi
294 f363d663 2019-05-23 stsp
295 f363d663 2019-05-23 stsp echo "modified alpha" > $testroot/wt/alpha
296 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
297 be94c032 2023-02-20 thomas 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 fc414659 2022-04-16 thomas ret=$?
313 fc414659 2022-04-16 thomas 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 be94c032 2023-02-20 thomas ret=$?
322 be94c032 2023-02-20 thomas if [ $ret -eq 0 ]; then
323 be94c032 2023-02-20 thomas echo "got commit succeeded unexpectedly"
324 0b477035 2023-06-22 thomas test_done "$testroot" "1"
325 be94c032 2023-02-20 thomas return 1
326 be94c032 2023-02-20 thomas fi
327 f363d663 2019-05-23 stsp
328 be94c032 2023-02-20 thomas 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 fc414659 2022-04-16 thomas ret=$?
334 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
335 f363d663 2019-05-23 stsp diff -u $testroot/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 fc414659 2022-04-16 thomas ret=$?
341 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
342 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
343 be94c032 2023-02-20 thomas test_done "$testroot" "$ret"
344 be94c032 2023-02-20 thomas return 1
345 be94c032 2023-02-20 thomas fi
346 be94c032 2023-02-20 thomas
347 be94c032 2023-02-20 thomas (cd $testroot/wt && got commit -C -m 'commit it' > $testroot/stdout \
348 be94c032 2023-02-20 thomas 2> $testroot/stderr)
349 be94c032 2023-02-20 thomas ret=$?
350 be94c032 2023-02-20 thomas if [ $ret -ne 0 ]; then
351 be94c032 2023-02-20 thomas echo "got commit failed unexpectedly"
352 be94c032 2023-02-20 thomas test_done "$testroot" "$ret"
353 be94c032 2023-02-20 thomas return 1
354 be94c032 2023-02-20 thomas fi
355 be94c032 2023-02-20 thomas
356 be94c032 2023-02-20 thomas # make sure the conflicted commit produces a diff
357 be94c032 2023-02-20 thomas local conflict_commit=`git_show_head $testroot/repo`
358 be94c032 2023-02-20 thomas local blob_minus=`got tree -r $testroot/repo -c $commit_id1 -i | \
359 be94c032 2023-02-20 thomas grep 'alpha$' | cut -d' ' -f1`
360 be94c032 2023-02-20 thomas local blob_plus=`got tree -r $testroot/repo -c $conflict_commit -i | \
361 be94c032 2023-02-20 thomas grep 'alpha$' | cut -d' ' -f1`
362 be94c032 2023-02-20 thomas
363 be94c032 2023-02-20 thomas echo -n > $testroot/stderr.expected
364 be94c032 2023-02-20 thomas cmp -s $testroot/stderr.expected $testroot/stderr
365 be94c032 2023-02-20 thomas ret=$?
366 be94c032 2023-02-20 thomas if [ $ret -ne 0 ]; then
367 be94c032 2023-02-20 thomas diff -u $testroot/stderr.expected $testroot/stderr
368 be94c032 2023-02-20 thomas test_done "$testroot" "$ret"
369 be94c032 2023-02-20 thomas return 1
370 be94c032 2023-02-20 thomas fi
371 be94c032 2023-02-20 thomas
372 be94c032 2023-02-20 thomas (cd $testroot/wt && got diff -c master > $testroot/stdout)
373 be94c032 2023-02-20 thomas
374 be94c032 2023-02-20 thomas echo -n > $testroot/stdout.expected
375 be94c032 2023-02-20 thomas cat > $testroot/stdout.expected <<EOF
376 be94c032 2023-02-20 thomas diff $commit_id1 refs/heads/master
377 be94c032 2023-02-20 thomas commit - $commit_id1
378 be94c032 2023-02-20 thomas commit + $conflict_commit
379 be94c032 2023-02-20 thomas blob - $blob_minus
380 be94c032 2023-02-20 thomas blob + $blob_plus
381 be94c032 2023-02-20 thomas --- alpha
382 be94c032 2023-02-20 thomas +++ alpha
383 be94c032 2023-02-20 thomas @@ -1 +1,7 @@
384 be94c032 2023-02-20 thomas +<<<<<<< merged change: commit $commit_id1
385 be94c032 2023-02-20 thomas modified alpha
386 be94c032 2023-02-20 thomas +||||||| 3-way merge base: commit $initial_rev
387 be94c032 2023-02-20 thomas +alpha
388 be94c032 2023-02-20 thomas +=======
389 be94c032 2023-02-20 thomas +modified alpha, too
390 be94c032 2023-02-20 thomas +>>>>>>>
391 be94c032 2023-02-20 thomas EOF
392 be94c032 2023-02-20 thomas
393 be94c032 2023-02-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
394 be94c032 2023-02-20 thomas ret=$?
395 be94c032 2023-02-20 thomas if [ $ret -ne 0 ]; then
396 be94c032 2023-02-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
397 be94c032 2023-02-20 thomas test_done "$testroot" "$ret"
398 be94c032 2023-02-20 thomas return 1
399 f363d663 2019-05-23 stsp fi
400 be94c032 2023-02-20 thomas
401 be94c032 2023-02-20 thomas (cd $testroot/wt && got status > $testroot/stdout)
402 be94c032 2023-02-20 thomas
403 be94c032 2023-02-20 thomas echo -n > $testroot/stdout.expected
404 be94c032 2023-02-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
405 be94c032 2023-02-20 thomas ret=$?
406 be94c032 2023-02-20 thomas if [ $ret -ne 0 ]; then
407 be94c032 2023-02-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
408 be94c032 2023-02-20 thomas 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 fc414659 2022-04-16 thomas ret=$?
417 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
434 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
449 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
469 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
481 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
496 fc414659 2022-04-16 thomas 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 9b4458b4 2022-06-26 thomas echo "commit - $commit1" >> $testroot/stdout.expected
504 9b4458b4 2022-06-26 thomas 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 fc414659 2022-04-16 thomas ret=$?
520 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
540 fc414659 2022-04-16 thomas 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 9b4458b4 2022-06-26 thomas echo "commit - $commit2" >> $testroot/stdout.expected
548 9b4458b4 2022-06-26 thomas 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 fc414659 2022-04-16 thomas ret=$?
571 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
583 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
600 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
610 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
621 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
636 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
645 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
662 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
676 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
686 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
695 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
707 fc414659 2022-04-16 thomas 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 ec9b5f0b 2022-07-19 thomas local errmsg=""
716 ec9b5f0b 2022-07-19 thomas
717 ec9b5f0b 2022-07-19 thomas errmsg="commit author's email address is required for"
718 ec9b5f0b 2022-07-19 thomas 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 fc414659 2022-04-16 thomas ret=$?
722 fc414659 2022-04-16 thomas 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 ec9b5f0b 2022-07-19 thomas printf "got: :flan_hacker:: %s\n" "$errmsg" > $testroot/stderr.expected
733 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
734 fc414659 2022-04-16 thomas ret=$?
735 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
744 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
745 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
746 ec9b5f0b 2022-07-19 thomas test_done "$testroot" $ret
747 ec9b5f0b 2022-07-19 thomas return 1
748 84792843 2019-08-09 stsp fi
749 ec9b5f0b 2022-07-19 thomas
750 ec9b5f0b 2022-07-19 thomas # try again with a newline inside the email
751 ec9b5f0b 2022-07-19 thomas (cd $testroot/wt \
752 ec9b5f0b 2022-07-19 thomas && FS=' ' env GOT_AUTHOR="$(printf "Flan <hack\ner>")" \
753 ec9b5f0b 2022-07-19 thomas got commit -m 'test invalid email' > $testroot/stdout \
754 ec9b5f0b 2022-07-19 thomas 2> $testroot/stderr)
755 ec9b5f0b 2022-07-19 thomas
756 ec9b5f0b 2022-07-19 thomas printf "got: Flan <hack\ner>: %s\n" "$errmsg" \
757 ec9b5f0b 2022-07-19 thomas > $testroot/stderr.expected
758 ec9b5f0b 2022-07-19 thomas cmp -s $testroot/stderr.expected $testroot/stderr
759 ec9b5f0b 2022-07-19 thomas ret=$?
760 ec9b5f0b 2022-07-19 thomas if [ $ret -ne 0 ]; then
761 ec9b5f0b 2022-07-19 thomas diff -u $testroot/stderr.expected $testroot/stderr
762 ec9b5f0b 2022-07-19 thomas test_done "$testroot" $ret
763 ec9b5f0b 2022-07-19 thomas return 1
764 ec9b5f0b 2022-07-19 thomas fi
765 ec9b5f0b 2022-07-19 thomas
766 ec9b5f0b 2022-07-19 thomas echo -n > $testroot/stdout.expected
767 ec9b5f0b 2022-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
768 ec9b5f0b 2022-07-19 thomas ret=$?
769 ec9b5f0b 2022-07-19 thomas if [ $ret -ne 0 ]; then
770 ec9b5f0b 2022-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
771 ec9b5f0b 2022-07-19 thomas test_done "$testroot" $ret
772 ec9b5f0b 2022-07-19 thomas return 1
773 ec9b5f0b 2022-07-19 thomas fi
774 ec9b5f0b 2022-07-19 thomas
775 ec9b5f0b 2022-07-19 thomas # try again with a < inside the email
776 ec9b5f0b 2022-07-19 thomas (cd $testroot/wt && env GOT_AUTHOR="$(printf "Flan <ha<ker>")" \
777 ec9b5f0b 2022-07-19 thomas got commit -m 'test invalid email' > $testroot/stdout \
778 ec9b5f0b 2022-07-19 thomas 2> $testroot/stderr)
779 ec9b5f0b 2022-07-19 thomas
780 ec9b5f0b 2022-07-19 thomas printf "got: Flan <ha<ker>: %s\n" "$errmsg" > $testroot/stderr.expected
781 ec9b5f0b 2022-07-19 thomas cmp -s $testroot/stderr.expected $testroot/stderr
782 ec9b5f0b 2022-07-19 thomas ret=$?
783 ec9b5f0b 2022-07-19 thomas if [ $ret -ne 0 ]; then
784 ec9b5f0b 2022-07-19 thomas diff -u $testroot/stderr.expected $testroot/stderr
785 ec9b5f0b 2022-07-19 thomas test_done "$testroot" $ret
786 ec9b5f0b 2022-07-19 thomas return 1
787 ec9b5f0b 2022-07-19 thomas fi
788 ec9b5f0b 2022-07-19 thomas
789 ec9b5f0b 2022-07-19 thomas echo -n > $testroot/stdout.expected
790 ec9b5f0b 2022-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
791 ec9b5f0b 2022-07-19 thomas ret=$?
792 ec9b5f0b 2022-07-19 thomas if [ $ret -ne 0 ]; then
793 ec9b5f0b 2022-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
794 ec9b5f0b 2022-07-19 thomas fi
795 ec9b5f0b 2022-07-19 thomas 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 fc414659 2022-04-16 thomas ret=$?
803 fc414659 2022-04-16 thomas 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 d1e03b8c 2023-10-08 thomas git -C $testroot/repo fsck --strict \
822 d1e03b8c 2023-10-08 thomas > $testroot/fsck.stdout 2> $testroot/fsck.stderr
823 fc414659 2022-04-16 thomas ret=$?
824 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
825 18d1acad 2022-07-20 thomas }
826 18d1acad 2022-07-20 thomas
827 18d1acad 2022-07-20 thomas test_commit_cmdline_author() {
828 18d1acad 2022-07-20 thomas local testroot=`test_init commit_cmdline_author`
829 18d1acad 2022-07-20 thomas
830 18d1acad 2022-07-20 thomas got checkout $testroot/repo $testroot/wt > /dev/null
831 18d1acad 2022-07-20 thomas ret=$?
832 18d1acad 2022-07-20 thomas if [ $ret -ne 0 ]; then
833 18d1acad 2022-07-20 thomas test_done "$testroot" $ret
834 18d1acad 2022-07-20 thomas return 1
835 18d1acad 2022-07-20 thomas fi
836 18d1acad 2022-07-20 thomas
837 18d1acad 2022-07-20 thomas echo "modified alpha" > $testroot/wt/alpha
838 18d1acad 2022-07-20 thomas
839 18d1acad 2022-07-20 thomas local author="Foo <foo@example.com>"
840 18d1acad 2022-07-20 thomas (cd $testroot/wt && got commit -A "$author" -m 'edit alpha') \
841 18d1acad 2022-07-20 thomas > /dev/null
842 18d1acad 2022-07-20 thomas ret=$?
843 18d1acad 2022-07-20 thomas if [ $ret -ne 0 ]; then
844 18d1acad 2022-07-20 thomas test_done "$testroot" $ret
845 18d1acad 2022-07-20 thomas return 1
846 18d1acad 2022-07-20 thomas fi
847 18d1acad 2022-07-20 thomas
848 18d1acad 2022-07-20 thomas (cd $testroot/repo && got log -l1 | egrep '^(from|via):') \
849 18d1acad 2022-07-20 thomas > $testroot/stdout
850 18d1acad 2022-07-20 thomas ret=$?
851 18d1acad 2022-07-20 thomas if [ $ret -ne 0 ]; then
852 18d1acad 2022-07-20 thomas test_done "$testroot" $ret
853 18d1acad 2022-07-20 thomas return 1
854 18d1acad 2022-07-20 thomas fi
855 18d1acad 2022-07-20 thomas
856 18d1acad 2022-07-20 thomas echo "from: $author" > $testroot/stdout.expected
857 18d1acad 2022-07-20 thomas echo "via: $GOT_AUTHOR" >> $testroot/stdout.expected
858 18d1acad 2022-07-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
859 18d1acad 2022-07-20 thomas ret=$?
860 18d1acad 2022-07-20 thomas if [ $ret -ne 0 ]; then
861 18d1acad 2022-07-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
862 18d1acad 2022-07-20 thomas fi
863 18d1acad 2022-07-20 thomas 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 fc414659 2022-04-16 thomas ret=$?
871 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
881 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
888 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
897 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
908 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
920 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
927 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
936 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
947 fc414659 2022-04-16 thomas 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 d1e03b8c 2023-10-08 thomas git -C $testroot/repo config user.name 'Flan Luck'
953 d1e03b8c 2023-10-08 thomas git -C $testroot/repo 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 1f240092 2022-07-24 thomas
957 1f240092 2022-07-24 thomas # unset in a subshell to avoid affecting our environment
958 1f240092 2022-07-24 thomas (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
959 1f240092 2022-07-24 thomas got commit -m 'test gitconfig author' > /dev/null)
960 fc414659 2022-04-16 thomas ret=$?
961 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
968 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
977 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
978 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
979 40d0d6a4 2023-02-20 thomas test_done "$testroot" "$ret"
980 40d0d6a4 2023-02-20 thomas return 1
981 aba9c984 2019-09-08 stsp fi
982 40d0d6a4 2023-02-20 thomas
983 40d0d6a4 2023-02-20 thomas # retry with spaces in the git config
984 40d0d6a4 2023-02-20 thomas ed -s "$testroot/repo/.git/config" <<EOF
985 2cf27278 2023-02-23 thomas /^\[user/ a
986 2cf27278 2023-02-23 thomas # it's me!
987 2cf27278 2023-02-23 thomas .
988 40d0d6a4 2023-02-20 thomas ,s/ / /g
989 40d0d6a4 2023-02-20 thomas wq
990 40d0d6a4 2023-02-20 thomas EOF
991 40d0d6a4 2023-02-20 thomas echo "modified again" > $testroot/wt/alpha
992 40d0d6a4 2023-02-20 thomas
993 40d0d6a4 2023-02-20 thomas # unset in a subshell to avoid affecting our environment
994 40d0d6a4 2023-02-20 thomas (unset GOT_IGNORE_GITCONFIG && cd "$testroot/wt" && \
995 2cf27278 2023-02-23 thomas got commit -m 'test gitconfig author again' \
996 2cf27278 2023-02-23 thomas >/dev/null 2>$testroot/stderr)
997 2cf27278 2023-02-23 thomas ret=$?
998 2cf27278 2023-02-23 thomas if [ $ret -ne 0 ]; then
999 2cf27278 2023-02-23 thomas test_done "$testroot" "$ret"
1000 2cf27278 2023-02-23 thomas return 1
1001 2cf27278 2023-02-23 thomas fi
1002 2cf27278 2023-02-23 thomas
1003 2cf27278 2023-02-23 thomas # shouldn't have triggered any parsing error
1004 2cf27278 2023-02-23 thomas echo -n > $testroot/stderr.expected
1005 2cf27278 2023-02-23 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1006 40d0d6a4 2023-02-20 thomas ret=$?
1007 40d0d6a4 2023-02-20 thomas if [ $ret -ne 0 ]; then
1008 2cf27278 2023-02-23 thomas diff -u $testroot/stderr.expected $testroot/stderr
1009 40d0d6a4 2023-02-20 thomas test_done "$testroot" "$ret"
1010 40d0d6a4 2023-02-20 thomas return 1
1011 40d0d6a4 2023-02-20 thomas fi
1012 40d0d6a4 2023-02-20 thomas
1013 40d0d6a4 2023-02-20 thomas (cd "$testroot/repo" && got log -l1 | grep ^from: > $testroot/stdout)
1014 40d0d6a4 2023-02-20 thomas ret=$?
1015 40d0d6a4 2023-02-20 thomas if [ $ret -ne 0 ]; then
1016 40d0d6a4 2023-02-20 thomas test_done "$testroot" "$ret"
1017 40d0d6a4 2023-02-20 thomas return 1
1018 40d0d6a4 2023-02-20 thomas fi
1019 40d0d6a4 2023-02-20 thomas
1020 40d0d6a4 2023-02-20 thomas echo "from: Flan Luck <flan_luck@openbsd.org>" \
1021 40d0d6a4 2023-02-20 thomas > $testroot/stdout.expected
1022 40d0d6a4 2023-02-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1023 40d0d6a4 2023-02-20 thomas ret=$?
1024 40d0d6a4 2023-02-20 thomas if [ $ret -ne 0 ]; then
1025 40d0d6a4 2023-02-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
1026 40d0d6a4 2023-02-20 thomas 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 fc414659 2022-04-16 thomas ret=$?
1035 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1047 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1055 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1066 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1077 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1090 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1098 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1109 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1122 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1138 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1149 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1163 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1174 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1183 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1195 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 d1e03b8c 2023-10-08 thomas git -C $testroot/repo -c protocol.file.allow=always \
1212 d1e03b8c 2023-10-08 thomas submodule -q add ../repo2
1213 d1e03b8c 2023-10-08 thomas git -C $testroot/repo 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 fc414659 2022-04-16 thomas ret=$?
1217 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1229 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1241 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1258 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1272 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1286 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1293 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1302 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1311 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1324 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1340 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1341 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1342 0b477035 2023-06-22 thomas test_done "$testroot" "1"
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 fc414659 2022-04-16 thomas ret=$?
1350 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1369 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1378 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1384 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1399 fc414659 2022-04-16 thomas 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 e6f45b72 2023-03-03 thomas (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 fc414659 2022-04-16 thomas ret=$?
1418 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1419 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1420 0b477035 2023-06-22 thomas test_done "$testroot" "1"
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 fc414659 2022-04-16 thomas ret=$?
1428 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1448 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1471 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1482 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1509 fc414659 2022-04-16 thomas 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 e6f45b72 2023-03-03 thomas (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 fc414659 2022-04-16 thomas ret=$?
1527 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1543 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1551 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1567 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1580 fc414659 2022-04-16 thomas 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 8fedfb3c 2023-03-05 thomas # a no-op editor script
1593 8fedfb3c 2023-03-05 thomas > $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 fc414659 2022-04-16 thomas ret=$?
1607 fc414659 2022-04-16 thomas 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 1c72bab5 2023-03-03 thomas 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 fc414659 2022-04-16 thomas ret=$?
1626 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
1646 fc414659 2022-04-16 thomas 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 1c72bab5 2023-03-03 thomas 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 fc414659 2022-04-16 thomas ret=$?
1667 fc414659 2022-04-16 thomas 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 e8f02263 2022-01-23 thomas
1673 e8f02263 2022-01-23 thomas test_commit_large_file() {
1674 e8f02263 2022-01-23 thomas local testroot=`test_init commit_large_file`
1675 e8f02263 2022-01-23 thomas
1676 e8f02263 2022-01-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1677 fc414659 2022-04-16 thomas ret=$?
1678 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1679 e8f02263 2022-01-23 thomas test_done "$testroot" "$ret"
1680 e8f02263 2022-01-23 thomas return 1
1681 e8f02263 2022-01-23 thomas fi
1682 e8f02263 2022-01-23 thomas
1683 b9e845cd 2022-07-06 thomas dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1684 e8f02263 2022-01-23 thomas (cd $testroot/wt && got add new >/dev/null)
1685 28cf319f 2021-01-28 stsp
1686 e8f02263 2022-01-23 thomas (cd $testroot/wt && got commit -m 'test commit_large_file' \
1687 e8f02263 2022-01-23 thomas > $testroot/stdout)
1688 e8f02263 2022-01-23 thomas
1689 e8f02263 2022-01-23 thomas local head_rev=`git_show_head $testroot/repo`
1690 e8f02263 2022-01-23 thomas echo "A new" > $testroot/stdout.expected
1691 e8f02263 2022-01-23 thomas echo "Created commit $head_rev" >> $testroot/stdout.expected
1692 e8f02263 2022-01-23 thomas
1693 e8f02263 2022-01-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1694 fc414659 2022-04-16 thomas ret=$?
1695 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1696 e8f02263 2022-01-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1697 e8f02263 2022-01-23 thomas test_done "$testroot" "$ret"
1698 e8f02263 2022-01-23 thomas return 1
1699 e8f02263 2022-01-23 thomas fi
1700 e8f02263 2022-01-23 thomas
1701 e8f02263 2022-01-23 thomas new_id=`get_blob_id $testroot/repo "" new`
1702 e8f02263 2022-01-23 thomas got cat -r $testroot/repo $new_id > $testroot/new
1703 fc414659 2022-04-16 thomas ret=$?
1704 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1705 e8f02263 2022-01-23 thomas echo "commit failed unexpectedly" >&2
1706 e8f02263 2022-01-23 thomas test_done "$testroot" "1"
1707 e8f02263 2022-01-23 thomas return 1
1708 e8f02263 2022-01-23 thomas fi
1709 e8f02263 2022-01-23 thomas
1710 e8f02263 2022-01-23 thomas cmp -s $testroot/new $testroot/wt/new
1711 fc414659 2022-04-16 thomas ret=$?
1712 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1713 e8f02263 2022-01-23 thomas diff -u $testroot/new $testroot/wt/new
1714 e8f02263 2022-01-23 thomas fi
1715 e8f02263 2022-01-23 thomas test_done "$testroot" "$ret"
1716 43896ae6 2022-09-02 thomas
1717 43896ae6 2022-09-02 thomas
1718 43896ae6 2022-09-02 thomas }
1719 43896ae6 2022-09-02 thomas
1720 43896ae6 2022-09-02 thomas test_commit_gitignore() {
1721 43896ae6 2022-09-02 thomas local testroot=`test_init commit_gitignores`
1722 43896ae6 2022-09-02 thomas
1723 43896ae6 2022-09-02 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1724 43896ae6 2022-09-02 thomas ret=$?
1725 43896ae6 2022-09-02 thomas if [ $ret -ne 0 ]; then
1726 43896ae6 2022-09-02 thomas test_done "$testroot" "$ret"
1727 43896ae6 2022-09-02 thomas return 1
1728 43896ae6 2022-09-02 thomas fi
1729 43896ae6 2022-09-02 thomas
1730 43896ae6 2022-09-02 thomas mkdir -p $testroot/wt/tree1/foo
1731 43896ae6 2022-09-02 thomas mkdir -p $testroot/wt/tree2/foo
1732 43896ae6 2022-09-02 thomas echo "tree1/**" > $testroot/wt/.gitignore
1733 43896ae6 2022-09-02 thomas echo "tree2/**" >> $testroot/wt/.gitignore
1734 43896ae6 2022-09-02 thomas echo -n > $testroot/wt/tree1/bar
1735 43896ae6 2022-09-02 thomas echo -n > $testroot/wt/tree1/foo/baz
1736 43896ae6 2022-09-02 thomas echo -n > $testroot/wt/tree2/bar
1737 43896ae6 2022-09-02 thomas echo -n > $testroot/wt/tree2/foo/baz
1738 43896ae6 2022-09-02 thomas echo -n > $testroot/wt/epsilon/zeta1
1739 43896ae6 2022-09-02 thomas echo -n > $testroot/wt/epsilon/zeta2
1740 43896ae6 2022-09-02 thomas
1741 43896ae6 2022-09-02 thomas (cd $testroot/wt && got add -I -R tree1 > /dev/null)
1742 43896ae6 2022-09-02 thomas (cd $testroot/wt && got add -I tree2/foo/baz > /dev/null)
1743 43896ae6 2022-09-02 thomas (cd $testroot/wt && got commit -m "gitignore add" > /dev/null)
1744 43896ae6 2022-09-02 thomas (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1745 43896ae6 2022-09-02 thomas
1746 43896ae6 2022-09-02 thomas echo ' gitignore add' > $testroot/stdout.expected
1747 43896ae6 2022-09-02 thomas echo ' A tree1/bar' >> $testroot/stdout.expected
1748 43896ae6 2022-09-02 thomas echo ' A tree1/foo/baz' >> $testroot/stdout.expected
1749 43896ae6 2022-09-02 thomas echo ' A tree2/foo/baz' >> $testroot/stdout.expected
1750 e8f02263 2022-01-23 thomas
1751 43896ae6 2022-09-02 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1752 43896ae6 2022-09-02 thomas ret=$?
1753 43896ae6 2022-09-02 thomas if [ $ret -ne 0 ]; then
1754 43896ae6 2022-09-02 thomas diff -u $testroot/stdout.expected $testroot/stdout
1755 43896ae6 2022-09-02 thomas test_done "$testroot" "$ret"
1756 43896ae6 2022-09-02 thomas return 1
1757 43896ae6 2022-09-02 thomas fi
1758 e8f02263 2022-01-23 thomas
1759 43896ae6 2022-09-02 thomas echo touch > $testroot/wt/tree1/bar
1760 43896ae6 2022-09-02 thomas echo touch > $testroot/wt/tree1/foo/baz
1761 43896ae6 2022-09-02 thomas echo touch > $testroot/wt/epsilon/zeta1
1762 43896ae6 2022-09-02 thomas
1763 43896ae6 2022-09-02 thomas (cd $testroot/wt && got commit -m "gitignore change" > /dev/null)
1764 43896ae6 2022-09-02 thomas (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1765 43896ae6 2022-09-02 thomas
1766 43896ae6 2022-09-02 thomas echo ' gitignore change' > $testroot/stdout.expected
1767 43896ae6 2022-09-02 thomas echo ' M tree1/bar' >> $testroot/stdout.expected
1768 43896ae6 2022-09-02 thomas echo ' M tree1/foo/baz' >> $testroot/stdout.expected
1769 43896ae6 2022-09-02 thomas
1770 43896ae6 2022-09-02 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1771 43896ae6 2022-09-02 thomas ret=$?
1772 43896ae6 2022-09-02 thomas if [ $ret -ne 0 ]; then
1773 43896ae6 2022-09-02 thomas diff -u $testroot/stdout.expected $testroot/stdout
1774 43896ae6 2022-09-02 thomas test_done "$testroot" "$ret"
1775 43896ae6 2022-09-02 thomas return 1
1776 43896ae6 2022-09-02 thomas fi
1777 43896ae6 2022-09-02 thomas
1778 43896ae6 2022-09-02 thomas test_done "$testroot" "$ret"
1779 e8f02263 2022-01-23 thomas }
1780 3d47d5be 2022-10-31 thomas
1781 3d47d5be 2022-10-31 thomas test_commit_bad_author() {
1782 3d47d5be 2022-10-31 thomas local testroot=`test_init commit_bad_author`
1783 3d47d5be 2022-10-31 thomas
1784 3d47d5be 2022-10-31 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1785 3d47d5be 2022-10-31 thomas ret=$?
1786 3d47d5be 2022-10-31 thomas if [ $ret -ne 0 ]; then
1787 3d47d5be 2022-10-31 thomas test_done "$testroot" $ret
1788 3d47d5be 2022-10-31 thomas return 1
1789 3d47d5be 2022-10-31 thomas fi
1790 3d47d5be 2022-10-31 thomas
1791 3d47d5be 2022-10-31 thomas echo "modified alpha" > $testroot/wt/alpha
1792 3d47d5be 2022-10-31 thomas
1793 3d47d5be 2022-10-31 thomas (cd $testroot/wt && got commit \
1794 3d47d5be 2022-10-31 thomas -A "${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>" -m 'edit alpha') \
1795 3d47d5be 2022-10-31 thomas > /dev/null 2> $testroot/stderr
1796 3d47d5be 2022-10-31 thomas ret=$?
1797 3d47d5be 2022-10-31 thomas if [ $ret -eq 0 ]; then
1798 3d47d5be 2022-10-31 thomas test_done "$testroot" 1
1799 3d47d5be 2022-10-31 thomas return 1
1800 3d47d5be 2022-10-31 thomas fi
1801 e8f02263 2022-01-23 thomas
1802 3d47d5be 2022-10-31 thomas echo -n "got: ${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>: " \
1803 3d47d5be 2022-10-31 thomas > $testroot/stderr.expected
1804 3d47d5be 2022-10-31 thomas echo -n 'space between author name and email required: ' \
1805 3d47d5be 2022-10-31 thomas >> $testroot/stderr.expected
1806 3d47d5be 2022-10-31 thomas echo 'commit author formatting would make Git unhappy' \
1807 3d47d5be 2022-10-31 thomas >> $testroot/stderr.expected
1808 3d47d5be 2022-10-31 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1809 3d47d5be 2022-10-31 thomas ret=$?
1810 3d47d5be 2022-10-31 thomas if [ $ret -ne 0 ]; then
1811 3d47d5be 2022-10-31 thomas diff -u $testroot/stderr.expected $testroot/stderr
1812 3d47d5be 2022-10-31 thomas test_done "$testroot" $ret
1813 3d47d5be 2022-10-31 thomas return 1
1814 3d47d5be 2022-10-31 thomas fi
1815 e8f02263 2022-01-23 thomas
1816 3d47d5be 2022-10-31 thomas test_done "$testroot" 0
1817 3d47d5be 2022-10-31 thomas }
1818 3f4f8b5a 2023-01-31 thomas
1819 3f4f8b5a 2023-01-31 thomas test_commit_logmsg_ref() {
1820 3f4f8b5a 2023-01-31 thomas local testroot=`test_init commit_logmsg_ref`
1821 3f4f8b5a 2023-01-31 thomas
1822 3f4f8b5a 2023-01-31 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1823 3f4f8b5a 2023-01-31 thomas ret=$?
1824 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
1825 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
1826 3f4f8b5a 2023-01-31 thomas return 1
1827 3f4f8b5a 2023-01-31 thomas fi
1828 3f4f8b5a 2023-01-31 thomas
1829 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q -b newbranch
1830 3f4f8b5a 2023-01-31 thomas
1831 3f4f8b5a 2023-01-31 thomas local bo_logmsg_prefix="log message of backed-out commit"
1832 3f4f8b5a 2023-01-31 thomas local cy_logmsg_prefix="log message of cherrypicked commit"
1833 3f4f8b5a 2023-01-31 thomas local branch_rev_logmsg="changes on newbranch to cherrypick"
1834 3f4f8b5a 2023-01-31 thomas local branch_rev2_logmsg="modified zeta on newbranch to cherrypick"
1835 3f4f8b5a 2023-01-31 thomas
1836 3f4f8b5a 2023-01-31 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
1837 3f4f8b5a 2023-01-31 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1838 d1e03b8c 2023-10-08 thomas git -C $testroot/repo rm -q beta
1839 3f4f8b5a 2023-01-31 thomas echo "new file on branch" > $testroot/repo/epsilon/new
1840 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add epsilon/new
1841 3f4f8b5a 2023-01-31 thomas
1842 3f4f8b5a 2023-01-31 thomas git_commit $testroot/repo -m "$branch_rev_logmsg"
1843 3f4f8b5a 2023-01-31 thomas local branch_rev=`git_show_head $testroot/repo`
1844 3f4f8b5a 2023-01-31 thomas
1845 3f4f8b5a 2023-01-31 thomas echo "modified zeta on branch" > $testroot/repo/epsilon/zeta
1846 3f4f8b5a 2023-01-31 thomas
1847 3f4f8b5a 2023-01-31 thomas git_commit $testroot/repo -m "$branch_rev2_logmsg"
1848 3f4f8b5a 2023-01-31 thomas local branch_rev2=`git_show_head $testroot/repo`
1849 3f4f8b5a 2023-01-31 thomas
1850 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1851 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got cherrypick $branch_rev2 > /dev/null)
1852 3d47d5be 2022-10-31 thomas
1853 3f4f8b5a 2023-01-31 thomas cat > $testroot/editor.sh <<EOF
1854 3f4f8b5a 2023-01-31 thomas #!/bin/sh
1855 ac3cdf31 2023-03-06 thomas ed -s "\$1" <<-EOF
1856 ac3cdf31 2023-03-06 thomas ,s/# l/l/
1857 ac3cdf31 2023-03-06 thomas w
1858 ac3cdf31 2023-03-06 thomas EOF
1859 3f4f8b5a 2023-01-31 thomas EOF
1860 3f4f8b5a 2023-01-31 thomas chmod +x $testroot/editor.sh
1861 3f4f8b5a 2023-01-31 thomas
1862 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1863 3f4f8b5a 2023-01-31 thomas got commit > /dev/null)
1864 3f4f8b5a 2023-01-31 thomas ret=$?
1865 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
1866 3f4f8b5a 2023-01-31 thomas echo "'got commit' failed unexpectedly" >&2
1867 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "1"
1868 3f4f8b5a 2023-01-31 thomas return 1
1869 3f4f8b5a 2023-01-31 thomas fi
1870 3f4f8b5a 2023-01-31 thomas
1871 3f4f8b5a 2023-01-31 thomas # check that multiple cherrypicked log messages populate the editor
1872 3f4f8b5a 2023-01-31 thomas local first=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | head -1`
1873 3f4f8b5a 2023-01-31 thomas local second=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | tail -1`
1874 3f4f8b5a 2023-01-31 thomas
1875 8d6e02ca 2023-03-03 thomas if [ $branch_rev = $first ]; then
1876 3f4f8b5a 2023-01-31 thomas local first_msg=$branch_rev_logmsg
1877 3f4f8b5a 2023-01-31 thomas local second_msg=$branch_rev2_logmsg
1878 3f4f8b5a 2023-01-31 thomas else
1879 3f4f8b5a 2023-01-31 thomas local first_msg=$branch_rev2_logmsg
1880 3f4f8b5a 2023-01-31 thomas local second_msg=$branch_rev_logmsg
1881 3f4f8b5a 2023-01-31 thomas fi
1882 3f4f8b5a 2023-01-31 thomas
1883 3f4f8b5a 2023-01-31 thomas echo " $cy_logmsg_prefix $first:" > $testroot/stdout.expected
1884 3f4f8b5a 2023-01-31 thomas echo " $first_msg" >> $testroot/stdout.expected
1885 3f4f8b5a 2023-01-31 thomas echo " " >> $testroot/stdout.expected
1886 3f4f8b5a 2023-01-31 thomas echo " $cy_logmsg_prefix $second:" >> $testroot/stdout.expected
1887 3f4f8b5a 2023-01-31 thomas echo " $second_msg" >> $testroot/stdout.expected
1888 3f4f8b5a 2023-01-31 thomas echo " " >> $testroot/stdout.expected
1889 3f4f8b5a 2023-01-31 thomas
1890 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got log -l2 | \
1891 3f4f8b5a 2023-01-31 thomas grep -A2 'log message' | sed '/^--/d' > $testroot/stdout)
1892 3f4f8b5a 2023-01-31 thomas
1893 3f4f8b5a 2023-01-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1894 3f4f8b5a 2023-01-31 thomas ret=$?
1895 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
1896 3f4f8b5a 2023-01-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
1897 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
1898 3f4f8b5a 2023-01-31 thomas return 1
1899 3f4f8b5a 2023-01-31 thomas fi
1900 3f4f8b5a 2023-01-31 thomas
1901 3f4f8b5a 2023-01-31 thomas # check that only the relevant log message populates the editor
1902 3f4f8b5a 2023-01-31 thomas # when the changes from one of two backout commits are reverted
1903 3f4f8b5a 2023-01-31 thomas got checkout $testroot/repo $testroot/wt2 > /dev/null
1904 3f4f8b5a 2023-01-31 thomas ret=$?
1905 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
1906 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
1907 3f4f8b5a 2023-01-31 thomas return 1
1908 3f4f8b5a 2023-01-31 thomas fi
1909 3f4f8b5a 2023-01-31 thomas
1910 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt2 && got backout $branch_rev > /dev/null)
1911 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt2 && got backout $branch_rev2 > /dev/null)
1912 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt2 && got revert epsilon/zeta > /dev/null)
1913 3f4f8b5a 2023-01-31 thomas
1914 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt2 && env VISUAL="$testroot/editor.sh" \
1915 3f4f8b5a 2023-01-31 thomas got commit > /dev/null)
1916 3f4f8b5a 2023-01-31 thomas ret=$?
1917 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
1918 3f4f8b5a 2023-01-31 thomas echo "'got commit' failed unexpectedly" >&2
1919 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "1"
1920 3f4f8b5a 2023-01-31 thomas return 1
1921 3f4f8b5a 2023-01-31 thomas fi
1922 3f4f8b5a 2023-01-31 thomas
1923 3f4f8b5a 2023-01-31 thomas echo " $bo_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1924 3f4f8b5a 2023-01-31 thomas echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1925 3f4f8b5a 2023-01-31 thomas echo " " >> $testroot/stdout.expected
1926 3f4f8b5a 2023-01-31 thomas
1927 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt2 && got log -l1 | \
1928 3f4f8b5a 2023-01-31 thomas grep -A2 'log message' > $testroot/stdout)
1929 3f4f8b5a 2023-01-31 thomas
1930 3f4f8b5a 2023-01-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1931 3f4f8b5a 2023-01-31 thomas ret=$?
1932 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
1933 3f4f8b5a 2023-01-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
1934 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
1935 3f4f8b5a 2023-01-31 thomas return 1
1936 3f4f8b5a 2023-01-31 thomas fi
1937 3f4f8b5a 2023-01-31 thomas
1938 3f4f8b5a 2023-01-31 thomas # check that a cherrypicked log message is still
1939 3f4f8b5a 2023-01-31 thomas # used when its changes are only partially reverted
1940 3f4f8b5a 2023-01-31 thomas branch_rev_logmsg="changes to cherrypick and partially revert"
1941 3f4f8b5a 2023-01-31 thomas
1942 3f4f8b5a 2023-01-31 thomas echo "newline in alpha" >> $testroot/repo/alpha
1943 3f4f8b5a 2023-01-31 thomas echo "modified epsilon/zeta on branch" > $testroot/repo/epsilon/zeta
1944 3f4f8b5a 2023-01-31 thomas
1945 3f4f8b5a 2023-01-31 thomas git_commit $testroot/repo -m "$branch_rev_logmsg"
1946 3f4f8b5a 2023-01-31 thomas branch_rev=`git_show_head $testroot/repo`
1947 3f4f8b5a 2023-01-31 thomas
1948 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1949 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got revert alpha > /dev/null)
1950 3f4f8b5a 2023-01-31 thomas
1951 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1952 3f4f8b5a 2023-01-31 thomas got commit > /dev/null)
1953 3f4f8b5a 2023-01-31 thomas ret=$?
1954 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
1955 3f4f8b5a 2023-01-31 thomas echo "'got commit' failed unexpectedly" >&2
1956 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "1"
1957 3f4f8b5a 2023-01-31 thomas return 1
1958 3f4f8b5a 2023-01-31 thomas fi
1959 3f4f8b5a 2023-01-31 thomas
1960 3f4f8b5a 2023-01-31 thomas echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1961 3f4f8b5a 2023-01-31 thomas echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1962 3f4f8b5a 2023-01-31 thomas echo " " >> $testroot/stdout.expected
1963 3f4f8b5a 2023-01-31 thomas
1964 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got log -l1 | \
1965 3f4f8b5a 2023-01-31 thomas grep -A2 'log message' > $testroot/stdout)
1966 3f4f8b5a 2023-01-31 thomas
1967 3f4f8b5a 2023-01-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1968 3f4f8b5a 2023-01-31 thomas ret=$?
1969 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
1970 3f4f8b5a 2023-01-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
1971 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
1972 3f4f8b5a 2023-01-31 thomas return 1
1973 3f4f8b5a 2023-01-31 thomas fi
1974 3f4f8b5a 2023-01-31 thomas
1975 3f4f8b5a 2023-01-31 thomas # check we don't use and consequently delete the logmsg ref of a
1976 3f4f8b5a 2023-01-31 thomas # cherrypicked commit when omitting its changed path from the commit
1977 3f4f8b5a 2023-01-31 thomas branch_rev_logmsg="changes to cherrypick but omit from the commit"
1978 3f4f8b5a 2023-01-31 thomas
1979 3f4f8b5a 2023-01-31 thomas echo "changed delta" >> $testroot/repo/gamma/delta
1980 3f4f8b5a 2023-01-31 thomas
1981 3f4f8b5a 2023-01-31 thomas git_commit $testroot/repo -m "$branch_rev_logmsg"
1982 3f4f8b5a 2023-01-31 thomas local author_time=`git_show_author_time $testroot/repo`
1983 3f4f8b5a 2023-01-31 thomas local d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1984 3f4f8b5a 2023-01-31 thomas branch_rev=`git_show_head $testroot/repo`
1985 3f4f8b5a 2023-01-31 thomas
1986 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got update > /dev/null)
1987 3f4f8b5a 2023-01-31 thomas ret=$?
1988 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
1989 3f4f8b5a 2023-01-31 thomas echo "got update failed unexpectedly" >&2
1990 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
1991 3f4f8b5a 2023-01-31 thomas return 1
1992 3f4f8b5a 2023-01-31 thomas fi
1993 3f4f8b5a 2023-01-31 thomas
1994 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1995 3f4f8b5a 2023-01-31 thomas
1996 3f4f8b5a 2023-01-31 thomas echo "changed alpha" >> $testroot/wt/alpha
1997 3f4f8b5a 2023-01-31 thomas
1998 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got commit -m \
1999 3f4f8b5a 2023-01-31 thomas "don't commit cy change to gamma/delta" alpha > /dev/null)
2000 3f4f8b5a 2023-01-31 thomas ret=$?
2001 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
2002 3f4f8b5a 2023-01-31 thomas echo "'got commit' failed unexpectedly" >&2
2003 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "1"
2004 3f4f8b5a 2023-01-31 thomas return 1
2005 3f4f8b5a 2023-01-31 thomas fi
2006 3f4f8b5a 2023-01-31 thomas
2007 3f4f8b5a 2023-01-31 thomas # confirm logmsg ref was not deleted with got cherrypick -l
2008 3f4f8b5a 2023-01-31 thomas echo "-----------------------------------------------" \
2009 3f4f8b5a 2023-01-31 thomas > $testroot/stdout.expected
2010 f35e52a9 2023-01-31 thomas echo "cherrypick $branch_rev (newbranch)" >> $testroot/stdout.expected
2011 3f4f8b5a 2023-01-31 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
2012 3f4f8b5a 2023-01-31 thomas echo "date: $d" >> $testroot/stdout.expected
2013 3f4f8b5a 2023-01-31 thomas echo " " >> $testroot/stdout.expected
2014 3f4f8b5a 2023-01-31 thomas echo " $branch_rev_logmsg" >> $testroot/stdout.expected
2015 3f4f8b5a 2023-01-31 thomas echo " " >> $testroot/stdout.expected
2016 3f4f8b5a 2023-01-31 thomas echo " M gamma/delta" >> $testroot/stdout.expected
2017 3f4f8b5a 2023-01-31 thomas echo >> $testroot/stdout.expected
2018 3f4f8b5a 2023-01-31 thomas
2019 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got cherrypick -l > $testroot/stdout)
2020 3f4f8b5a 2023-01-31 thomas
2021 3f4f8b5a 2023-01-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
2022 3f4f8b5a 2023-01-31 thomas ret=$?
2023 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
2024 3f4f8b5a 2023-01-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
2025 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
2026 3f4f8b5a 2023-01-31 thomas return 1
2027 3f4f8b5a 2023-01-31 thomas fi
2028 3f4f8b5a 2023-01-31 thomas
2029 3f4f8b5a 2023-01-31 thomas # confirm a previously unused logmsg ref is picked up
2030 3f4f8b5a 2023-01-31 thomas # when an affected path is actually committed
2031 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
2032 3f4f8b5a 2023-01-31 thomas got commit > /dev/null)
2033 3f4f8b5a 2023-01-31 thomas ret=$?
2034 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
2035 3f4f8b5a 2023-01-31 thomas echo "'got commit' failed unexpectedly" >&2
2036 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "1"
2037 3f4f8b5a 2023-01-31 thomas return 1
2038 3f4f8b5a 2023-01-31 thomas fi
2039 3f4f8b5a 2023-01-31 thomas
2040 3f4f8b5a 2023-01-31 thomas echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
2041 3f4f8b5a 2023-01-31 thomas echo " $branch_rev_logmsg" >> $testroot/stdout.expected
2042 3f4f8b5a 2023-01-31 thomas echo " " >> $testroot/stdout.expected
2043 3f4f8b5a 2023-01-31 thomas
2044 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got log -l1 | \
2045 3f4f8b5a 2023-01-31 thomas grep -A2 'log message' > $testroot/stdout)
2046 3f4f8b5a 2023-01-31 thomas
2047 3f4f8b5a 2023-01-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
2048 3f4f8b5a 2023-01-31 thomas ret=$?
2049 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
2050 3f4f8b5a 2023-01-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
2051 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
2052 3f4f8b5a 2023-01-31 thomas return 1
2053 3f4f8b5a 2023-01-31 thomas fi
2054 3f4f8b5a 2023-01-31 thomas
2055 3f4f8b5a 2023-01-31 thomas # make sure we are not littering work trees
2056 3f4f8b5a 2023-01-31 thomas # by leaving temp got-logmsg-* files behind
2057 3f4f8b5a 2023-01-31 thomas echo -n > $testroot/stdout.expected
2058 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt && got status > $testroot/stdout)
2059 3f4f8b5a 2023-01-31 thomas
2060 3f4f8b5a 2023-01-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
2061 3f4f8b5a 2023-01-31 thomas ret=$?
2062 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
2063 3f4f8b5a 2023-01-31 thomas echo "$testroot/wt is not clean"
2064 3f4f8b5a 2023-01-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
2065 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
2066 3f4f8b5a 2023-01-31 thomas return 1
2067 3f4f8b5a 2023-01-31 thomas fi
2068 3f4f8b5a 2023-01-31 thomas
2069 3f4f8b5a 2023-01-31 thomas (cd $testroot/wt2 && got status > $testroot/stdout)
2070 3f4f8b5a 2023-01-31 thomas
2071 3f4f8b5a 2023-01-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
2072 3f4f8b5a 2023-01-31 thomas ret=$?
2073 3f4f8b5a 2023-01-31 thomas if [ $ret -ne 0 ]; then
2074 3f4f8b5a 2023-01-31 thomas echo "$testroot/repo is not clean"
2075 3f4f8b5a 2023-01-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
2076 3f4f8b5a 2023-01-31 thomas fi
2077 3f4f8b5a 2023-01-31 thomas test_done "$testroot" "$ret"
2078 538aebb5 2023-04-22 thomas }
2079 538aebb5 2023-04-22 thomas
2080 538aebb5 2023-04-22 thomas test_commit_from_different_worktrees() {
2081 538aebb5 2023-04-22 thomas local testroot=$(test_init commit_from_different_worktrees)
2082 538aebb5 2023-04-22 thomas
2083 538aebb5 2023-04-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
2084 538aebb5 2023-04-22 thomas ret=$?
2085 538aebb5 2023-04-22 thomas if [ $ret -ne 0 ]; then
2086 538aebb5 2023-04-22 thomas test_done "$testroot" "$ret"
2087 538aebb5 2023-04-22 thomas return 1
2088 538aebb5 2023-04-22 thomas fi
2089 538aebb5 2023-04-22 thomas
2090 538aebb5 2023-04-22 thomas got checkout $testroot/repo $testroot/wt2 > /dev/null
2091 538aebb5 2023-04-22 thomas ret=$?
2092 538aebb5 2023-04-22 thomas if [ $ret -ne 0 ]; then
2093 538aebb5 2023-04-22 thomas test_done "$testroot" "$ret"
2094 538aebb5 2023-04-22 thomas return 1
2095 538aebb5 2023-04-22 thomas fi
2096 538aebb5 2023-04-22 thomas
2097 538aebb5 2023-04-22 thomas echo "new file" > $testroot/wt2/new
2098 538aebb5 2023-04-22 thomas (cd $testroot/wt2 && got add new >/dev/null)
2099 538aebb5 2023-04-22 thomas (cd $testroot/wt2 && got commit -m 'add new file from wt2' > \
2100 538aebb5 2023-04-22 thomas $testroot/stdout)
2101 538aebb5 2023-04-22 thomas local wt2_head_id=$(git_show_head $testroot/repo)
2102 538aebb5 2023-04-22 thomas
2103 538aebb5 2023-04-22 thomas echo "modified alpha" > $testroot/wt/alpha
2104 538aebb5 2023-04-22 thomas (cd $testroot/wt && got commit -m 'mod alpha in wt' > $testroot/stdout)
2105 538aebb5 2023-04-22 thomas local wt1_parent_id=$(git_show_parent_commit $testroot/repo)
2106 538aebb5 2023-04-22 thomas
2107 538aebb5 2023-04-22 thomas if [ $wt2_head_id != $wt1_parent_id ]; then
2108 538aebb5 2023-04-22 thomas echo "commit lost from different work tree" >&2
2109 538aebb5 2023-04-22 thomas test_done "$testroot" "1"
2110 538aebb5 2023-04-22 thomas fi
2111 538aebb5 2023-04-22 thomas
2112 538aebb5 2023-04-22 thomas test_done "$testroot" "0"
2113 3f4f8b5a 2023-01-31 thomas }
2114 3f4f8b5a 2023-01-31 thomas
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 18d1acad 2022-07-20 thomas 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 e8f02263 2022-01-23 thomas run_test test_commit_large_file
2143 43896ae6 2022-09-02 thomas run_test test_commit_gitignore
2144 3d47d5be 2022-10-31 thomas run_test test_commit_bad_author
2145 3f4f8b5a 2023-01-31 thomas run_test test_commit_logmsg_ref
2146 538aebb5 2023-04-22 thomas run_test test_commit_from_different_worktrees