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