Blame


1 fccbfb98 2019-08-03 stsp #!/bin/sh
2 fccbfb98 2019-08-03 stsp #
3 fccbfb98 2019-08-03 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 fccbfb98 2019-08-03 stsp #
5 fccbfb98 2019-08-03 stsp # Permission to use, copy, modify, and distribute this software for any
6 fccbfb98 2019-08-03 stsp # purpose with or without fee is hereby granted, provided that the above
7 fccbfb98 2019-08-03 stsp # copyright notice and this permission notice appear in all copies.
8 fccbfb98 2019-08-03 stsp #
9 fccbfb98 2019-08-03 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 fccbfb98 2019-08-03 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 fccbfb98 2019-08-03 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 fccbfb98 2019-08-03 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 fccbfb98 2019-08-03 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 fccbfb98 2019-08-03 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 fccbfb98 2019-08-03 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 fccbfb98 2019-08-03 stsp
17 fccbfb98 2019-08-03 stsp . ./common.sh
18 fccbfb98 2019-08-03 stsp
19 fccbfb98 2019-08-03 stsp function test_stage_basic {
20 fccbfb98 2019-08-03 stsp local testroot=`test_init stage_basic`
21 fccbfb98 2019-08-03 stsp
22 fccbfb98 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 fccbfb98 2019-08-03 stsp ret="$?"
24 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
25 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
26 fccbfb98 2019-08-03 stsp return 1
27 fccbfb98 2019-08-03 stsp fi
28 fccbfb98 2019-08-03 stsp
29 fccbfb98 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
30 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
31 fccbfb98 2019-08-03 stsp echo "new file" > $testroot/wt/foo
32 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
33 fccbfb98 2019-08-03 stsp
34 88d0e355 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
35 88d0e355 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
36 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
37 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
38 d3e7c587 2019-08-03 stsp
39 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
40 d3e7c587 2019-08-03 stsp ret="$?"
41 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
42 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
43 d3e7c587 2019-08-03 stsp fi
44 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
45 d3e7c587 2019-08-03 stsp }
46 d3e7c587 2019-08-03 stsp
47 a4f692bb 2019-08-04 stsp function test_stage_list {
48 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
49 a4f692bb 2019-08-04 stsp
50 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
51 a4f692bb 2019-08-04 stsp ret="$?"
52 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
53 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
54 a4f692bb 2019-08-04 stsp return 1
55 a4f692bb 2019-08-04 stsp fi
56 a4f692bb 2019-08-04 stsp
57 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
58 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
59 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
60 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
61 a4f692bb 2019-08-04 stsp
62 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
63 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
64 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
65 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
66 a4f692bb 2019-08-04 stsp
67 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
68 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
69 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
70 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
71 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
72 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
73 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
74 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
75 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
76 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
77 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
78 a4f692bb 2019-08-04 stsp ret="$?"
79 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
80 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
81 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
82 a4f692bb 2019-08-04 stsp return 1
83 a4f692bb 2019-08-04 stsp fi
84 a4f692bb 2019-08-04 stsp
85 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
86 a4f692bb 2019-08-04 stsp > $testroot/stdout)
87 a4f692bb 2019-08-04 stsp
88 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
89 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
90 a4f692bb 2019-08-04 stsp ret="$?"
91 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
92 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
93 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
94 a4f692bb 2019-08-04 stsp return 1
95 a4f692bb 2019-08-04 stsp fi
96 a4f692bb 2019-08-04 stsp
97 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
98 a4f692bb 2019-08-04 stsp
99 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
100 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
101 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
102 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
103 a4f692bb 2019-08-04 stsp ret="$?"
104 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
105 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
106 a4f692bb 2019-08-04 stsp fi
107 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
108 a4f692bb 2019-08-04 stsp
109 a4f692bb 2019-08-04 stsp }
110 a4f692bb 2019-08-04 stsp
111 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
112 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
113 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
114 ebf48fd5 2019-08-03 stsp
115 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
116 ebf48fd5 2019-08-03 stsp ret="$?"
117 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
118 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
119 ebf48fd5 2019-08-03 stsp return 1
120 ebf48fd5 2019-08-03 stsp fi
121 ebf48fd5 2019-08-03 stsp
122 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
123 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
124 ebf48fd5 2019-08-03 stsp
125 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
126 ebf48fd5 2019-08-03 stsp
127 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
128 ebf48fd5 2019-08-03 stsp
129 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
130 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
131 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
132 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
133 ebf48fd5 2019-08-03 stsp
134 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
135 ebf48fd5 2019-08-03 stsp
136 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
137 ebf48fd5 2019-08-03 stsp ret="$?"
138 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
139 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
140 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
141 ebf48fd5 2019-08-03 stsp return 1
142 ebf48fd5 2019-08-03 stsp fi
143 ebf48fd5 2019-08-03 stsp
144 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
145 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
146 ebf48fd5 2019-08-03 stsp ret="$?"
147 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
148 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
149 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
150 ebf48fd5 2019-08-03 stsp return 1
151 ebf48fd5 2019-08-03 stsp fi
152 ebf48fd5 2019-08-03 stsp
153 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
154 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
155 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
156 735ef5ac 2019-08-03 stsp
157 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
158 735ef5ac 2019-08-03 stsp ret="$?"
159 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
160 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
161 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
162 735ef5ac 2019-08-03 stsp return 1
163 735ef5ac 2019-08-03 stsp fi
164 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
165 735ef5ac 2019-08-03 stsp ret="$?"
166 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
167 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
168 735ef5ac 2019-08-03 stsp fi
169 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
170 735ef5ac 2019-08-03 stsp }
171 735ef5ac 2019-08-03 stsp
172 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
173 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
174 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
175 735ef5ac 2019-08-03 stsp
176 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
177 735ef5ac 2019-08-03 stsp ret="$?"
178 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
179 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
180 735ef5ac 2019-08-03 stsp return 1
181 735ef5ac 2019-08-03 stsp fi
182 735ef5ac 2019-08-03 stsp
183 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
184 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
185 735ef5ac 2019-08-03 stsp
186 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
187 735ef5ac 2019-08-03 stsp
188 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
189 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
190 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
191 735ef5ac 2019-08-03 stsp ret="$?"
192 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
193 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
194 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
195 735ef5ac 2019-08-03 stsp return 1
196 735ef5ac 2019-08-03 stsp fi
197 735ef5ac 2019-08-03 stsp
198 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
199 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
200 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
201 ebf48fd5 2019-08-03 stsp
202 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
203 ebf48fd5 2019-08-03 stsp ret="$?"
204 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
205 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
206 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
207 ebf48fd5 2019-08-03 stsp return 1
208 ebf48fd5 2019-08-03 stsp fi
209 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
210 ebf48fd5 2019-08-03 stsp ret="$?"
211 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
212 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
213 ebf48fd5 2019-08-03 stsp fi
214 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
215 ebf48fd5 2019-08-03 stsp }
216 ebf48fd5 2019-08-03 stsp
217 ebf48fd5 2019-08-03 stsp
218 d3e7c587 2019-08-03 stsp function test_double_stage {
219 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
220 d3e7c587 2019-08-03 stsp
221 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
222 d3e7c587 2019-08-03 stsp ret="$?"
223 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
224 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
225 d3e7c587 2019-08-03 stsp return 1
226 d3e7c587 2019-08-03 stsp fi
227 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
228 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
229 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
230 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
231 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
232 d3e7c587 2019-08-03 stsp
233 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
234 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
235 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
236 d3e7c587 2019-08-03 stsp ret="$?"
237 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
238 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
239 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
240 d3e7c587 2019-08-03 stsp return 1
241 d3e7c587 2019-08-03 stsp fi
242 d3e7c587 2019-08-03 stsp
243 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
244 9c5c5eed 2019-08-03 stsp ret="$?"
245 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
246 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
247 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
248 d3e7c587 2019-08-03 stsp return 1
249 d3e7c587 2019-08-03 stsp fi
250 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
251 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
252 d3e7c587 2019-08-03 stsp ret="$?"
253 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
254 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
255 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
256 d3e7c587 2019-08-03 stsp return 1
257 d3e7c587 2019-08-03 stsp fi
258 d3e7c587 2019-08-03 stsp
259 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
260 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
261 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
262 d3e7c587 2019-08-03 stsp ret="$?"
263 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
264 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
265 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
266 d3e7c587 2019-08-03 stsp return 1
267 d3e7c587 2019-08-03 stsp fi
268 d3e7c587 2019-08-03 stsp
269 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
270 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
271 d3e7c587 2019-08-03 stsp
272 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
273 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
274 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
275 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
276 d3e7c587 2019-08-03 stsp ret="$?"
277 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
278 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
279 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
280 d3e7c587 2019-08-03 stsp return 1
281 d3e7c587 2019-08-03 stsp fi
282 d3e7c587 2019-08-03 stsp
283 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
284 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
285 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
286 fccbfb98 2019-08-03 stsp
287 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
288 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
289 fccbfb98 2019-08-03 stsp ret="$?"
290 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
291 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
292 fccbfb98 2019-08-03 stsp fi
293 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
294 fccbfb98 2019-08-03 stsp }
295 fccbfb98 2019-08-03 stsp
296 c363b2c1 2019-08-03 stsp function test_stage_status {
297 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
298 c363b2c1 2019-08-03 stsp
299 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
300 c363b2c1 2019-08-03 stsp ret="$?"
301 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
302 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
303 c363b2c1 2019-08-03 stsp return 1
304 c363b2c1 2019-08-03 stsp fi
305 c363b2c1 2019-08-03 stsp
306 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
307 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
308 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
309 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
310 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
311 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
312 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
313 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
314 c363b2c1 2019-08-03 stsp
315 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
316 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
317 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
318 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
319 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
320 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
321 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
322 c363b2c1 2019-08-03 stsp
323 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
324 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
325 c363b2c1 2019-08-03 stsp ret="$?"
326 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
327 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
329 244725f2 2019-08-03 stsp return 1
330 c363b2c1 2019-08-03 stsp fi
331 244725f2 2019-08-03 stsp
332 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
333 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
334 244725f2 2019-08-03 stsp
335 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
336 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
337 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
338 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
339 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
340 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
341 244725f2 2019-08-03 stsp
342 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
343 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
344 244725f2 2019-08-03 stsp ret="$?"
345 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
346 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
347 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
348 244725f2 2019-08-03 stsp return 1
349 244725f2 2019-08-03 stsp fi
350 244725f2 2019-08-03 stsp
351 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
352 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
353 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
354 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
355 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
356 244725f2 2019-08-03 stsp ret="$?"
357 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
358 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
359 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
360 244725f2 2019-08-03 stsp return 1
361 244725f2 2019-08-03 stsp fi
362 244725f2 2019-08-03 stsp
363 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
364 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
365 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
366 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
367 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
368 244725f2 2019-08-03 stsp ret="$?"
369 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
370 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
371 244725f2 2019-08-03 stsp fi
372 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
373 244725f2 2019-08-03 stsp
374 c363b2c1 2019-08-03 stsp }
375 c363b2c1 2019-08-03 stsp
376 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
377 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
378 1e1446d3 2019-08-03 stsp
379 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
380 1e1446d3 2019-08-03 stsp ret="$?"
381 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
382 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
383 1e1446d3 2019-08-03 stsp return 1
384 1e1446d3 2019-08-03 stsp fi
385 1e1446d3 2019-08-03 stsp
386 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
387 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
388 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
389 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
390 1e1446d3 2019-08-03 stsp
391 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
392 1e1446d3 2019-08-03 stsp
393 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
394 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
395 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
396 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
397 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
398 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
399 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
400 1e1446d3 2019-08-03 stsp ret="$?"
401 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
402 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
403 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
404 1e1446d3 2019-08-03 stsp return 1
405 1e1446d3 2019-08-03 stsp fi
406 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
407 1e1446d3 2019-08-03 stsp ret="$?"
408 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
409 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
410 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
411 1e1446d3 2019-08-03 stsp return 1
412 1e1446d3 2019-08-03 stsp fi
413 1e1446d3 2019-08-03 stsp done
414 1e1446d3 2019-08-03 stsp
415 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
416 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
417 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
418 1e1446d3 2019-08-03 stsp
419 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
420 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
421 1e1446d3 2019-08-03 stsp ret="$?"
422 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
423 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
424 1e1446d3 2019-08-03 stsp fi
425 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
426 1e1446d3 2019-08-03 stsp }
427 1e1446d3 2019-08-03 stsp
428 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
429 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
430 9acbc4fa 2019-08-03 stsp
431 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
432 9acbc4fa 2019-08-03 stsp ret="$?"
433 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
434 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
435 9acbc4fa 2019-08-03 stsp return 1
436 9acbc4fa 2019-08-03 stsp fi
437 9acbc4fa 2019-08-03 stsp
438 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
439 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
440 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
441 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
442 9acbc4fa 2019-08-03 stsp
443 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
444 9acbc4fa 2019-08-03 stsp
445 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
446 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
447 9acbc4fa 2019-08-03 stsp ret="$?"
448 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
449 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
450 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
451 9acbc4fa 2019-08-03 stsp return 1
452 9acbc4fa 2019-08-03 stsp fi
453 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
454 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
455 6d022e97 2019-08-04 stsp ret="$?"
456 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
457 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
458 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
459 6d022e97 2019-08-04 stsp return 1
460 6d022e97 2019-08-04 stsp fi
461 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
462 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
463 9acbc4fa 2019-08-03 stsp ret="$?"
464 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
465 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
466 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
467 9acbc4fa 2019-08-03 stsp return 1
468 9acbc4fa 2019-08-03 stsp fi
469 9acbc4fa 2019-08-03 stsp
470 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
471 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
472 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
473 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
474 9acbc4fa 2019-08-03 stsp ret="$?"
475 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
476 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
477 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
478 9acbc4fa 2019-08-03 stsp return 1
479 9acbc4fa 2019-08-03 stsp fi
480 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
481 9acbc4fa 2019-08-03 stsp ret="$?"
482 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
483 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
484 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
485 9acbc4fa 2019-08-03 stsp return 1
486 9acbc4fa 2019-08-03 stsp fi
487 9acbc4fa 2019-08-03 stsp done
488 9acbc4fa 2019-08-03 stsp
489 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
490 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
491 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
492 9acbc4fa 2019-08-03 stsp
493 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
494 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
495 9acbc4fa 2019-08-03 stsp ret="$?"
496 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
497 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
498 9acbc4fa 2019-08-03 stsp fi
499 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
500 9acbc4fa 2019-08-03 stsp }
501 24278f30 2019-08-03 stsp
502 24278f30 2019-08-03 stsp function test_stage_revert {
503 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
504 24278f30 2019-08-03 stsp
505 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
506 24278f30 2019-08-03 stsp ret="$?"
507 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
508 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
509 24278f30 2019-08-03 stsp return 1
510 24278f30 2019-08-03 stsp fi
511 24278f30 2019-08-03 stsp
512 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
513 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
514 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
515 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
516 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
517 24278f30 2019-08-03 stsp
518 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
519 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
520 24278f30 2019-08-03 stsp
521 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
522 24278f30 2019-08-03 stsp ret="$?"
523 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
524 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
525 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
526 24278f30 2019-08-03 stsp return 1
527 24278f30 2019-08-03 stsp fi
528 24278f30 2019-08-03 stsp
529 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
530 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
531 24278f30 2019-08-03 stsp ret="$?"
532 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
533 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
534 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
535 24278f30 2019-08-03 stsp return 1
536 24278f30 2019-08-03 stsp fi
537 24278f30 2019-08-03 stsp
538 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
539 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
540 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
541 24278f30 2019-08-03 stsp ret="$?"
542 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
543 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
544 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
545 24278f30 2019-08-03 stsp return 1
546 24278f30 2019-08-03 stsp fi
547 9acbc4fa 2019-08-03 stsp
548 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
549 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
550 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
551 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
552 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
553 24278f30 2019-08-03 stsp ret="$?"
554 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
555 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
556 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
557 24278f30 2019-08-03 stsp return 1
558 24278f30 2019-08-03 stsp fi
559 24278f30 2019-08-03 stsp
560 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
561 24278f30 2019-08-03 stsp ret="$?"
562 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
563 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
564 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
565 24278f30 2019-08-03 stsp return 1
566 24278f30 2019-08-03 stsp fi
567 24278f30 2019-08-03 stsp
568 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
569 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
570 24278f30 2019-08-03 stsp ret="$?"
571 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
572 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
573 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
574 24278f30 2019-08-03 stsp return 1
575 24278f30 2019-08-03 stsp fi
576 24278f30 2019-08-03 stsp
577 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
578 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
579 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
580 24278f30 2019-08-03 stsp ret="$?"
581 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
582 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
583 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
584 24278f30 2019-08-03 stsp return 1
585 24278f30 2019-08-03 stsp fi
586 24278f30 2019-08-03 stsp
587 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
588 24278f30 2019-08-03 stsp 2> $testroot/stderr)
589 24278f30 2019-08-03 stsp ret="$?"
590 24278f30 2019-08-03 stsp if [ "$ret" == "0" ]; then
591 24278f30 2019-08-03 stsp echo "revert command succeeded unexpectedly" >&2
592 24278f30 2019-08-03 stsp test_done "$testroot" "1"
593 24278f30 2019-08-03 stsp return 1
594 24278f30 2019-08-03 stsp fi
595 24278f30 2019-08-03 stsp
596 24278f30 2019-08-03 stsp echo "got: beta: file is staged" > $testroot/stderr.expected
597 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
598 24278f30 2019-08-03 stsp ret="$?"
599 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
600 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
601 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
602 24278f30 2019-08-03 stsp return 1
603 24278f30 2019-08-03 stsp fi
604 24278f30 2019-08-03 stsp
605 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
606 24278f30 2019-08-03 stsp ret="$?"
607 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
608 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
609 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
610 24278f30 2019-08-03 stsp return 1
611 24278f30 2019-08-03 stsp fi
612 24278f30 2019-08-03 stsp
613 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
614 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
615 24278f30 2019-08-03 stsp ret="$?"
616 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
617 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
618 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
619 24278f30 2019-08-03 stsp return 1
620 24278f30 2019-08-03 stsp fi
621 24278f30 2019-08-03 stsp
622 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
623 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
624 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
625 24278f30 2019-08-03 stsp ret="$?"
626 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
627 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
628 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
629 24278f30 2019-08-03 stsp return 1
630 24278f30 2019-08-03 stsp fi
631 24278f30 2019-08-03 stsp
632 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
633 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
634 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
635 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
636 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
637 24278f30 2019-08-03 stsp ret="$?"
638 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
639 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
640 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
641 24278f30 2019-08-03 stsp return 1
642 24278f30 2019-08-03 stsp fi
643 24278f30 2019-08-03 stsp
644 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
645 24278f30 2019-08-03 stsp ret="$?"
646 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
647 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
648 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
649 24278f30 2019-08-03 stsp return 1
650 24278f30 2019-08-03 stsp fi
651 24278f30 2019-08-03 stsp
652 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
653 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
654 24278f30 2019-08-03 stsp ret="$?"
655 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
656 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
657 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
658 24278f30 2019-08-03 stsp return 1
659 24278f30 2019-08-03 stsp fi
660 24278f30 2019-08-03 stsp
661 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
662 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
663 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
664 24278f30 2019-08-03 stsp ret="$?"
665 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
666 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
667 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
668 24278f30 2019-08-03 stsp return 1
669 24278f30 2019-08-03 stsp fi
670 24278f30 2019-08-03 stsp
671 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
672 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
673 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
674 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
675 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
676 408b4ebc 2019-08-03 stsp ret="$?"
677 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
678 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
679 408b4ebc 2019-08-03 stsp fi
680 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
681 408b4ebc 2019-08-03 stsp }
682 408b4ebc 2019-08-03 stsp
683 408b4ebc 2019-08-03 stsp function test_stage_diff {
684 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
685 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
686 408b4ebc 2019-08-03 stsp
687 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
688 408b4ebc 2019-08-03 stsp ret="$?"
689 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
690 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
691 408b4ebc 2019-08-03 stsp return 1
692 408b4ebc 2019-08-03 stsp fi
693 408b4ebc 2019-08-03 stsp
694 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
695 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
696 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
697 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
698 98eaaa12 2019-08-03 stsp
699 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
700 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
701 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
702 98eaaa12 2019-08-03 stsp ret="$?"
703 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
704 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
705 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
706 98eaaa12 2019-08-03 stsp return 1
707 98eaaa12 2019-08-03 stsp fi
708 408b4ebc 2019-08-03 stsp
709 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
710 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
711 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
712 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
713 408b4ebc 2019-08-03 stsp
714 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
715 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
716 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
717 408b4ebc 2019-08-03 stsp ret="$?"
718 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
719 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
720 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
721 408b4ebc 2019-08-03 stsp return 1
722 408b4ebc 2019-08-03 stsp fi
723 408b4ebc 2019-08-03 stsp
724 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
725 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
726 408b4ebc 2019-08-03 stsp
727 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
728 408b4ebc 2019-08-03 stsp
729 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
730 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
731 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
732 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
733 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
734 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
735 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
736 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
737 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
738 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
739 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
740 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
741 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
742 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
743 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
744 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
745 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
746 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
747 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
748 98eaaa12 2019-08-03 stsp
749 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
750 98eaaa12 2019-08-03 stsp ret="$?"
751 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
752 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
753 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
754 98eaaa12 2019-08-03 stsp return 1
755 98eaaa12 2019-08-03 stsp fi
756 98eaaa12 2019-08-03 stsp
757 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
758 98eaaa12 2019-08-03 stsp
759 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
760 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
761 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
762 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
763 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
764 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
765 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
766 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
767 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
768 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
769 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
770 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
771 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
772 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
773 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
774 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
775 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
776 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
777 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
778 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
779 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
780 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
781 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
782 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
783 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
784 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
785 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
786 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
787 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
788 408b4ebc 2019-08-03 stsp
789 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
790 24278f30 2019-08-03 stsp ret="$?"
791 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
792 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
793 24278f30 2019-08-03 stsp fi
794 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
795 408b4ebc 2019-08-03 stsp
796 24278f30 2019-08-03 stsp }
797 b9622844 2019-08-03 stsp
798 b9622844 2019-08-03 stsp function test_stage_histedit {
799 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
800 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
801 b9622844 2019-08-03 stsp
802 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
803 b9622844 2019-08-03 stsp ret="$?"
804 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
805 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
806 b9622844 2019-08-03 stsp return 1
807 b9622844 2019-08-03 stsp fi
808 b9622844 2019-08-03 stsp
809 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
810 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
811 b9622844 2019-08-03 stsp
812 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
813 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
814 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
815 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
816 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
817 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
818 24278f30 2019-08-03 stsp
819 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
820 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
821 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
822 b9622844 2019-08-03 stsp
823 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
824 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
825 b9622844 2019-08-03 stsp
826 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
827 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
828 b9622844 2019-08-03 stsp ret="$?"
829 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
830 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
831 b9622844 2019-08-03 stsp test_done "$testroot" "1"
832 b9622844 2019-08-03 stsp return 1
833 b9622844 2019-08-03 stsp fi
834 b9622844 2019-08-03 stsp
835 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
836 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
837 b9622844 2019-08-03 stsp
838 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
839 b9622844 2019-08-03 stsp ret="$?"
840 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
841 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
842 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
843 b9622844 2019-08-03 stsp return 1
844 b9622844 2019-08-03 stsp fi
845 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
846 b9622844 2019-08-03 stsp ret="$?"
847 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
848 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
849 b9622844 2019-08-03 stsp fi
850 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
851 243d7cf1 2019-08-03 stsp
852 243d7cf1 2019-08-03 stsp }
853 243d7cf1 2019-08-03 stsp
854 243d7cf1 2019-08-03 stsp function test_stage_rebase {
855 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
856 243d7cf1 2019-08-03 stsp
857 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
858 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
859 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
860 243d7cf1 2019-08-03 stsp
861 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
862 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
863 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
864 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
865 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
866 243d7cf1 2019-08-03 stsp
867 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
868 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
869 243d7cf1 2019-08-03 stsp
870 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
871 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
872 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
873 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
874 243d7cf1 2019-08-03 stsp
875 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
876 243d7cf1 2019-08-03 stsp ret="$?"
877 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
878 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
879 243d7cf1 2019-08-03 stsp return 1
880 243d7cf1 2019-08-03 stsp fi
881 243d7cf1 2019-08-03 stsp
882 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
883 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
884 b9622844 2019-08-03 stsp
885 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
886 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
887 243d7cf1 2019-08-03 stsp ret="$?"
888 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
889 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
890 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
891 243d7cf1 2019-08-03 stsp return 1
892 243d7cf1 2019-08-03 stsp fi
893 243d7cf1 2019-08-03 stsp
894 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
895 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
896 243d7cf1 2019-08-03 stsp
897 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
898 243d7cf1 2019-08-03 stsp ret="$?"
899 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
900 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
901 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
902 243d7cf1 2019-08-03 stsp return 1
903 243d7cf1 2019-08-03 stsp fi
904 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
905 243d7cf1 2019-08-03 stsp ret="$?"
906 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
907 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
908 243d7cf1 2019-08-03 stsp fi
909 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
910 b9622844 2019-08-03 stsp }
911 b9622844 2019-08-03 stsp
912 a76c42e6 2019-08-03 stsp function test_stage_update {
913 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
914 a76c42e6 2019-08-03 stsp
915 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
916 a76c42e6 2019-08-03 stsp ret="$?"
917 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
918 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
919 a76c42e6 2019-08-03 stsp return 1
920 a76c42e6 2019-08-03 stsp fi
921 243d7cf1 2019-08-03 stsp
922 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
923 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
924 a76c42e6 2019-08-03 stsp
925 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
926 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
927 a76c42e6 2019-08-03 stsp
928 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
929 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
930 a76c42e6 2019-08-03 stsp ret="$?"
931 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
932 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
933 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
934 a76c42e6 2019-08-03 stsp return 1
935 a76c42e6 2019-08-03 stsp fi
936 a76c42e6 2019-08-03 stsp
937 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
938 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
939 a76c42e6 2019-08-03 stsp
940 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
941 a76c42e6 2019-08-03 stsp ret="$?"
942 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
943 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
944 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
945 a76c42e6 2019-08-03 stsp return 1
946 a76c42e6 2019-08-03 stsp fi
947 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
948 a76c42e6 2019-08-03 stsp ret="$?"
949 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
950 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
951 a76c42e6 2019-08-03 stsp fi
952 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
953 a76c42e6 2019-08-03 stsp }
954 f0b75401 2019-08-03 stsp
955 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
956 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
957 f0b75401 2019-08-03 stsp
958 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
959 f0b75401 2019-08-03 stsp ret="$?"
960 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
961 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
962 f0b75401 2019-08-03 stsp return 1
963 f0b75401 2019-08-03 stsp fi
964 f0b75401 2019-08-03 stsp
965 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
966 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
967 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
968 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
969 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
970 a76c42e6 2019-08-03 stsp
971 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
972 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
973 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
974 f0b75401 2019-08-03 stsp ret="$?"
975 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
976 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
977 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
978 f0b75401 2019-08-03 stsp return 1
979 f0b75401 2019-08-03 stsp fi
980 f0b75401 2019-08-03 stsp
981 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
982 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
983 f0b75401 2019-08-03 stsp
984 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
985 f0b75401 2019-08-03 stsp ret="$?"
986 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
987 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
988 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
989 5f8a88c6 2019-08-03 stsp return 1
990 5f8a88c6 2019-08-03 stsp fi
991 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
992 5f8a88c6 2019-08-03 stsp ret="$?"
993 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
994 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
995 5f8a88c6 2019-08-03 stsp fi
996 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
997 5f8a88c6 2019-08-03 stsp }
998 5f8a88c6 2019-08-03 stsp
999 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1000 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1001 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1002 5f8a88c6 2019-08-03 stsp
1003 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1004 5f8a88c6 2019-08-03 stsp ret="$?"
1005 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1006 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1007 5f8a88c6 2019-08-03 stsp return 1
1008 5f8a88c6 2019-08-03 stsp fi
1009 5f8a88c6 2019-08-03 stsp
1010 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1011 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1012 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1013 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1014 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1015 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1016 5f8a88c6 2019-08-03 stsp
1017 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1018 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1019 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1020 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1021 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1022 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1023 5f8a88c6 2019-08-03 stsp
1024 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1025 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1026 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1027 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1028 5f8a88c6 2019-08-03 stsp
1029 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1030 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1031 5f8a88c6 2019-08-03 stsp ret="$?"
1032 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1033 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1034 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1035 5f8a88c6 2019-08-03 stsp return 1
1036 5f8a88c6 2019-08-03 stsp fi
1037 5f8a88c6 2019-08-03 stsp
1038 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1039 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1040 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1041 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1042 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1043 5f8a88c6 2019-08-03 stsp
1044 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1045 5f8a88c6 2019-08-03 stsp ret="$?"
1046 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1047 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1048 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1049 f0b75401 2019-08-03 stsp return 1
1050 f0b75401 2019-08-03 stsp fi
1051 5f8a88c6 2019-08-03 stsp
1052 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1053 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1054 5f8a88c6 2019-08-03 stsp
1055 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1056 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1057 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1058 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1059 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1060 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1061 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1062 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1063 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1064 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1065 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1066 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1067 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1068 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1069 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1070 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1071 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1072 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1073 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1074 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1075 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1076 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1077 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1078 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1079 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1080 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1081 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1082 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1083 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1084 5f8a88c6 2019-08-03 stsp
1085 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1086 f0b75401 2019-08-03 stsp ret="$?"
1087 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1088 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1089 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1090 5f8a88c6 2019-08-03 stsp return 1
1091 f0b75401 2019-08-03 stsp fi
1092 5f8a88c6 2019-08-03 stsp
1093 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1094 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1095 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1096 5f8a88c6 2019-08-03 stsp
1097 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1098 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1099 5f8a88c6 2019-08-03 stsp ret="$?"
1100 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1101 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1102 5f8a88c6 2019-08-03 stsp fi
1103 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1104 f0b75401 2019-08-03 stsp }
1105 f0b75401 2019-08-03 stsp
1106 fccbfb98 2019-08-03 stsp run_test test_stage_basic
1107 a4f692bb 2019-08-04 stsp run_test test_stage_list
1108 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
1109 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
1110 d3e7c587 2019-08-03 stsp run_test test_double_stage
1111 c363b2c1 2019-08-03 stsp run_test test_stage_status
1112 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
1113 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
1114 24278f30 2019-08-03 stsp run_test test_stage_revert
1115 408b4ebc 2019-08-03 stsp run_test test_stage_diff
1116 b9622844 2019-08-03 stsp run_test test_stage_histedit
1117 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
1118 a76c42e6 2019-08-03 stsp run_test test_stage_update
1119 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
1120 5f8a88c6 2019-08-03 stsp run_test test_stage_commit