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 c4296144 2019-05-09 stsp function 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 c4296144 2019-05-09 stsp ret="$?"
24 c4296144 2019-05-09 stsp if [ "$ret" != "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 c4296144 2019-05-09 stsp ret="$?"
44 c4296144 2019-05-09 stsp if [ "$ret" != "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 baa7dcfa 2019-05-09 stsp function 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 baa7dcfa 2019-05-09 stsp ret="$?"
55 baa7dcfa 2019-05-09 stsp if [ "$ret" != "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 baa7dcfa 2019-05-09 stsp ret="$?"
76 baa7dcfa 2019-05-09 stsp if [ "$ret" != "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 bc70eb79 2019-05-09 stsp function 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 bc70eb79 2019-05-09 stsp ret="$?"
87 bc70eb79 2019-05-09 stsp if [ "$ret" != "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 bc70eb79 2019-05-09 stsp ret="$?"
104 bc70eb79 2019-05-09 stsp if [ "$ret" != "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 5bbcb68b 2019-05-09 stsp function 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 5bbcb68b 2019-05-09 stsp ret="$?"
115 5bbcb68b 2019-05-09 stsp if [ "$ret" != "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 5bbcb68b 2019-05-09 stsp ret="$?"
132 5bbcb68b 2019-05-09 stsp if [ "$ret" != "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 819f385b 2019-05-10 stsp function 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 819f385b 2019-05-10 stsp ret="$?"
144 819f385b 2019-05-10 stsp if [ "$ret" != "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 819f385b 2019-05-10 stsp ret="$?"
163 819f385b 2019-05-10 stsp if [ "$ret" != "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 819f385b 2019-05-10 stsp ret="$?"
171 819f385b 2019-05-10 stsp if [ "$ret" != "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 f0b75401 2019-08-03 stsp ret="$?"
185 f0b75401 2019-08-03 stsp if [ "$ret" != "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 f0b75401 2019-08-03 stsp ret="$?"
196 f0b75401 2019-08-03 stsp if [ "$ret" != "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 8ba6ba2d 2019-05-14 stsp function 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 8ba6ba2d 2019-05-14 stsp ret="$?"
207 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "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 ba580f68 2020-03-22 stsp ret="$?"
235 ba580f68 2020-03-22 stsp if [ "$ret" != "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 ba580f68 2020-03-22 stsp function 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 ba580f68 2020-03-22 stsp ret="$?"
246 ba580f68 2020-03-22 stsp if [ "$ret" != "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 ba580f68 2020-03-22 stsp (cd $testroot/wt && got rm -R $testroot/wt/{epsilon,gamma} >/dev/null)
252 ba580f68 2020-03-22 stsp
253 ba580f68 2020-03-22 stsp (cd $testroot/wt && got commit -m 'test commit_deleted_subdirs' \
254 ba580f68 2020-03-22 stsp > $testroot/stdout 2> $testroot/stderr)
255 ba580f68 2020-03-22 stsp
256 ba580f68 2020-03-22 stsp local head_rev=`git_show_head $testroot/repo`
257 ba580f68 2020-03-22 stsp echo "D epsilon/zeta" > $testroot/stdout.expected
258 ba580f68 2020-03-22 stsp echo "D gamma/delta" >> $testroot/stdout.expected
259 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
260 ba580f68 2020-03-22 stsp
261 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
262 ba580f68 2020-03-22 stsp ret="$?"
263 ba580f68 2020-03-22 stsp if [ "$ret" != "0" ]; then
264 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
265 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
266 ba580f68 2020-03-22 stsp return 1
267 ba580f68 2020-03-22 stsp fi
268 8ba6ba2d 2019-05-14 stsp
269 ba580f68 2020-03-22 stsp got tree -r $testroot/repo > $testroot/stdout
270 ba580f68 2020-03-22 stsp
271 ba580f68 2020-03-22 stsp echo "alpha" > $testroot/stdout.expected
272 ba580f68 2020-03-22 stsp echo "beta" >> $testroot/stdout.expected
273 ba580f68 2020-03-22 stsp
274 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
275 8ba6ba2d 2019-05-14 stsp ret="$?"
276 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
277 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
278 8ba6ba2d 2019-05-14 stsp fi
279 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
280 8ba6ba2d 2019-05-14 stsp }
281 8ba6ba2d 2019-05-14 stsp
282 f363d663 2019-05-23 stsp function test_commit_rejects_conflicted_file {
283 461aee03 2019-06-29 stsp local testroot=`test_init commit_rejects_conflicted_file`
284 f363d663 2019-05-23 stsp
285 f363d663 2019-05-23 stsp local initial_rev=`git_show_head $testroot/repo`
286 f363d663 2019-05-23 stsp
287 f363d663 2019-05-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
288 f363d663 2019-05-23 stsp ret="$?"
289 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
290 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
291 f363d663 2019-05-23 stsp return 1
292 f363d663 2019-05-23 stsp fi
293 f363d663 2019-05-23 stsp
294 f363d663 2019-05-23 stsp echo "modified alpha" > $testroot/wt/alpha
295 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
296 f363d663 2019-05-23 stsp
297 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
298 f363d663 2019-05-23 stsp
299 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
300 f363d663 2019-05-23 stsp
301 f363d663 2019-05-23 stsp echo "C alpha" > $testroot/stdout.expected
302 f363d663 2019-05-23 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
303 f363d663 2019-05-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
304 f363d663 2019-05-23 stsp echo >> $testroot/stdout.expected
305 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
306 f363d663 2019-05-23 stsp
307 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
308 f363d663 2019-05-23 stsp
309 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
310 f363d663 2019-05-23 stsp ret="$?"
311 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
312 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
313 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
314 f363d663 2019-05-23 stsp return 1
315 f363d663 2019-05-23 stsp fi
316 f363d663 2019-05-23 stsp
317 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
318 f363d663 2019-05-23 stsp 2> $testroot/stderr)
319 f363d663 2019-05-23 stsp
320 f363d663 2019-05-23 stsp echo -n > $testroot/stdout.expected
321 f363d663 2019-05-23 stsp echo "got: cannot commit file in conflicted status" \
322 f363d663 2019-05-23 stsp > $testroot/stderr.expected
323 f363d663 2019-05-23 stsp
324 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
325 f363d663 2019-05-23 stsp ret="$?"
326 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
327 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
329 f363d663 2019-05-23 stsp return 1
330 f363d663 2019-05-23 stsp fi
331 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
332 f363d663 2019-05-23 stsp ret="$?"
333 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
334 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
335 f363d663 2019-05-23 stsp fi
336 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
337 f363d663 2019-05-23 stsp }
338 1a36436d 2019-06-10 stsp
339 1a36436d 2019-06-10 stsp function test_commit_single_file_multiple {
340 1a36436d 2019-06-10 stsp local testroot=`test_init commit_single_file_multiple`
341 f363d663 2019-05-23 stsp
342 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
343 1a36436d 2019-06-10 stsp ret="$?"
344 1a36436d 2019-06-10 stsp if [ "$ret" != "0" ]; then
345 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
346 1a36436d 2019-06-10 stsp return 1
347 1a36436d 2019-06-10 stsp fi
348 1a36436d 2019-06-10 stsp
349 1a36436d 2019-06-10 stsp for i in 1 2 3 4; do
350 1a36436d 2019-06-10 stsp echo "modified alpha" >> $testroot/wt/alpha
351 1a36436d 2019-06-10 stsp
352 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
353 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
354 1a36436d 2019-06-10 stsp
355 1a36436d 2019-06-10 stsp local head_rev=`git_show_head $testroot/repo`
356 1a36436d 2019-06-10 stsp echo "M alpha" > $testroot/stdout.expected
357 1a36436d 2019-06-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
358 1a36436d 2019-06-10 stsp
359 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
360 1a36436d 2019-06-10 stsp ret="$?"
361 1a36436d 2019-06-10 stsp if [ "$ret" != "0" ]; then
362 1a36436d 2019-06-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
363 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
364 1a36436d 2019-06-10 stsp return 1
365 1a36436d 2019-06-10 stsp fi
366 1a36436d 2019-06-10 stsp done
367 1a36436d 2019-06-10 stsp
368 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
369 1a36436d 2019-06-10 stsp }
370 4866d084 2019-07-10 stsp
371 4866d084 2019-07-10 stsp function test_commit_added_and_modified_in_same_dir {
372 4866d084 2019-07-10 stsp local testroot=`test_init commit_added_and_modified_in_same_dir`
373 1a36436d 2019-06-10 stsp
374 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
375 4866d084 2019-07-10 stsp ret="$?"
376 4866d084 2019-07-10 stsp if [ "$ret" != "0" ]; then
377 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
378 4866d084 2019-07-10 stsp return 1
379 4866d084 2019-07-10 stsp fi
380 4866d084 2019-07-10 stsp
381 4866d084 2019-07-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
382 4866d084 2019-07-10 stsp echo "new file" > $testroot/wt/epsilon/new
383 4866d084 2019-07-10 stsp (cd $testroot/wt && got add epsilon/new >/dev/null)
384 4866d084 2019-07-10 stsp
385 4866d084 2019-07-10 stsp (cd $testroot/wt && got commit \
386 4866d084 2019-07-10 stsp -m 'added and modified in same dir' > $testroot/stdout \
387 4866d084 2019-07-10 stsp 2> $testroot/stderr)
388 4866d084 2019-07-10 stsp
389 4866d084 2019-07-10 stsp local head_rev=`git_show_head $testroot/repo`
390 4866d084 2019-07-10 stsp echo "A epsilon/new" > $testroot/stdout.expected
391 4866d084 2019-07-10 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
392 4866d084 2019-07-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
393 e0233cea 2019-07-25 stsp
394 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
395 e0233cea 2019-07-25 stsp ret="$?"
396 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
397 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
398 e0233cea 2019-07-25 stsp fi
399 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
400 e0233cea 2019-07-25 stsp }
401 e0233cea 2019-07-25 stsp
402 e0233cea 2019-07-25 stsp function test_commit_path_prefix {
403 e0233cea 2019-07-25 stsp local testroot=`test_init commit_path_prefix`
404 e0233cea 2019-07-25 stsp local commit1=`git_show_head $testroot/repo`
405 e0233cea 2019-07-25 stsp
406 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
407 e0233cea 2019-07-25 stsp ret="$?"
408 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
409 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
410 e0233cea 2019-07-25 stsp return 1
411 e0233cea 2019-07-25 stsp fi
412 e0233cea 2019-07-25 stsp
413 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
414 e0233cea 2019-07-25 stsp
415 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
416 e0233cea 2019-07-25 stsp
417 e0233cea 2019-07-25 stsp local commit2=`git_show_head $testroot/repo`
418 e0233cea 2019-07-25 stsp echo "M delta" > $testroot/stdout.expected
419 e0233cea 2019-07-25 stsp echo "Created commit $commit2" >> $testroot/stdout.expected
420 4866d084 2019-07-10 stsp
421 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
422 4866d084 2019-07-10 stsp ret="$?"
423 4866d084 2019-07-10 stsp if [ "$ret" != "0" ]; then
424 2b496619 2019-07-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
425 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
426 e0233cea 2019-07-25 stsp return 1
427 4866d084 2019-07-10 stsp fi
428 e0233cea 2019-07-25 stsp
429 e0233cea 2019-07-25 stsp echo "diff $commit1 $commit2" > $testroot/stdout.expected
430 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
431 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
432 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $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 $commit2 -i gamma | grep 'delta$' | \
435 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
436 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
437 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
438 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
439 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
440 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
441 e0233cea 2019-07-25 stsp
442 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
443 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
444 e0233cea 2019-07-25 stsp ret="$?"
445 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
446 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
447 e0233cea 2019-07-25 stsp fi
448 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
449 4866d084 2019-07-10 stsp }
450 90e8619e 2019-07-25 stsp
451 90e8619e 2019-07-25 stsp function test_commit_dir_path {
452 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
453 4866d084 2019-07-10 stsp
454 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
455 90e8619e 2019-07-25 stsp ret="$?"
456 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
457 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
458 90e8619e 2019-07-25 stsp return 1
459 90e8619e 2019-07-25 stsp fi
460 90e8619e 2019-07-25 stsp
461 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
462 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
463 90e8619e 2019-07-25 stsp
464 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
465 90e8619e 2019-07-25 stsp > $testroot/stdout)
466 90e8619e 2019-07-25 stsp
467 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
468 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
469 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
470 90e8619e 2019-07-25 stsp
471 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
472 90e8619e 2019-07-25 stsp ret="$?"
473 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
474 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
475 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
476 90e8619e 2019-07-25 stsp return 1
477 90e8619e 2019-07-25 stsp fi
478 90e8619e 2019-07-25 stsp
479 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
480 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
481 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
482 90e8619e 2019-07-25 stsp ret="$?"
483 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
484 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
485 90e8619e 2019-07-25 stsp fi
486 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
487 90e8619e 2019-07-25 stsp }
488 5c1e53bc 2019-07-28 stsp
489 5c1e53bc 2019-07-28 stsp function test_commit_selected_paths {
490 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
491 5c1e53bc 2019-07-28 stsp
492 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
493 5c1e53bc 2019-07-28 stsp ret="$?"
494 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
495 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
496 5c1e53bc 2019-07-28 stsp return 1
497 5c1e53bc 2019-07-28 stsp fi
498 5c1e53bc 2019-07-28 stsp
499 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
500 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
501 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
502 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
503 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
504 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
505 90e8619e 2019-07-25 stsp
506 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
507 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
508 5c1e53bc 2019-07-28 stsp ret="$?"
509 5c1e53bc 2019-07-28 stsp if [ "$ret" == "0" ]; then
510 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
511 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
512 5c1e53bc 2019-07-28 stsp return 1
513 5c1e53bc 2019-07-28 stsp fi
514 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
515 5c1e53bc 2019-07-28 stsp
516 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
517 5c1e53bc 2019-07-28 stsp ret="$?"
518 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
519 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
520 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
521 5c1e53bc 2019-07-28 stsp return 1
522 5c1e53bc 2019-07-28 stsp fi
523 5c1e53bc 2019-07-28 stsp
524 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
525 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
526 5c1e53bc 2019-07-28 stsp
527 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
528 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
529 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
530 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
531 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
532 5c1e53bc 2019-07-28 stsp
533 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
534 5c1e53bc 2019-07-28 stsp ret="$?"
535 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
536 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
537 5c1e53bc 2019-07-28 stsp fi
538 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
539 5c1e53bc 2019-07-28 stsp }
540 5c1e53bc 2019-07-28 stsp
541 916f288c 2019-07-30 stsp function test_commit_outside_refs_heads {
542 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
543 916f288c 2019-07-30 stsp
544 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
545 916f288c 2019-07-30 stsp
546 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
547 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
548 916f288c 2019-07-30 stsp ret="$?"
549 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
550 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
551 916f288c 2019-07-30 stsp return 1
552 916f288c 2019-07-30 stsp fi
553 916f288c 2019-07-30 stsp
554 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
555 916f288c 2019-07-30 stsp
556 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
557 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
558 916f288c 2019-07-30 stsp ret="$?"
559 916f288c 2019-07-30 stsp if [ "$ret" == "0" ]; then
560 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
561 916f288c 2019-07-30 stsp test_done "$testroot" "1"
562 916f288c 2019-07-30 stsp return 1
563 916f288c 2019-07-30 stsp fi
564 916f288c 2019-07-30 stsp
565 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
566 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
567 916f288c 2019-07-30 stsp ret="$?"
568 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
569 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
570 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
571 916f288c 2019-07-30 stsp return 1
572 916f288c 2019-07-30 stsp fi
573 916f288c 2019-07-30 stsp
574 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
575 916f288c 2019-07-30 stsp > $testroot/stderr.expected
576 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
577 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
578 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
579 916f288c 2019-07-30 stsp ret="$?"
580 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
581 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
582 916f288c 2019-07-30 stsp fi
583 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
584 916f288c 2019-07-30 stsp }
585 916f288c 2019-07-30 stsp
586 84792843 2019-08-09 stsp function test_commit_no_email {
587 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
588 916f288c 2019-07-30 stsp
589 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
590 84792843 2019-08-09 stsp ret="$?"
591 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
592 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
593 84792843 2019-08-09 stsp return 1
594 84792843 2019-08-09 stsp fi
595 84792843 2019-08-09 stsp
596 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
597 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
598 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
599 84792843 2019-08-09 stsp 2> $testroot/stderr)
600 84792843 2019-08-09 stsp
601 84792843 2019-08-09 stsp echo -n "got: GOT_AUTHOR environment variable contains no email " \
602 84792843 2019-08-09 stsp > $testroot/stderr.expected
603 84792843 2019-08-09 stsp echo -n "address; an email address is required for compatibility "\
604 84792843 2019-08-09 stsp >> $testroot/stderr.expected
605 84792843 2019-08-09 stsp echo "with Git" >> $testroot/stderr.expected
606 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
607 84792843 2019-08-09 stsp ret="$?"
608 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
609 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
610 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
611 84792843 2019-08-09 stsp return 1
612 84792843 2019-08-09 stsp fi
613 84792843 2019-08-09 stsp
614 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
615 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
616 84792843 2019-08-09 stsp ret="$?"
617 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
618 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
619 84792843 2019-08-09 stsp fi
620 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
621 84792843 2019-08-09 stsp }
622 6af1ccbd 2019-08-16 stsp
623 6af1ccbd 2019-08-16 stsp function test_commit_tree_entry_sorting {
624 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
625 6af1ccbd 2019-08-16 stsp
626 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
627 6af1ccbd 2019-08-16 stsp ret="$?"
628 6af1ccbd 2019-08-16 stsp if [ "$ret" != "0" ]; then
629 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
630 6af1ccbd 2019-08-16 stsp return 1
631 6af1ccbd 2019-08-16 stsp fi
632 6af1ccbd 2019-08-16 stsp
633 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
634 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
635 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
636 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
637 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
638 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
639 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
640 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
641 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
642 84792843 2019-08-09 stsp
643 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
644 84792843 2019-08-09 stsp
645 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
646 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
647 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
648 6af1ccbd 2019-08-16 stsp ret="$?"
649 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
650 6af1ccbd 2019-08-16 stsp }
651 aba9c984 2019-09-08 stsp
652 aba9c984 2019-09-08 stsp function test_commit_gitconfig_author {
653 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
654 84792843 2019-08-09 stsp
655 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
656 aba9c984 2019-09-08 stsp ret="$?"
657 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
658 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
659 aba9c984 2019-09-08 stsp return 1
660 aba9c984 2019-09-08 stsp fi
661 aba9c984 2019-09-08 stsp
662 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
663 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
664 aba9c984 2019-09-08 stsp
665 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
666 aba9c984 2019-09-08 stsp (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
667 aba9c984 2019-09-08 stsp ret="$?"
668 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
669 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
670 aba9c984 2019-09-08 stsp return 1
671 aba9c984 2019-09-08 stsp fi
672 aba9c984 2019-09-08 stsp
673 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
674 aba9c984 2019-09-08 stsp ret="$?"
675 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
676 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
677 aba9c984 2019-09-08 stsp return 1
678 aba9c984 2019-09-08 stsp fi
679 aba9c984 2019-09-08 stsp
680 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
681 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
682 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
683 aba9c984 2019-09-08 stsp ret="$?"
684 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
685 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
686 aba9c984 2019-09-08 stsp fi
687 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
688 aba9c984 2019-09-08 stsp }
689 1ebedb77 2019-10-19 stsp
690 1ebedb77 2019-10-19 stsp function test_commit_xbit_change {
691 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
692 1ebedb77 2019-10-19 stsp
693 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
694 1ebedb77 2019-10-19 stsp ret="$?"
695 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
696 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
697 1ebedb77 2019-10-19 stsp return 1
698 1ebedb77 2019-10-19 stsp fi
699 1ebedb77 2019-10-19 stsp
700 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
701 1ebedb77 2019-10-19 stsp
702 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
703 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
704 aba9c984 2019-09-08 stsp
705 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
706 1ebedb77 2019-10-19 stsp ret="$?"
707 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
708 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
709 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
710 1ebedb77 2019-10-19 stsp return 1
711 1ebedb77 2019-10-19 stsp fi
712 1ebedb77 2019-10-19 stsp
713 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
714 1ebedb77 2019-10-19 stsp ret="$?"
715 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
716 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
717 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
718 1ebedb77 2019-10-19 stsp return 1
719 1ebedb77 2019-10-19 stsp fi
720 1ebedb77 2019-10-19 stsp
721 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
722 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
723 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
724 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
725 1ebedb77 2019-10-19 stsp ret="$?"
726 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
727 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
728 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
729 1ebedb77 2019-10-19 stsp return 1
730 1ebedb77 2019-10-19 stsp fi
731 1ebedb77 2019-10-19 stsp
732 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
733 1ebedb77 2019-10-19 stsp
734 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
735 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
736 1ebedb77 2019-10-19 stsp ret="$?"
737 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
738 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
739 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
740 1ebedb77 2019-10-19 stsp return 1
741 1ebedb77 2019-10-19 stsp fi
742 1ebedb77 2019-10-19 stsp
743 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
744 1ebedb77 2019-10-19 stsp
745 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
746 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
747 1ebedb77 2019-10-19 stsp
748 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
749 1ebedb77 2019-10-19 stsp ret="$?"
750 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
751 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
752 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
753 1ebedb77 2019-10-19 stsp return 1
754 1ebedb77 2019-10-19 stsp fi
755 1ebedb77 2019-10-19 stsp
756 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
757 1ebedb77 2019-10-19 stsp ret="$?"
758 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
759 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
760 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
761 1ebedb77 2019-10-19 stsp return 1
762 1ebedb77 2019-10-19 stsp fi
763 1ebedb77 2019-10-19 stsp
764 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
765 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
766 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
767 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
768 1ebedb77 2019-10-19 stsp ret="$?"
769 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
770 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
771 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
772 1ebedb77 2019-10-19 stsp return 1
773 1ebedb77 2019-10-19 stsp fi
774 1ebedb77 2019-10-19 stsp
775 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
776 1ebedb77 2019-10-19 stsp
777 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
778 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
779 f7b97ccb 2020-04-14 stsp
780 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
781 f7b97ccb 2020-04-14 stsp ret="$?"
782 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
783 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
784 f7b97ccb 2020-04-14 stsp fi
785 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
786 f7b97ccb 2020-04-14 stsp }
787 f7b97ccb 2020-04-14 stsp
788 f7b97ccb 2020-04-14 stsp function commit_check_mode {
789 f7b97ccb 2020-04-14 stsp local mode="$1"
790 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
791 f7b97ccb 2020-04-14 stsp
792 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
793 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
794 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
795 f7b97ccb 2020-04-14 stsp
796 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
797 f7b97ccb 2020-04-14 stsp ret="$?"
798 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
799 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
800 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
801 f7b97ccb 2020-04-14 stsp return 1
802 f7b97ccb 2020-04-14 stsp fi
803 1ebedb77 2019-10-19 stsp
804 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
805 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
806 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
807 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
808 f7b97ccb 2020-04-14 stsp ret="$?"
809 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
810 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
811 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
812 f7b97ccb 2020-04-14 stsp fi
813 f7b97ccb 2020-04-14 stsp
814 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
815 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
816 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
817 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
818 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
819 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
820 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
821 1ebedb77 2019-10-19 stsp ret="$?"
822 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
823 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
824 1ebedb77 2019-10-19 stsp fi
825 f7b97ccb 2020-04-14 stsp return $ret
826 f7b97ccb 2020-04-14 stsp }
827 f7b97ccb 2020-04-14 stsp
828 f7b97ccb 2020-04-14 stsp function test_commit_normalizes_filemodes {
829 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
830 f7b97ccb 2020-04-14 stsp
831 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
832 f7b97ccb 2020-04-14 stsp ret="$?"
833 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
834 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
835 f7b97ccb 2020-04-14 stsp return 1
836 f7b97ccb 2020-04-14 stsp fi
837 f7b97ccb 2020-04-14 stsp
838 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
839 f7b97ccb 2020-04-14 stsp for m in $modes; do
840 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
841 cb35d58a 2020-04-14 stsp ret="$?"
842 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
843 f7b97ccb 2020-04-14 stsp break
844 f7b97ccb 2020-04-14 stsp fi
845 f7b97ccb 2020-04-14 stsp done
846 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
847 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
848 f7b97ccb 2020-04-14 stsp return 1
849 f7b97ccb 2020-04-14 stsp fi
850 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
851 f7b97ccb 2020-04-14 stsp for m in $modes; do
852 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
853 cb35d58a 2020-04-14 stsp ret="$?"
854 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
855 f7b97ccb 2020-04-14 stsp break
856 f7b97ccb 2020-04-14 stsp fi
857 f7b97ccb 2020-04-14 stsp done
858 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
859 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
860 f7b97ccb 2020-04-14 stsp return 1
861 f7b97ccb 2020-04-14 stsp fi
862 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
863 1ebedb77 2019-10-19 stsp }
864 1ebedb77 2019-10-19 stsp
865 c4296144 2019-05-09 stsp run_test test_commit_basic
866 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
867 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
868 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
869 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
870 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
871 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
872 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
873 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
874 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
875 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
876 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
877 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
878 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
879 84792843 2019-08-09 stsp run_test test_commit_no_email
880 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
881 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
882 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
883 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes