Blame


1 c4296144 2019-05-09 stsp #!/bin/sh
2 c4296144 2019-05-09 stsp #
3 c4296144 2019-05-09 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 c4296144 2019-05-09 stsp #
5 c4296144 2019-05-09 stsp # Permission to use, copy, modify, and distribute this software for any
6 c4296144 2019-05-09 stsp # purpose with or without fee is hereby granted, provided that the above
7 c4296144 2019-05-09 stsp # copyright notice and this permission notice appear in all copies.
8 c4296144 2019-05-09 stsp #
9 c4296144 2019-05-09 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c4296144 2019-05-09 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c4296144 2019-05-09 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c4296144 2019-05-09 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c4296144 2019-05-09 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c4296144 2019-05-09 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c4296144 2019-05-09 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 c4296144 2019-05-09 stsp
17 c4296144 2019-05-09 stsp . ./common.sh
18 c4296144 2019-05-09 stsp
19 f6cae3ed 2020-09-13 naddy test_commit_basic() {
20 c4296144 2019-05-09 stsp local testroot=`test_init commit_basic`
21 c4296144 2019-05-09 stsp
22 c4296144 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 49c543a6 2022-03-31 naddy ret=$?
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
26 c4296144 2019-05-09 stsp return 1
27 c4296144 2019-05-09 stsp fi
28 c4296144 2019-05-09 stsp
29 c4296144 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
30 c4296144 2019-05-09 stsp (cd $testroot/wt && got rm beta >/dev/null)
31 c4296144 2019-05-09 stsp echo "new file" > $testroot/wt/new
32 c4296144 2019-05-09 stsp (cd $testroot/wt && got add new >/dev/null)
33 c4296144 2019-05-09 stsp
34 83a7ae6d 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_basic' > $testroot/stdout)
35 c4296144 2019-05-09 stsp
36 c4296144 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
37 afa376bf 2019-05-09 stsp echo "A new" > $testroot/stdout.expected
38 afa376bf 2019-05-09 stsp echo "M alpha" >> $testroot/stdout.expected
39 afa376bf 2019-05-09 stsp echo "D beta" >> $testroot/stdout.expected
40 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
41 c4296144 2019-05-09 stsp
42 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
43 49c543a6 2022-03-31 naddy ret=$?
44 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
45 c4296144 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
46 c4296144 2019-05-09 stsp fi
47 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
48 c4296144 2019-05-09 stsp }
49 c4296144 2019-05-09 stsp
50 f6cae3ed 2020-09-13 naddy test_commit_new_subdir() {
51 baa7dcfa 2019-05-09 stsp local testroot=`test_init commit_new_subdir`
52 baa7dcfa 2019-05-09 stsp
53 baa7dcfa 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
54 49c543a6 2022-03-31 naddy ret=$?
55 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
56 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
57 baa7dcfa 2019-05-09 stsp return 1
58 baa7dcfa 2019-05-09 stsp fi
59 baa7dcfa 2019-05-09 stsp
60 baa7dcfa 2019-05-09 stsp mkdir -p $testroot/wt/d
61 baa7dcfa 2019-05-09 stsp echo "new file" > $testroot/wt/d/new
62 baa7dcfa 2019-05-09 stsp echo "another new file" > $testroot/wt/d/new2
63 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new >/dev/null)
64 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new2 >/dev/null)
65 baa7dcfa 2019-05-09 stsp
66 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && \
67 baa7dcfa 2019-05-09 stsp got commit -m 'test commit_new_subdir' > $testroot/stdout)
68 baa7dcfa 2019-05-09 stsp
69 baa7dcfa 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
70 baa7dcfa 2019-05-09 stsp echo "A d/new" > $testroot/stdout.expected
71 baa7dcfa 2019-05-09 stsp echo "A d/new2" >> $testroot/stdout.expected
72 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
73 baa7dcfa 2019-05-09 stsp
74 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
75 49c543a6 2022-03-31 naddy ret=$?
76 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
77 baa7dcfa 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
78 baa7dcfa 2019-05-09 stsp fi
79 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
80 baa7dcfa 2019-05-09 stsp }
81 baa7dcfa 2019-05-09 stsp
82 f6cae3ed 2020-09-13 naddy test_commit_subdir() {
83 bc70eb79 2019-05-09 stsp local testroot=`test_init commit_subdir`
84 bc70eb79 2019-05-09 stsp
85 bc70eb79 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
86 49c543a6 2022-03-31 naddy ret=$?
87 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
88 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
89 bc70eb79 2019-05-09 stsp return 1
90 bc70eb79 2019-05-09 stsp fi
91 bc70eb79 2019-05-09 stsp
92 bc70eb79 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
93 bc70eb79 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
94 bc70eb79 2019-05-09 stsp
95 bc70eb79 2019-05-09 stsp (cd $testroot/wt && \
96 bc70eb79 2019-05-09 stsp got commit -m 'test commit_subdir' epsilon > $testroot/stdout)
97 bc70eb79 2019-05-09 stsp
98 bc70eb79 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
99 bc70eb79 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
100 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
101 bc70eb79 2019-05-09 stsp
102 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
103 49c543a6 2022-03-31 naddy ret=$?
104 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
105 bc70eb79 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
106 bc70eb79 2019-05-09 stsp fi
107 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
108 bc70eb79 2019-05-09 stsp }
109 bc70eb79 2019-05-09 stsp
110 f6cae3ed 2020-09-13 naddy test_commit_single_file() {
111 5bbcb68b 2019-05-09 stsp local testroot=`test_init commit_single_file`
112 5bbcb68b 2019-05-09 stsp
113 5bbcb68b 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
114 49c543a6 2022-03-31 naddy ret=$?
115 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
116 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
117 5bbcb68b 2019-05-09 stsp return 1
118 5bbcb68b 2019-05-09 stsp fi
119 5bbcb68b 2019-05-09 stsp
120 5bbcb68b 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
121 5bbcb68b 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
122 5bbcb68b 2019-05-09 stsp
123 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon/zeta \
124 5bbcb68b 2019-05-09 stsp > $testroot/stdout)
125 5bbcb68b 2019-05-09 stsp
126 5bbcb68b 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
127 5bbcb68b 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
128 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
129 5bbcb68b 2019-05-09 stsp
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
131 49c543a6 2022-03-31 naddy ret=$?
132 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
133 5bbcb68b 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
134 5bbcb68b 2019-05-09 stsp fi
135 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
136 5bbcb68b 2019-05-09 stsp }
137 5bbcb68b 2019-05-09 stsp
138 f6cae3ed 2020-09-13 naddy test_commit_out_of_date() {
139 819f385b 2019-05-10 stsp local testroot=`test_init commit_out_of_date`
140 f0b75401 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
141 819f385b 2019-05-10 stsp
142 819f385b 2019-05-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 49c543a6 2022-03-31 naddy ret=$?
144 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
145 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
146 819f385b 2019-05-10 stsp return 1
147 819f385b 2019-05-10 stsp fi
148 819f385b 2019-05-10 stsp
149 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/repo/alpha
150 819f385b 2019-05-10 stsp git_commit $testroot/repo -m "modified alpha"
151 819f385b 2019-05-10 stsp
152 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/wt/alpha
153 819f385b 2019-05-10 stsp
154 819f385b 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_out_of_date' \
155 819f385b 2019-05-10 stsp > $testroot/stdout 2> $testroot/stderr)
156 819f385b 2019-05-10 stsp
157 819f385b 2019-05-10 stsp echo -n > $testroot/stdout.expected
158 819f385b 2019-05-10 stsp echo "got: work tree must be updated before these" \
159 819f385b 2019-05-10 stsp "changes can be committed" > $testroot/stderr.expected
160 819f385b 2019-05-10 stsp
161 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
162 49c543a6 2022-03-31 naddy ret=$?
163 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
164 819f385b 2019-05-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
165 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
166 819f385b 2019-05-10 stsp return 1
167 819f385b 2019-05-10 stsp fi
168 819f385b 2019-05-10 stsp
169 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
170 49c543a6 2022-03-31 naddy ret=$?
171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
172 819f385b 2019-05-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
173 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
174 f0b75401 2019-08-03 stsp return 1
175 819f385b 2019-05-10 stsp fi
176 f0b75401 2019-08-03 stsp
177 f0b75401 2019-08-03 stsp echo "alpha" > $testroot/repo/alpha
178 f0b75401 2019-08-03 stsp git_commit $testroot/repo -m "reset alpha contents"
179 f0b75401 2019-08-03 stsp (cd $testroot/wt && got update -c $first_commit > /dev/null)
180 f0b75401 2019-08-03 stsp
181 f0b75401 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
182 f0b75401 2019-08-03 stsp
183 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m 'changed alpha ' > $testroot/stdout)
184 49c543a6 2022-03-31 naddy ret=$?
185 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
186 f0b75401 2019-08-03 stsp echo "commit failed unexpectedly" >&2
187 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
188 f0b75401 2019-08-03 stsp return 1
189 f0b75401 2019-08-03 stsp fi
190 f0b75401 2019-08-03 stsp
191 f0b75401 2019-08-03 stsp local head_rev=`git_show_head $testroot/repo`
192 f0b75401 2019-08-03 stsp echo "M alpha" > $testroot/stdout.expected
193 f0b75401 2019-08-03 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
194 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
195 49c543a6 2022-03-31 naddy ret=$?
196 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
197 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
198 f0b75401 2019-08-03 stsp fi
199 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
200 819f385b 2019-05-10 stsp }
201 819f385b 2019-05-10 stsp
202 f6cae3ed 2020-09-13 naddy test_commit_added_subdirs() {
203 8ba6ba2d 2019-05-14 stsp local testroot=`test_init commit_added_subdirs`
204 8ba6ba2d 2019-05-14 stsp
205 8ba6ba2d 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
206 49c543a6 2022-03-31 naddy ret=$?
207 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
208 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
209 8ba6ba2d 2019-05-14 stsp return 1
210 8ba6ba2d 2019-05-14 stsp fi
211 8ba6ba2d 2019-05-14 stsp
212 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d
213 8ba6ba2d 2019-05-14 stsp echo "new file" > $testroot/wt/d/new
214 8ba6ba2d 2019-05-14 stsp echo "new file 2" > $testroot/wt/d/new2
215 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f
216 8ba6ba2d 2019-05-14 stsp echo "new file 3" > $testroot/wt/d/f/new3
217 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f/g
218 8ba6ba2d 2019-05-14 stsp echo "new file 4" > $testroot/wt/d/f/g/new4
219 8ba6ba2d 2019-05-14 stsp
220 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got add $testroot/wt/*/new* \
221 8ba6ba2d 2019-05-14 stsp $testroot/wt/*/*/new* $testroot/wt/*/*/*/new* > /dev/null)
222 8ba6ba2d 2019-05-14 stsp
223 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got commit -m 'test commit_added_subdirs' \
224 8ba6ba2d 2019-05-14 stsp > $testroot/stdout 2> $testroot/stderr)
225 8ba6ba2d 2019-05-14 stsp
226 8ba6ba2d 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
227 a3df2849 2019-05-20 stsp echo "A d/f/g/new4" > $testroot/stdout.expected
228 a3df2849 2019-05-20 stsp echo "A d/f/new3" >> $testroot/stdout.expected
229 8ba6ba2d 2019-05-14 stsp echo "A d/new" >> $testroot/stdout.expected
230 8ba6ba2d 2019-05-14 stsp echo "A d/new2" >> $testroot/stdout.expected
231 ba580f68 2020-03-22 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
232 ba580f68 2020-03-22 stsp
233 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
234 49c543a6 2022-03-31 naddy ret=$?
235 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
236 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
237 ba580f68 2020-03-22 stsp fi
238 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
239 ba580f68 2020-03-22 stsp }
240 ba580f68 2020-03-22 stsp
241 f6cae3ed 2020-09-13 naddy test_commit_deleted_subdirs() {
242 ba580f68 2020-03-22 stsp local testroot=`test_init commit_deleted_subdirs`
243 ba580f68 2020-03-22 stsp
244 ba580f68 2020-03-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
245 49c543a6 2022-03-31 naddy ret=$?
246 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
247 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
248 ba580f68 2020-03-22 stsp return 1
249 ba580f68 2020-03-22 stsp fi
250 ba580f68 2020-03-22 stsp
251 c8c7d149 2020-09-17 naddy (cd $testroot/wt && \
252 c8c7d149 2020-09-17 naddy got rm -R $testroot/wt/epsilon $testroot/wt/gamma >/dev/null)
253 ba580f68 2020-03-22 stsp
254 ba580f68 2020-03-22 stsp (cd $testroot/wt && got commit -m 'test commit_deleted_subdirs' \
255 ba580f68 2020-03-22 stsp > $testroot/stdout 2> $testroot/stderr)
256 ba580f68 2020-03-22 stsp
257 ba580f68 2020-03-22 stsp local head_rev=`git_show_head $testroot/repo`
258 ba580f68 2020-03-22 stsp echo "D epsilon/zeta" > $testroot/stdout.expected
259 ba580f68 2020-03-22 stsp echo "D gamma/delta" >> $testroot/stdout.expected
260 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
261 ba580f68 2020-03-22 stsp
262 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
263 49c543a6 2022-03-31 naddy ret=$?
264 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
265 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
267 ba580f68 2020-03-22 stsp return 1
268 ba580f68 2020-03-22 stsp fi
269 8ba6ba2d 2019-05-14 stsp
270 ba580f68 2020-03-22 stsp got tree -r $testroot/repo > $testroot/stdout
271 ba580f68 2020-03-22 stsp
272 ba580f68 2020-03-22 stsp echo "alpha" > $testroot/stdout.expected
273 ba580f68 2020-03-22 stsp echo "beta" >> $testroot/stdout.expected
274 ba580f68 2020-03-22 stsp
275 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
276 49c543a6 2022-03-31 naddy ret=$?
277 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
278 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
279 8ba6ba2d 2019-05-14 stsp fi
280 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
281 8ba6ba2d 2019-05-14 stsp }
282 8ba6ba2d 2019-05-14 stsp
283 f6cae3ed 2020-09-13 naddy test_commit_rejects_conflicted_file() {
284 461aee03 2019-06-29 stsp local testroot=`test_init commit_rejects_conflicted_file`
285 f363d663 2019-05-23 stsp
286 f363d663 2019-05-23 stsp local initial_rev=`git_show_head $testroot/repo`
287 f363d663 2019-05-23 stsp
288 f363d663 2019-05-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
289 49c543a6 2022-03-31 naddy ret=$?
290 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
291 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
292 f363d663 2019-05-23 stsp return 1
293 f363d663 2019-05-23 stsp fi
294 f363d663 2019-05-23 stsp
295 f363d663 2019-05-23 stsp echo "modified alpha" > $testroot/wt/alpha
296 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
297 f363d663 2019-05-23 stsp
298 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
299 f363d663 2019-05-23 stsp
300 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
301 f363d663 2019-05-23 stsp
302 f363d663 2019-05-23 stsp echo "C alpha" > $testroot/stdout.expected
303 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
304 f363d663 2019-05-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
305 f363d663 2019-05-23 stsp echo >> $testroot/stdout.expected
306 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
307 f363d663 2019-05-23 stsp
308 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
309 f363d663 2019-05-23 stsp
310 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
311 49c543a6 2022-03-31 naddy ret=$?
312 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
313 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
314 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
315 f363d663 2019-05-23 stsp return 1
316 f363d663 2019-05-23 stsp fi
317 f363d663 2019-05-23 stsp
318 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
319 f363d663 2019-05-23 stsp 2> $testroot/stderr)
320 f363d663 2019-05-23 stsp
321 f363d663 2019-05-23 stsp echo -n > $testroot/stdout.expected
322 f363d663 2019-05-23 stsp echo "got: cannot commit file in conflicted status" \
323 f363d663 2019-05-23 stsp > $testroot/stderr.expected
324 f363d663 2019-05-23 stsp
325 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
326 49c543a6 2022-03-31 naddy ret=$?
327 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
328 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
329 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
330 f363d663 2019-05-23 stsp return 1
331 f363d663 2019-05-23 stsp fi
332 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
333 49c543a6 2022-03-31 naddy ret=$?
334 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
335 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
336 f363d663 2019-05-23 stsp fi
337 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
338 f363d663 2019-05-23 stsp }
339 1a36436d 2019-06-10 stsp
340 f6cae3ed 2020-09-13 naddy test_commit_single_file_multiple() {
341 1a36436d 2019-06-10 stsp local testroot=`test_init commit_single_file_multiple`
342 f363d663 2019-05-23 stsp
343 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
344 49c543a6 2022-03-31 naddy ret=$?
345 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
346 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
347 1a36436d 2019-06-10 stsp return 1
348 1a36436d 2019-06-10 stsp fi
349 1a36436d 2019-06-10 stsp
350 1a36436d 2019-06-10 stsp for i in 1 2 3 4; do
351 1a36436d 2019-06-10 stsp echo "modified alpha" >> $testroot/wt/alpha
352 1a36436d 2019-06-10 stsp
353 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
354 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
355 1a36436d 2019-06-10 stsp
356 1a36436d 2019-06-10 stsp local head_rev=`git_show_head $testroot/repo`
357 1a36436d 2019-06-10 stsp echo "M alpha" > $testroot/stdout.expected
358 1a36436d 2019-06-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
359 1a36436d 2019-06-10 stsp
360 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
361 49c543a6 2022-03-31 naddy ret=$?
362 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
363 1a36436d 2019-06-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
364 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
365 1a36436d 2019-06-10 stsp return 1
366 1a36436d 2019-06-10 stsp fi
367 1a36436d 2019-06-10 stsp done
368 1a36436d 2019-06-10 stsp
369 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
370 1a36436d 2019-06-10 stsp }
371 4866d084 2019-07-10 stsp
372 f6cae3ed 2020-09-13 naddy test_commit_added_and_modified_in_same_dir() {
373 4866d084 2019-07-10 stsp local testroot=`test_init commit_added_and_modified_in_same_dir`
374 1a36436d 2019-06-10 stsp
375 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
376 49c543a6 2022-03-31 naddy ret=$?
377 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
378 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
379 4866d084 2019-07-10 stsp return 1
380 4866d084 2019-07-10 stsp fi
381 4866d084 2019-07-10 stsp
382 4866d084 2019-07-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
383 4866d084 2019-07-10 stsp echo "new file" > $testroot/wt/epsilon/new
384 4866d084 2019-07-10 stsp (cd $testroot/wt && got add epsilon/new >/dev/null)
385 4866d084 2019-07-10 stsp
386 4866d084 2019-07-10 stsp (cd $testroot/wt && got commit \
387 4866d084 2019-07-10 stsp -m 'added and modified in same dir' > $testroot/stdout \
388 4866d084 2019-07-10 stsp 2> $testroot/stderr)
389 4866d084 2019-07-10 stsp
390 4866d084 2019-07-10 stsp local head_rev=`git_show_head $testroot/repo`
391 4866d084 2019-07-10 stsp echo "A epsilon/new" > $testroot/stdout.expected
392 4866d084 2019-07-10 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
393 4866d084 2019-07-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
394 e0233cea 2019-07-25 stsp
395 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
396 49c543a6 2022-03-31 naddy ret=$?
397 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
398 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
399 e0233cea 2019-07-25 stsp fi
400 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
401 e0233cea 2019-07-25 stsp }
402 e0233cea 2019-07-25 stsp
403 f6cae3ed 2020-09-13 naddy test_commit_path_prefix() {
404 e0233cea 2019-07-25 stsp local testroot=`test_init commit_path_prefix`
405 e0233cea 2019-07-25 stsp local commit1=`git_show_head $testroot/repo`
406 e0233cea 2019-07-25 stsp
407 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
408 49c543a6 2022-03-31 naddy ret=$?
409 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
410 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
411 e0233cea 2019-07-25 stsp return 1
412 e0233cea 2019-07-25 stsp fi
413 e0233cea 2019-07-25 stsp
414 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
415 e0233cea 2019-07-25 stsp
416 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
417 e0233cea 2019-07-25 stsp
418 e0233cea 2019-07-25 stsp local commit2=`git_show_head $testroot/repo`
419 e0233cea 2019-07-25 stsp echo "M delta" > $testroot/stdout.expected
420 e0233cea 2019-07-25 stsp echo "Created commit $commit2" >> $testroot/stdout.expected
421 4866d084 2019-07-10 stsp
422 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
423 49c543a6 2022-03-31 naddy ret=$?
424 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
425 2b496619 2019-07-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
426 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
427 e0233cea 2019-07-25 stsp return 1
428 4866d084 2019-07-10 stsp fi
429 e0233cea 2019-07-25 stsp
430 e0233cea 2019-07-25 stsp echo "diff $commit1 $commit2" > $testroot/stdout.expected
431 8469d821 2022-06-25 stsp echo "commit - $commit1" >> $testroot/stdout.expected
432 8469d821 2022-06-25 stsp echo "commit + $commit2" >> $testroot/stdout.expected
433 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
434 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
435 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $testroot/stdout.expected
436 e0233cea 2019-07-25 stsp echo -n 'blob + ' >> $testroot/stdout.expected
437 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
438 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
439 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
440 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
441 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
442 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
443 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
444 e0233cea 2019-07-25 stsp
445 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
446 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
447 49c543a6 2022-03-31 naddy ret=$?
448 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
449 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
450 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
451 f2b0a8b0 2020-07-31 stsp return 1
452 f2b0a8b0 2020-07-31 stsp fi
453 f2b0a8b0 2020-07-31 stsp
454 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got rm delta > /dev/null)
455 f2b0a8b0 2020-07-31 stsp echo new > $testroot/wt/new
456 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got add new > /dev/null)
457 f2b0a8b0 2020-07-31 stsp
458 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
459 f2b0a8b0 2020-07-31 stsp > $testroot/stdout)
460 f2b0a8b0 2020-07-31 stsp
461 f2b0a8b0 2020-07-31 stsp local commit3=`git_show_head $testroot/repo`
462 f2b0a8b0 2020-07-31 stsp echo "A new" > $testroot/stdout.expected
463 f2b0a8b0 2020-07-31 stsp echo "D delta" >> $testroot/stdout.expected
464 f2b0a8b0 2020-07-31 stsp echo "Created commit $commit3" >> $testroot/stdout.expected
465 f2b0a8b0 2020-07-31 stsp
466 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
467 49c543a6 2022-03-31 naddy ret=$?
468 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
469 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
470 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
471 f2b0a8b0 2020-07-31 stsp return 1
472 f2b0a8b0 2020-07-31 stsp fi
473 f2b0a8b0 2020-07-31 stsp
474 f2b0a8b0 2020-07-31 stsp echo "diff $commit2 $commit3" > $testroot/stdout.expected
475 8469d821 2022-06-25 stsp echo "commit - $commit2" >> $testroot/stdout.expected
476 8469d821 2022-06-25 stsp echo "commit + $commit3" >> $testroot/stdout.expected
477 f2b0a8b0 2020-07-31 stsp echo -n 'blob - ' >> $testroot/stdout.expected
478 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
479 f2b0a8b0 2020-07-31 stsp | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
480 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
481 f2b0a8b0 2020-07-31 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
482 f2b0a8b0 2020-07-31 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
483 f2b0a8b0 2020-07-31 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
484 f2b0a8b0 2020-07-31 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
485 f2b0a8b0 2020-07-31 stsp echo '-modified delta' >> $testroot/stdout.expected
486 f2b0a8b0 2020-07-31 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
487 f2b0a8b0 2020-07-31 stsp echo -n 'blob + ' >> $testroot/stdout.expected
488 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
489 f2b0a8b0 2020-07-31 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
490 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
491 f2b0a8b0 2020-07-31 stsp echo '--- /dev/null' >> $testroot/stdout.expected
492 f2b0a8b0 2020-07-31 stsp echo '+++ gamma/new' >> $testroot/stdout.expected
493 f2b0a8b0 2020-07-31 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
494 f2b0a8b0 2020-07-31 stsp echo '+new' >> $testroot/stdout.expected
495 f2b0a8b0 2020-07-31 stsp
496 f2b0a8b0 2020-07-31 stsp got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
497 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
498 49c543a6 2022-03-31 naddy ret=$?
499 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
500 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
501 e0233cea 2019-07-25 stsp fi
502 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
503 f2b0a8b0 2020-07-31 stsp return "$ret"
504 4866d084 2019-07-10 stsp }
505 90e8619e 2019-07-25 stsp
506 f6cae3ed 2020-09-13 naddy test_commit_dir_path() {
507 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
508 4866d084 2019-07-10 stsp
509 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
510 49c543a6 2022-03-31 naddy ret=$?
511 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
512 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
513 90e8619e 2019-07-25 stsp return 1
514 90e8619e 2019-07-25 stsp fi
515 90e8619e 2019-07-25 stsp
516 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
517 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
518 90e8619e 2019-07-25 stsp
519 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
520 90e8619e 2019-07-25 stsp > $testroot/stdout)
521 90e8619e 2019-07-25 stsp
522 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
523 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
524 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
525 90e8619e 2019-07-25 stsp
526 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
527 49c543a6 2022-03-31 naddy ret=$?
528 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
529 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
530 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
531 90e8619e 2019-07-25 stsp return 1
532 90e8619e 2019-07-25 stsp fi
533 90e8619e 2019-07-25 stsp
534 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
535 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
536 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
537 49c543a6 2022-03-31 naddy ret=$?
538 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
539 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
540 90e8619e 2019-07-25 stsp fi
541 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
542 90e8619e 2019-07-25 stsp }
543 5c1e53bc 2019-07-28 stsp
544 f6cae3ed 2020-09-13 naddy test_commit_selected_paths() {
545 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
546 5c1e53bc 2019-07-28 stsp
547 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
548 49c543a6 2022-03-31 naddy ret=$?
549 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
550 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
551 5c1e53bc 2019-07-28 stsp return 1
552 5c1e53bc 2019-07-28 stsp fi
553 5c1e53bc 2019-07-28 stsp
554 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
555 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
556 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
557 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
558 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
559 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
560 90e8619e 2019-07-25 stsp
561 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
562 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
563 49c543a6 2022-03-31 naddy ret=$?
564 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
565 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
566 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
567 5c1e53bc 2019-07-28 stsp return 1
568 5c1e53bc 2019-07-28 stsp fi
569 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
570 5c1e53bc 2019-07-28 stsp
571 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
572 49c543a6 2022-03-31 naddy ret=$?
573 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
574 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
575 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
576 5c1e53bc 2019-07-28 stsp return 1
577 5c1e53bc 2019-07-28 stsp fi
578 5c1e53bc 2019-07-28 stsp
579 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
580 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
581 5c1e53bc 2019-07-28 stsp
582 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
583 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
584 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
585 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
586 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
587 5c1e53bc 2019-07-28 stsp
588 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
589 49c543a6 2022-03-31 naddy ret=$?
590 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
591 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
592 5c1e53bc 2019-07-28 stsp fi
593 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
594 5c1e53bc 2019-07-28 stsp }
595 5c1e53bc 2019-07-28 stsp
596 f6cae3ed 2020-09-13 naddy test_commit_outside_refs_heads() {
597 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
598 916f288c 2019-07-30 stsp
599 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
600 916f288c 2019-07-30 stsp
601 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
602 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
603 49c543a6 2022-03-31 naddy ret=$?
604 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
605 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
606 916f288c 2019-07-30 stsp return 1
607 916f288c 2019-07-30 stsp fi
608 916f288c 2019-07-30 stsp
609 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
610 916f288c 2019-07-30 stsp
611 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
612 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
613 49c543a6 2022-03-31 naddy ret=$?
614 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
615 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
616 916f288c 2019-07-30 stsp test_done "$testroot" "1"
617 916f288c 2019-07-30 stsp return 1
618 916f288c 2019-07-30 stsp fi
619 916f288c 2019-07-30 stsp
620 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
621 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
622 49c543a6 2022-03-31 naddy ret=$?
623 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
624 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
625 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
626 916f288c 2019-07-30 stsp return 1
627 916f288c 2019-07-30 stsp fi
628 916f288c 2019-07-30 stsp
629 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
630 916f288c 2019-07-30 stsp > $testroot/stderr.expected
631 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
632 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
633 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
634 49c543a6 2022-03-31 naddy ret=$?
635 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
636 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
637 916f288c 2019-07-30 stsp fi
638 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
639 916f288c 2019-07-30 stsp }
640 916f288c 2019-07-30 stsp
641 f6cae3ed 2020-09-13 naddy test_commit_no_email() {
642 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
643 916f288c 2019-07-30 stsp
644 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
645 49c543a6 2022-03-31 naddy ret=$?
646 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
647 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
648 84792843 2019-08-09 stsp return 1
649 84792843 2019-08-09 stsp fi
650 84792843 2019-08-09 stsp
651 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
652 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
653 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
654 84792843 2019-08-09 stsp 2> $testroot/stderr)
655 84792843 2019-08-09 stsp
656 1d918cf9 2022-02-06 op echo -n "got: :flan_hacker:: commit author's email address " \
657 84792843 2019-08-09 stsp > $testroot/stderr.expected
658 1d918cf9 2022-02-06 op echo "is required for compatibility with Git" \
659 84792843 2019-08-09 stsp >> $testroot/stderr.expected
660 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
661 49c543a6 2022-03-31 naddy ret=$?
662 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
663 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
664 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
665 84792843 2019-08-09 stsp return 1
666 84792843 2019-08-09 stsp fi
667 84792843 2019-08-09 stsp
668 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
669 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
670 49c543a6 2022-03-31 naddy ret=$?
671 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
672 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
673 84792843 2019-08-09 stsp fi
674 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
675 84792843 2019-08-09 stsp }
676 6af1ccbd 2019-08-16 stsp
677 f6cae3ed 2020-09-13 naddy test_commit_tree_entry_sorting() {
678 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
679 6af1ccbd 2019-08-16 stsp
680 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
681 49c543a6 2022-03-31 naddy ret=$?
682 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
683 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
684 6af1ccbd 2019-08-16 stsp return 1
685 6af1ccbd 2019-08-16 stsp fi
686 6af1ccbd 2019-08-16 stsp
687 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
688 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
689 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
690 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
691 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
692 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
693 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
694 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
695 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
696 84792843 2019-08-09 stsp
697 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
698 84792843 2019-08-09 stsp
699 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
700 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
701 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
702 49c543a6 2022-03-31 naddy ret=$?
703 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
704 257add31 2020-09-09 stsp }
705 257add31 2020-09-09 stsp
706 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_author() {
707 257add31 2020-09-09 stsp local testroot=`test_init commit_gotconfig_author`
708 257add31 2020-09-09 stsp
709 257add31 2020-09-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
710 49c543a6 2022-03-31 naddy ret=$?
711 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
712 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
713 257add31 2020-09-09 stsp return 1
714 257add31 2020-09-09 stsp fi
715 257add31 2020-09-09 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
716 257add31 2020-09-09 stsp > $testroot/repo/.git/got.conf
717 257add31 2020-09-09 stsp
718 257add31 2020-09-09 stsp echo "modified alpha" > $testroot/wt/alpha
719 257add31 2020-09-09 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
720 49c543a6 2022-03-31 naddy ret=$?
721 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
722 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
723 257add31 2020-09-09 stsp return 1
724 257add31 2020-09-09 stsp fi
725 257add31 2020-09-09 stsp
726 257add31 2020-09-09 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
727 49c543a6 2022-03-31 naddy ret=$?
728 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
729 257add31 2020-09-09 stsp test_done "$testroot" "$ret"
730 257add31 2020-09-09 stsp return 1
731 257add31 2020-09-09 stsp fi
732 257add31 2020-09-09 stsp
733 257add31 2020-09-09 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
734 50b0790e 2020-09-11 stsp > $testroot/stdout.expected
735 50b0790e 2020-09-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
736 49c543a6 2022-03-31 naddy ret=$?
737 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
738 50b0790e 2020-09-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
739 50b0790e 2020-09-11 stsp fi
740 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
741 50b0790e 2020-09-11 stsp }
742 50b0790e 2020-09-11 stsp
743 f6cae3ed 2020-09-13 naddy test_commit_gotconfig_worktree_author() {
744 50b0790e 2020-09-11 stsp local testroot=`test_init commit_gotconfig_worktree_author`
745 50b0790e 2020-09-11 stsp
746 50b0790e 2020-09-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
747 49c543a6 2022-03-31 naddy ret=$?
748 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
749 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
750 50b0790e 2020-09-11 stsp return 1
751 50b0790e 2020-09-11 stsp fi
752 50b0790e 2020-09-11 stsp echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
753 50b0790e 2020-09-11 stsp > $testroot/repo/.git/got.conf
754 50b0790e 2020-09-11 stsp echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
755 50b0790e 2020-09-11 stsp > $testroot/wt/.got/got.conf
756 50b0790e 2020-09-11 stsp
757 50b0790e 2020-09-11 stsp echo "modified alpha" > $testroot/wt/alpha
758 50b0790e 2020-09-11 stsp (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
759 49c543a6 2022-03-31 naddy ret=$?
760 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
761 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
762 50b0790e 2020-09-11 stsp return 1
763 50b0790e 2020-09-11 stsp fi
764 50b0790e 2020-09-11 stsp
765 50b0790e 2020-09-11 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
766 49c543a6 2022-03-31 naddy ret=$?
767 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
768 50b0790e 2020-09-11 stsp test_done "$testroot" "$ret"
769 50b0790e 2020-09-11 stsp return 1
770 50b0790e 2020-09-11 stsp fi
771 50b0790e 2020-09-11 stsp
772 50b0790e 2020-09-11 stsp echo "from: Flan Squee <flan_squee@openbsd.org>" \
773 257add31 2020-09-09 stsp > $testroot/stdout.expected
774 257add31 2020-09-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
775 49c543a6 2022-03-31 naddy ret=$?
776 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
777 257add31 2020-09-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
778 257add31 2020-09-09 stsp fi
779 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
780 6af1ccbd 2019-08-16 stsp }
781 aba9c984 2019-09-08 stsp
782 f6cae3ed 2020-09-13 naddy test_commit_gitconfig_author() {
783 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
784 84792843 2019-08-09 stsp
785 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
786 49c543a6 2022-03-31 naddy ret=$?
787 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
788 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
789 aba9c984 2019-09-08 stsp return 1
790 aba9c984 2019-09-08 stsp fi
791 aba9c984 2019-09-08 stsp
792 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
793 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
794 aba9c984 2019-09-08 stsp
795 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
796 aba9c984 2019-09-08 stsp (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
797 49c543a6 2022-03-31 naddy ret=$?
798 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
799 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
800 aba9c984 2019-09-08 stsp return 1
801 aba9c984 2019-09-08 stsp fi
802 aba9c984 2019-09-08 stsp
803 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
804 49c543a6 2022-03-31 naddy ret=$?
805 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
806 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
807 aba9c984 2019-09-08 stsp return 1
808 aba9c984 2019-09-08 stsp fi
809 aba9c984 2019-09-08 stsp
810 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
811 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
812 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
813 49c543a6 2022-03-31 naddy ret=$?
814 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
815 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
816 aba9c984 2019-09-08 stsp fi
817 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
818 aba9c984 2019-09-08 stsp }
819 1ebedb77 2019-10-19 stsp
820 f6cae3ed 2020-09-13 naddy test_commit_xbit_change() {
821 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
822 1ebedb77 2019-10-19 stsp
823 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
824 49c543a6 2022-03-31 naddy ret=$?
825 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
826 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
827 1ebedb77 2019-10-19 stsp return 1
828 1ebedb77 2019-10-19 stsp fi
829 1ebedb77 2019-10-19 stsp
830 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
831 1ebedb77 2019-10-19 stsp
832 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
833 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
834 aba9c984 2019-09-08 stsp
835 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
836 49c543a6 2022-03-31 naddy ret=$?
837 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
838 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
839 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
840 1ebedb77 2019-10-19 stsp return 1
841 1ebedb77 2019-10-19 stsp fi
842 1ebedb77 2019-10-19 stsp
843 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
844 49c543a6 2022-03-31 naddy ret=$?
845 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
846 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
847 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
848 1ebedb77 2019-10-19 stsp return 1
849 1ebedb77 2019-10-19 stsp fi
850 1ebedb77 2019-10-19 stsp
851 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
852 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
853 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
854 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
855 49c543a6 2022-03-31 naddy ret=$?
856 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
857 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
858 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
859 1ebedb77 2019-10-19 stsp return 1
860 1ebedb77 2019-10-19 stsp fi
861 1ebedb77 2019-10-19 stsp
862 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
863 1ebedb77 2019-10-19 stsp
864 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
865 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
866 49c543a6 2022-03-31 naddy ret=$?
867 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
868 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
869 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
870 1ebedb77 2019-10-19 stsp return 1
871 1ebedb77 2019-10-19 stsp fi
872 1ebedb77 2019-10-19 stsp
873 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
874 1ebedb77 2019-10-19 stsp
875 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
876 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
877 1ebedb77 2019-10-19 stsp
878 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
879 49c543a6 2022-03-31 naddy ret=$?
880 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
881 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
882 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
883 1ebedb77 2019-10-19 stsp return 1
884 1ebedb77 2019-10-19 stsp fi
885 1ebedb77 2019-10-19 stsp
886 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
887 49c543a6 2022-03-31 naddy ret=$?
888 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
889 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
890 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
891 1ebedb77 2019-10-19 stsp return 1
892 1ebedb77 2019-10-19 stsp fi
893 1ebedb77 2019-10-19 stsp
894 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
895 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
896 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
897 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
898 49c543a6 2022-03-31 naddy ret=$?
899 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
900 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
901 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
902 1ebedb77 2019-10-19 stsp return 1
903 1ebedb77 2019-10-19 stsp fi
904 1ebedb77 2019-10-19 stsp
905 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
906 1ebedb77 2019-10-19 stsp
907 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
908 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
909 f7b97ccb 2020-04-14 stsp
910 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
911 49c543a6 2022-03-31 naddy ret=$?
912 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
913 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
914 f7b97ccb 2020-04-14 stsp fi
915 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
916 f7b97ccb 2020-04-14 stsp }
917 f7b97ccb 2020-04-14 stsp
918 f6cae3ed 2020-09-13 naddy commit_check_mode() {
919 f7b97ccb 2020-04-14 stsp local mode="$1"
920 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
921 f7b97ccb 2020-04-14 stsp
922 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
923 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
924 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
925 f7b97ccb 2020-04-14 stsp
926 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
927 49c543a6 2022-03-31 naddy ret=$?
928 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
929 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
930 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
931 f7b97ccb 2020-04-14 stsp return 1
932 f7b97ccb 2020-04-14 stsp fi
933 1ebedb77 2019-10-19 stsp
934 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
935 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
936 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
937 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
938 49c543a6 2022-03-31 naddy ret=$?
939 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
940 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
941 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
942 a9662115 2021-08-29 naddy return 1
943 f7b97ccb 2020-04-14 stsp fi
944 f7b97ccb 2020-04-14 stsp
945 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
946 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
947 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
948 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
949 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
950 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
951 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
952 49c543a6 2022-03-31 naddy ret=$?
953 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
954 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
955 1ebedb77 2019-10-19 stsp fi
956 f7b97ccb 2020-04-14 stsp return $ret
957 f7b97ccb 2020-04-14 stsp }
958 f7b97ccb 2020-04-14 stsp
959 f6cae3ed 2020-09-13 naddy test_commit_normalizes_filemodes() {
960 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
961 f7b97ccb 2020-04-14 stsp
962 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
963 49c543a6 2022-03-31 naddy ret=$?
964 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
965 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
966 f7b97ccb 2020-04-14 stsp return 1
967 f7b97ccb 2020-04-14 stsp fi
968 f7b97ccb 2020-04-14 stsp
969 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
970 f7b97ccb 2020-04-14 stsp for m in $modes; do
971 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
972 49c543a6 2022-03-31 naddy ret=$?
973 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
974 f7b97ccb 2020-04-14 stsp break
975 f7b97ccb 2020-04-14 stsp fi
976 f7b97ccb 2020-04-14 stsp done
977 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
978 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
979 f7b97ccb 2020-04-14 stsp return 1
980 f7b97ccb 2020-04-14 stsp fi
981 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
982 f7b97ccb 2020-04-14 stsp for m in $modes; do
983 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
984 49c543a6 2022-03-31 naddy ret=$?
985 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
986 f7b97ccb 2020-04-14 stsp break
987 f7b97ccb 2020-04-14 stsp fi
988 f7b97ccb 2020-04-14 stsp done
989 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
990 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
991 e7303626 2020-05-14 stsp return 1
992 e7303626 2020-05-14 stsp fi
993 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
994 e7303626 2020-05-14 stsp }
995 e7303626 2020-05-14 stsp
996 f6cae3ed 2020-09-13 naddy test_commit_with_unrelated_submodule() {
997 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
998 e7303626 2020-05-14 stsp
999 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1000 e7303626 2020-05-14 stsp
1001 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
1002 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1003 e7303626 2020-05-14 stsp
1004 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1005 49c543a6 2022-03-31 naddy ret=$?
1006 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1007 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
1008 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1009 e7303626 2020-05-14 stsp return 1
1010 e7303626 2020-05-14 stsp fi
1011 e7303626 2020-05-14 stsp
1012 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
1013 e7303626 2020-05-14 stsp
1014 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
1015 7aadece8 2020-05-17 stsp
1016 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1017 49c543a6 2022-03-31 naddy ret=$?
1018 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1019 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
1020 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
1021 f7b97ccb 2020-04-14 stsp return 1
1022 f7b97ccb 2020-04-14 stsp fi
1023 e7303626 2020-05-14 stsp
1024 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
1025 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
1026 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1027 3d9a4ec4 2020-07-23 stsp
1028 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1029 49c543a6 2022-03-31 naddy ret=$?
1030 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1031 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1032 3d9a4ec4 2020-07-23 stsp fi
1033 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1034 3d9a4ec4 2020-07-23 stsp }
1035 3d9a4ec4 2020-07-23 stsp
1036 f6cae3ed 2020-09-13 naddy check_symlinks() {
1037 bd6aa359 2020-07-23 stsp local wtpath="$1"
1038 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
1039 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
1040 bd6aa359 2020-07-23 stsp return 1
1041 bd6aa359 2020-07-23 stsp fi
1042 3d9a4ec4 2020-07-23 stsp
1043 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
1044 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1045 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1046 49c543a6 2022-03-31 naddy ret=$?
1047 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1048 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1049 3d9a4ec4 2020-07-23 stsp return 1
1050 3d9a4ec4 2020-07-23 stsp fi
1051 3d9a4ec4 2020-07-23 stsp
1052 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
1053 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
1054 bd6aa359 2020-07-23 stsp return 1
1055 bd6aa359 2020-07-23 stsp fi
1056 3d9a4ec4 2020-07-23 stsp
1057 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
1058 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1059 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1060 49c543a6 2022-03-31 naddy ret=$?
1061 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1062 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1063 3d9a4ec4 2020-07-23 stsp return 1
1064 3d9a4ec4 2020-07-23 stsp fi
1065 3d9a4ec4 2020-07-23 stsp
1066 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
1067 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1068 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
1069 bd6aa359 2020-07-23 stsp return 1
1070 bd6aa359 2020-07-23 stsp fi
1071 bd6aa359 2020-07-23 stsp
1072 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1073 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
1074 49c543a6 2022-03-31 naddy ret=$?
1075 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1076 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
1077 3d9a4ec4 2020-07-23 stsp return 1
1078 3d9a4ec4 2020-07-23 stsp fi
1079 3d9a4ec4 2020-07-23 stsp
1080 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1081 49c543a6 2022-03-31 naddy ret=$?
1082 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1083 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1084 3d9a4ec4 2020-07-23 stsp return 1
1085 3d9a4ec4 2020-07-23 stsp fi
1086 3d9a4ec4 2020-07-23 stsp
1087 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
1088 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1089 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1090 49c543a6 2022-03-31 naddy ret=$?
1091 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1092 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1093 3d9a4ec4 2020-07-23 stsp return 1
1094 3d9a4ec4 2020-07-23 stsp fi
1095 7aadece8 2020-05-17 stsp
1096 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
1097 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1098 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1099 49c543a6 2022-03-31 naddy ret=$?
1100 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1101 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1102 3d9a4ec4 2020-07-23 stsp return 1
1103 e7303626 2020-05-14 stsp fi
1104 3d9a4ec4 2020-07-23 stsp
1105 bd6aa359 2020-07-23 stsp return 0
1106 bd6aa359 2020-07-23 stsp }
1107 3d9a4ec4 2020-07-23 stsp
1108 f6cae3ed 2020-09-13 naddy test_commit_symlink() {
1109 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
1110 3d9a4ec4 2020-07-23 stsp
1111 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1112 49c543a6 2022-03-31 naddy ret=$?
1113 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1114 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1115 3d9a4ec4 2020-07-23 stsp return 1
1116 3d9a4ec4 2020-07-23 stsp fi
1117 3d9a4ec4 2020-07-23 stsp
1118 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
1119 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
1120 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1121 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1122 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1123 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1124 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
1125 bd6aa359 2020-07-23 stsp
1126 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1127 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1128 49c543a6 2022-03-31 naddy ret=$?
1129 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1130 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1131 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1132 35213c7c 2020-07-23 stsp return 1
1133 35213c7c 2020-07-23 stsp fi
1134 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1135 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1136 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1137 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1138 49c543a6 2022-03-31 naddy ret=$?
1139 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1140 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1141 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1142 35213c7c 2020-07-23 stsp return 1
1143 35213c7c 2020-07-23 stsp fi
1144 bd6aa359 2020-07-23 stsp
1145 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1146 35213c7c 2020-07-23 stsp > $testroot/stdout)
1147 35213c7c 2020-07-23 stsp
1148 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1149 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1150 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1151 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1152 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1153 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1154 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1155 bd6aa359 2020-07-23 stsp
1156 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1157 49c543a6 2022-03-31 naddy ret=$?
1158 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1159 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1160 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1161 3d9a4ec4 2020-07-23 stsp return 1
1162 3d9a4ec4 2020-07-23 stsp fi
1163 3d9a4ec4 2020-07-23 stsp
1164 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1165 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1166 49c543a6 2022-03-31 naddy ret=$?
1167 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1168 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1169 bd6aa359 2020-07-23 stsp return 1
1170 3d9a4ec4 2020-07-23 stsp fi
1171 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1172 49c543a6 2022-03-31 naddy ret=$?
1173 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1174 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1175 bd6aa359 2020-07-23 stsp return 1
1176 bd6aa359 2020-07-23 stsp fi
1177 bd6aa359 2020-07-23 stsp
1178 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1179 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1180 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1181 75f0a0fb 2020-07-23 stsp return 1
1182 75f0a0fb 2020-07-23 stsp fi
1183 75f0a0fb 2020-07-23 stsp
1184 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1185 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1186 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1187 49c543a6 2022-03-31 naddy ret=$?
1188 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1189 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1190 5a1fbc73 2020-07-23 stsp return 1
1191 5a1fbc73 2020-07-23 stsp fi
1192 88fb31d4 2020-07-23 stsp
1193 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1194 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
1195 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1196 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1197 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1198 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1199 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1200 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1201 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1202 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1203 88fb31d4 2020-07-23 stsp
1204 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1205 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1206 49c543a6 2022-03-31 naddy ret=$?
1207 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1208 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1209 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1210 35213c7c 2020-07-23 stsp return 1
1211 35213c7c 2020-07-23 stsp fi
1212 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1213 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1214 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1215 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1216 49c543a6 2022-03-31 naddy ret=$?
1217 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1218 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1219 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1220 35213c7c 2020-07-23 stsp return 1
1221 35213c7c 2020-07-23 stsp fi
1222 88fb31d4 2020-07-23 stsp
1223 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1224 35213c7c 2020-07-23 stsp > $testroot/stdout)
1225 35213c7c 2020-07-23 stsp
1226 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1227 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1228 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1229 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1230 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1231 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1232 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1233 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1234 88fb31d4 2020-07-23 stsp
1235 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1236 49c543a6 2022-03-31 naddy ret=$?
1237 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1238 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1239 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1240 88fb31d4 2020-07-23 stsp return 1
1241 88fb31d4 2020-07-23 stsp fi
1242 88fb31d4 2020-07-23 stsp
1243 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1244 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1245 88fb31d4 2020-07-23 stsp alpha
1246 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1247 88fb31d4 2020-07-23 stsp beta
1248 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1249 88fb31d4 2020-07-23 stsp epsilon/
1250 88fb31d4 2020-07-23 stsp epsilon/beta.link
1251 88fb31d4 2020-07-23 stsp epsilon/zeta
1252 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1253 88fb31d4 2020-07-23 stsp gamma/
1254 88fb31d4 2020-07-23 stsp gamma/delta
1255 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1256 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1257 88fb31d4 2020-07-23 stsp EOF
1258 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1259 49c543a6 2022-03-31 naddy ret=$?
1260 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1261 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1262 88fb31d4 2020-07-23 stsp fi
1263 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1264 5a1fbc73 2020-07-23 stsp }
1265 5a1fbc73 2020-07-23 stsp
1266 f6cae3ed 2020-09-13 naddy test_commit_fix_bad_symlink() {
1267 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1268 5a1fbc73 2020-07-23 stsp
1269 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1270 49c543a6 2022-03-31 naddy ret=$?
1271 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1272 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1273 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1274 5a1fbc73 2020-07-23 stsp return 1
1275 5a1fbc73 2020-07-23 stsp fi
1276 5a1fbc73 2020-07-23 stsp
1277 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1278 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1279 5a1fbc73 2020-07-23 stsp
1280 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1281 35213c7c 2020-07-23 stsp > $testroot/stdout)
1282 5a1fbc73 2020-07-23 stsp
1283 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1284 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1285 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1286 75f0a0fb 2020-07-23 stsp return 1
1287 75f0a0fb 2020-07-23 stsp fi
1288 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1289 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1290 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1291 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1292 5a1fbc73 2020-07-23 stsp return 1
1293 5a1fbc73 2020-07-23 stsp fi
1294 5a1fbc73 2020-07-23 stsp
1295 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1296 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1297 49c543a6 2022-03-31 naddy ret=$?
1298 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1299 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1300 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1301 5a1fbc73 2020-07-23 stsp return 1
1302 5a1fbc73 2020-07-23 stsp fi
1303 5a1fbc73 2020-07-23 stsp
1304 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1305 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -sfh alpha passwd.link)
1306 5a1fbc73 2020-07-23 stsp
1307 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1308 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1309 5a1fbc73 2020-07-23 stsp
1310 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1311 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1312 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1313 5a1fbc73 2020-07-23 stsp
1314 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1315 49c543a6 2022-03-31 naddy ret=$?
1316 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1317 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1318 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1319 bd6aa359 2020-07-23 stsp return 1
1320 bd6aa359 2020-07-23 stsp fi
1321 5a1fbc73 2020-07-23 stsp
1322 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1323 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1324 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1325 5a1fbc73 2020-07-23 stsp return 1
1326 5a1fbc73 2020-07-23 stsp fi
1327 5a1fbc73 2020-07-23 stsp
1328 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1329 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1330 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1331 49c543a6 2022-03-31 naddy ret=$?
1332 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1333 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1334 5a1fbc73 2020-07-23 stsp return 1
1335 5a1fbc73 2020-07-23 stsp fi
1336 5a1fbc73 2020-07-23 stsp
1337 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1338 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1339 49c543a6 2022-03-31 naddy ret=$?
1340 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1341 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1342 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1343 5a1fbc73 2020-07-23 stsp return 1
1344 5a1fbc73 2020-07-23 stsp fi
1345 5a1fbc73 2020-07-23 stsp
1346 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1347 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1348 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1349 5a1fbc73 2020-07-23 stsp return 1
1350 5a1fbc73 2020-07-23 stsp fi
1351 5a1fbc73 2020-07-23 stsp
1352 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1353 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1354 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1355 49c543a6 2022-03-31 naddy ret=$?
1356 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1357 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1358 5a1fbc73 2020-07-23 stsp return 1
1359 5a1fbc73 2020-07-23 stsp fi
1360 5a1fbc73 2020-07-23 stsp
1361 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1362 1ebedb77 2019-10-19 stsp }
1363 28cf319f 2021-01-28 stsp
1364 28cf319f 2021-01-28 stsp test_commit_prepared_logmsg() {
1365 28cf319f 2021-01-28 stsp local testroot=`test_init commit_prepared_logmsg`
1366 28cf319f 2021-01-28 stsp
1367 28cf319f 2021-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1368 49c543a6 2022-03-31 naddy ret=$?
1369 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1370 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1371 28cf319f 2021-01-28 stsp return 1
1372 28cf319f 2021-01-28 stsp fi
1373 28cf319f 2021-01-28 stsp
1374 28cf319f 2021-01-28 stsp echo "modified alpha" > $testroot/wt/alpha
1375 28cf319f 2021-01-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
1376 28cf319f 2021-01-28 stsp echo "new file" > $testroot/wt/new
1377 28cf319f 2021-01-28 stsp (cd $testroot/wt && got add new >/dev/null)
1378 28cf319f 2021-01-28 stsp
1379 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg' > $testroot/logmsg
1380 28cf319f 2021-01-28 stsp
1381 28cf319f 2021-01-28 stsp cat > $testroot/editor.sh <<EOF
1382 28cf319f 2021-01-28 stsp #!/bin/sh
1383 28cf319f 2021-01-28 stsp sed -i 's/foo/bar/' "\$1"
1384 28cf319f 2021-01-28 stsp EOF
1385 28cf319f 2021-01-28 stsp chmod +x $testroot/editor.sh
1386 28cf319f 2021-01-28 stsp
1387 8e09a168 2021-06-17 tracey (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1388 28cf319f 2021-01-28 stsp got commit -F "$testroot/logmsg" > $testroot/stdout)
1389 1ebedb77 2019-10-19 stsp
1390 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1391 28cf319f 2021-01-28 stsp echo "A new" > $testroot/stdout.expected
1392 28cf319f 2021-01-28 stsp echo "M alpha" >> $testroot/stdout.expected
1393 28cf319f 2021-01-28 stsp echo "D beta" >> $testroot/stdout.expected
1394 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1395 28cf319f 2021-01-28 stsp
1396 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1397 49c543a6 2022-03-31 naddy ret=$?
1398 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1399 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1400 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1401 28cf319f 2021-01-28 stsp return 1
1402 28cf319f 2021-01-28 stsp fi
1403 28cf319f 2021-01-28 stsp
1404 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1405 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1406 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" > $testroot/stdout.expected
1407 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1408 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1409 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1410 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1411 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1412 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1413 28cf319f 2021-01-28 stsp
1414 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1415 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1416 49c543a6 2022-03-31 naddy ret=$?
1417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1418 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1419 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1420 28cf319f 2021-01-28 stsp return 1
1421 28cf319f 2021-01-28 stsp fi
1422 28cf319f 2021-01-28 stsp
1423 28cf319f 2021-01-28 stsp echo "modified alpha again" > $testroot/wt/alpha
1424 28cf319f 2021-01-28 stsp
1425 28cf319f 2021-01-28 stsp echo 'test commit_prepared_logmsg non-interactive' \
1426 28cf319f 2021-01-28 stsp > $testroot/logmsg
1427 28cf319f 2021-01-28 stsp
1428 28cf319f 2021-01-28 stsp (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1429 28cf319f 2021-01-28 stsp > $testroot/stdout)
1430 28cf319f 2021-01-28 stsp
1431 28cf319f 2021-01-28 stsp local head_rev=`git_show_head $testroot/repo`
1432 28cf319f 2021-01-28 stsp echo "M alpha" > $testroot/stdout.expected
1433 28cf319f 2021-01-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1434 28cf319f 2021-01-28 stsp
1435 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1436 49c543a6 2022-03-31 naddy ret=$?
1437 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1438 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1439 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1440 28cf319f 2021-01-28 stsp return 1
1441 28cf319f 2021-01-28 stsp fi
1442 28cf319f 2021-01-28 stsp
1443 28cf319f 2021-01-28 stsp local author_time=`git_show_author_time $testroot/repo`
1444 3a6b8760 2021-08-31 naddy d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1445 28cf319f 2021-01-28 stsp echo "-----------------------------------------------" \
1446 28cf319f 2021-01-28 stsp > $testroot/stdout.expected
1447 28cf319f 2021-01-28 stsp echo "commit $head_rev (master)" >> $testroot/stdout.expected
1448 28cf319f 2021-01-28 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1449 28cf319f 2021-01-28 stsp echo "date: $d" >> $testroot/stdout.expected
1450 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1451 28cf319f 2021-01-28 stsp echo " test commit_prepared_logmsg non-interactive" \
1452 28cf319f 2021-01-28 stsp >> $testroot/stdout.expected
1453 28cf319f 2021-01-28 stsp echo " " >> $testroot/stdout.expected
1454 28cf319f 2021-01-28 stsp
1455 28cf319f 2021-01-28 stsp (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1456 28cf319f 2021-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1457 49c543a6 2022-03-31 naddy ret=$?
1458 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1459 28cf319f 2021-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1460 28cf319f 2021-01-28 stsp fi
1461 28cf319f 2021-01-28 stsp test_done "$testroot" "$ret"
1462 28cf319f 2021-01-28 stsp }
1463 72840534 2022-01-19 stsp
1464 72840534 2022-01-19 stsp test_commit_large_file() {
1465 72840534 2022-01-19 stsp local testroot=`test_init commit_large_file`
1466 72840534 2022-01-19 stsp
1467 72840534 2022-01-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1468 49c543a6 2022-03-31 naddy ret=$?
1469 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1470 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1471 72840534 2022-01-19 stsp return 1
1472 72840534 2022-01-19 stsp fi
1473 72840534 2022-01-19 stsp
1474 230e1f1b 2022-07-05 stsp dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1475 72840534 2022-01-19 stsp (cd $testroot/wt && got add new >/dev/null)
1476 28cf319f 2021-01-28 stsp
1477 72840534 2022-01-19 stsp (cd $testroot/wt && got commit -m 'test commit_large_file' \
1478 72840534 2022-01-19 stsp > $testroot/stdout)
1479 72840534 2022-01-19 stsp
1480 72840534 2022-01-19 stsp local head_rev=`git_show_head $testroot/repo`
1481 72840534 2022-01-19 stsp echo "A new" > $testroot/stdout.expected
1482 72840534 2022-01-19 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1483 72840534 2022-01-19 stsp
1484 72840534 2022-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1485 49c543a6 2022-03-31 naddy ret=$?
1486 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1487 72840534 2022-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1488 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1489 72840534 2022-01-19 stsp return 1
1490 72840534 2022-01-19 stsp fi
1491 72840534 2022-01-19 stsp
1492 72840534 2022-01-19 stsp new_id=`get_blob_id $testroot/repo "" new`
1493 72840534 2022-01-19 stsp got cat -r $testroot/repo $new_id > $testroot/new
1494 49c543a6 2022-03-31 naddy ret=$?
1495 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1496 72840534 2022-01-19 stsp echo "commit failed unexpectedly" >&2
1497 72840534 2022-01-19 stsp test_done "$testroot" "1"
1498 72840534 2022-01-19 stsp return 1
1499 72840534 2022-01-19 stsp fi
1500 72840534 2022-01-19 stsp
1501 72840534 2022-01-19 stsp cmp -s $testroot/new $testroot/wt/new
1502 49c543a6 2022-03-31 naddy ret=$?
1503 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1504 72840534 2022-01-19 stsp diff -u $testroot/new $testroot/wt/new
1505 72840534 2022-01-19 stsp fi
1506 72840534 2022-01-19 stsp test_done "$testroot" "$ret"
1507 72840534 2022-01-19 stsp
1508 72840534 2022-01-19 stsp
1509 72840534 2022-01-19 stsp }
1510 72840534 2022-01-19 stsp
1511 72840534 2022-01-19 stsp
1512 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1513 c4296144 2019-05-09 stsp run_test test_commit_basic
1514 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
1515 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
1516 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
1517 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
1518 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
1519 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
1520 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
1521 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
1522 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
1523 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
1524 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
1525 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
1526 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
1527 84792843 2019-08-09 stsp run_test test_commit_no_email
1528 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
1529 257add31 2020-09-09 stsp run_test test_commit_gotconfig_author
1530 50b0790e 2020-09-11 stsp run_test test_commit_gotconfig_worktree_author
1531 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
1532 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
1533 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
1534 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
1535 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
1536 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink
1537 28cf319f 2021-01-28 stsp run_test test_commit_prepared_logmsg
1538 72840534 2022-01-19 stsp run_test test_commit_large_file