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 ec9d9b2f 2019-08-08 stsp (cd $testroot/wt && got stage > $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 2db2652d 2019-08-07 stsp echo "got: 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 8b13ce36 2019-08-08 stsp function test_stage_unversioned {
86 8b13ce36 2019-08-08 stsp local testroot=`test_init stage_unversioned`
87 8b13ce36 2019-08-08 stsp
88 8b13ce36 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
89 8b13ce36 2019-08-08 stsp ret="$?"
90 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
91 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
92 8b13ce36 2019-08-08 stsp return 1
93 8b13ce36 2019-08-08 stsp fi
94 8b13ce36 2019-08-08 stsp
95 8b13ce36 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
96 8b13ce36 2019-08-08 stsp touch $testroot/wt/unversioned-file
97 8b13ce36 2019-08-08 stsp
98 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
99 8b13ce36 2019-08-08 stsp echo "M alpha" > $testroot/stdout.expected
100 8b13ce36 2019-08-08 stsp echo "? unversioned-file" >> $testroot/stdout.expected
101 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
102 8b13ce36 2019-08-08 stsp ret="$?"
103 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
104 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
105 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
106 8b13ce36 2019-08-08 stsp return 1
107 8b13ce36 2019-08-08 stsp fi
108 8b13ce36 2019-08-08 stsp
109 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage > $testroot/stdout)
110 8b13ce36 2019-08-08 stsp ret="$?"
111 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
112 8b13ce36 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
113 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
114 8b13ce36 2019-08-08 stsp return 1
115 8b13ce36 2019-08-08 stsp fi
116 8b13ce36 2019-08-08 stsp
117 8b13ce36 2019-08-08 stsp echo " M alpha" > $testroot/stdout.expected
118 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
119 8b13ce36 2019-08-08 stsp ret="$?"
120 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
121 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
122 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
123 8b13ce36 2019-08-08 stsp return 1
124 8b13ce36 2019-08-08 stsp fi
125 8b13ce36 2019-08-08 stsp
126 8b13ce36 2019-08-08 stsp echo "modified file again" > $testroot/wt/alpha
127 8b13ce36 2019-08-08 stsp
128 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage unversioned-file > $testroot/stdout \
129 8b13ce36 2019-08-08 stsp 2> $testroot/stderr)
130 8b13ce36 2019-08-08 stsp ret="$?"
131 8b13ce36 2019-08-08 stsp if [ "$ret" == "0" ]; then
132 8b13ce36 2019-08-08 stsp echo "got stage command succeed unexpectedly" >&2
133 8b13ce36 2019-08-08 stsp test_done "$testroot" "1"
134 8b13ce36 2019-08-08 stsp return 1
135 8b13ce36 2019-08-08 stsp fi
136 8b13ce36 2019-08-08 stsp
137 8b13ce36 2019-08-08 stsp echo "got: no changes to stage" > $testroot/stderr.expected
138 8b13ce36 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
139 8b13ce36 2019-08-08 stsp ret="$?"
140 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
141 8b13ce36 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
142 8b13ce36 2019-08-08 stsp fi
143 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
144 8564cb21 2019-08-08 stsp
145 8564cb21 2019-08-08 stsp }
146 8564cb21 2019-08-08 stsp
147 8564cb21 2019-08-08 stsp function test_stage_nonexistent {
148 8564cb21 2019-08-08 stsp local testroot=`test_init stage_nonexistent`
149 8564cb21 2019-08-08 stsp
150 8564cb21 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
151 8564cb21 2019-08-08 stsp ret="$?"
152 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
153 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
154 8564cb21 2019-08-08 stsp return 1
155 8564cb21 2019-08-08 stsp fi
156 8b13ce36 2019-08-08 stsp
157 8564cb21 2019-08-08 stsp (cd $testroot/wt && got stage nonexistent-file \
158 8564cb21 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
159 8564cb21 2019-08-08 stsp echo "got: no changes to stage" > $testroot/stderr.expected
160 8564cb21 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
161 8564cb21 2019-08-08 stsp ret="$?"
162 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
163 8564cb21 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
164 8564cb21 2019-08-08 stsp fi
165 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
166 8b13ce36 2019-08-08 stsp }
167 8b13ce36 2019-08-08 stsp
168 a4f692bb 2019-08-04 stsp function test_stage_list {
169 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
170 a4f692bb 2019-08-04 stsp
171 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
172 a4f692bb 2019-08-04 stsp ret="$?"
173 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
174 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
175 a4f692bb 2019-08-04 stsp return 1
176 a4f692bb 2019-08-04 stsp fi
177 a4f692bb 2019-08-04 stsp
178 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
179 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
180 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
181 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
182 a4f692bb 2019-08-04 stsp
183 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
184 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
185 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
186 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
187 a4f692bb 2019-08-04 stsp
188 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
189 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
190 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
191 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
192 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
193 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
194 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
195 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
196 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
197 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
198 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
199 a4f692bb 2019-08-04 stsp ret="$?"
200 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
201 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
202 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
203 a4f692bb 2019-08-04 stsp return 1
204 a4f692bb 2019-08-04 stsp fi
205 a4f692bb 2019-08-04 stsp
206 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
207 a4f692bb 2019-08-04 stsp > $testroot/stdout)
208 a4f692bb 2019-08-04 stsp
209 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
210 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
211 a4f692bb 2019-08-04 stsp ret="$?"
212 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
213 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
214 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
215 a4f692bb 2019-08-04 stsp return 1
216 a4f692bb 2019-08-04 stsp fi
217 a4f692bb 2019-08-04 stsp
218 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
219 a4f692bb 2019-08-04 stsp
220 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
221 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
222 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
223 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
224 a4f692bb 2019-08-04 stsp ret="$?"
225 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
226 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
227 a4f692bb 2019-08-04 stsp fi
228 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
229 a4f692bb 2019-08-04 stsp
230 a4f692bb 2019-08-04 stsp }
231 a4f692bb 2019-08-04 stsp
232 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
233 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
234 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
235 ebf48fd5 2019-08-03 stsp
236 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
237 ebf48fd5 2019-08-03 stsp ret="$?"
238 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
239 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
240 ebf48fd5 2019-08-03 stsp return 1
241 ebf48fd5 2019-08-03 stsp fi
242 ebf48fd5 2019-08-03 stsp
243 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
244 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
245 ebf48fd5 2019-08-03 stsp
246 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
247 ebf48fd5 2019-08-03 stsp
248 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
249 ebf48fd5 2019-08-03 stsp
250 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
251 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
252 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
253 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
254 ebf48fd5 2019-08-03 stsp
255 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
256 ebf48fd5 2019-08-03 stsp
257 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
258 ebf48fd5 2019-08-03 stsp ret="$?"
259 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
260 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
261 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
262 ebf48fd5 2019-08-03 stsp return 1
263 ebf48fd5 2019-08-03 stsp fi
264 ebf48fd5 2019-08-03 stsp
265 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
266 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
267 ebf48fd5 2019-08-03 stsp ret="$?"
268 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
269 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
270 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
271 ebf48fd5 2019-08-03 stsp return 1
272 ebf48fd5 2019-08-03 stsp fi
273 ebf48fd5 2019-08-03 stsp
274 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
275 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
276 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
277 735ef5ac 2019-08-03 stsp
278 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
279 735ef5ac 2019-08-03 stsp ret="$?"
280 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
281 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
282 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
283 735ef5ac 2019-08-03 stsp return 1
284 735ef5ac 2019-08-03 stsp fi
285 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
286 735ef5ac 2019-08-03 stsp ret="$?"
287 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
288 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
289 735ef5ac 2019-08-03 stsp fi
290 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
291 735ef5ac 2019-08-03 stsp }
292 735ef5ac 2019-08-03 stsp
293 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
294 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
295 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
296 735ef5ac 2019-08-03 stsp
297 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
298 735ef5ac 2019-08-03 stsp ret="$?"
299 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
300 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
301 735ef5ac 2019-08-03 stsp return 1
302 735ef5ac 2019-08-03 stsp fi
303 735ef5ac 2019-08-03 stsp
304 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
305 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
306 735ef5ac 2019-08-03 stsp
307 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
308 735ef5ac 2019-08-03 stsp
309 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
310 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
311 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
312 735ef5ac 2019-08-03 stsp ret="$?"
313 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
314 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
315 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
316 735ef5ac 2019-08-03 stsp return 1
317 735ef5ac 2019-08-03 stsp fi
318 735ef5ac 2019-08-03 stsp
319 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
320 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
321 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
322 ebf48fd5 2019-08-03 stsp
323 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
324 ebf48fd5 2019-08-03 stsp ret="$?"
325 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
326 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
327 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
328 ebf48fd5 2019-08-03 stsp return 1
329 ebf48fd5 2019-08-03 stsp fi
330 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
331 ebf48fd5 2019-08-03 stsp ret="$?"
332 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
333 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
334 ebf48fd5 2019-08-03 stsp fi
335 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
336 ebf48fd5 2019-08-03 stsp }
337 ebf48fd5 2019-08-03 stsp
338 ebf48fd5 2019-08-03 stsp
339 d3e7c587 2019-08-03 stsp function test_double_stage {
340 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
341 d3e7c587 2019-08-03 stsp
342 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
343 d3e7c587 2019-08-03 stsp ret="$?"
344 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
345 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
346 d3e7c587 2019-08-03 stsp return 1
347 d3e7c587 2019-08-03 stsp fi
348 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
349 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
350 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
351 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
352 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
353 d3e7c587 2019-08-03 stsp
354 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
355 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
356 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
357 d3e7c587 2019-08-03 stsp ret="$?"
358 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
359 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
360 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
361 d3e7c587 2019-08-03 stsp return 1
362 d3e7c587 2019-08-03 stsp fi
363 d3e7c587 2019-08-03 stsp
364 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
365 9c5c5eed 2019-08-03 stsp ret="$?"
366 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
367 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
368 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
369 d3e7c587 2019-08-03 stsp return 1
370 d3e7c587 2019-08-03 stsp fi
371 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
372 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
373 d3e7c587 2019-08-03 stsp ret="$?"
374 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
375 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
376 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
377 d3e7c587 2019-08-03 stsp return 1
378 d3e7c587 2019-08-03 stsp fi
379 d3e7c587 2019-08-03 stsp
380 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
381 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
382 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
383 d3e7c587 2019-08-03 stsp ret="$?"
384 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
385 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
386 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
387 d3e7c587 2019-08-03 stsp return 1
388 d3e7c587 2019-08-03 stsp fi
389 d3e7c587 2019-08-03 stsp
390 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
391 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
392 d3e7c587 2019-08-03 stsp
393 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
394 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
395 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
396 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
397 d3e7c587 2019-08-03 stsp ret="$?"
398 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
399 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
400 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
401 d3e7c587 2019-08-03 stsp return 1
402 d3e7c587 2019-08-03 stsp fi
403 d3e7c587 2019-08-03 stsp
404 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
405 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
406 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
407 fccbfb98 2019-08-03 stsp
408 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
409 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
410 fccbfb98 2019-08-03 stsp ret="$?"
411 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
412 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
413 fccbfb98 2019-08-03 stsp fi
414 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
415 fccbfb98 2019-08-03 stsp }
416 fccbfb98 2019-08-03 stsp
417 c363b2c1 2019-08-03 stsp function test_stage_status {
418 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
419 c363b2c1 2019-08-03 stsp
420 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
421 c363b2c1 2019-08-03 stsp ret="$?"
422 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
423 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
424 c363b2c1 2019-08-03 stsp return 1
425 c363b2c1 2019-08-03 stsp fi
426 c363b2c1 2019-08-03 stsp
427 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
428 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
429 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
430 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
431 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
432 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
433 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
434 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
435 c363b2c1 2019-08-03 stsp
436 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
437 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
438 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
439 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
440 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
441 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
442 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
443 c363b2c1 2019-08-03 stsp
444 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
445 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
446 c363b2c1 2019-08-03 stsp ret="$?"
447 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
448 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
449 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
450 244725f2 2019-08-03 stsp return 1
451 c363b2c1 2019-08-03 stsp fi
452 244725f2 2019-08-03 stsp
453 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
454 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
455 244725f2 2019-08-03 stsp
456 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
457 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
458 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
459 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
460 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
461 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
462 244725f2 2019-08-03 stsp
463 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
464 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
465 244725f2 2019-08-03 stsp ret="$?"
466 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
467 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
468 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
469 244725f2 2019-08-03 stsp return 1
470 244725f2 2019-08-03 stsp fi
471 244725f2 2019-08-03 stsp
472 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
473 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
474 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
475 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
476 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
477 244725f2 2019-08-03 stsp ret="$?"
478 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
479 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
480 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
481 244725f2 2019-08-03 stsp return 1
482 244725f2 2019-08-03 stsp fi
483 244725f2 2019-08-03 stsp
484 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
485 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
486 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
487 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
488 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
489 244725f2 2019-08-03 stsp ret="$?"
490 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
491 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
492 244725f2 2019-08-03 stsp fi
493 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
494 244725f2 2019-08-03 stsp
495 c363b2c1 2019-08-03 stsp }
496 c363b2c1 2019-08-03 stsp
497 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
498 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
499 1e1446d3 2019-08-03 stsp
500 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
501 1e1446d3 2019-08-03 stsp ret="$?"
502 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
503 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
504 1e1446d3 2019-08-03 stsp return 1
505 1e1446d3 2019-08-03 stsp fi
506 1e1446d3 2019-08-03 stsp
507 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
508 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
509 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
510 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
511 1e1446d3 2019-08-03 stsp
512 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
513 1e1446d3 2019-08-03 stsp
514 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
515 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
516 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
517 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
518 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
519 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
520 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
521 1e1446d3 2019-08-03 stsp ret="$?"
522 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
523 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
524 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
525 1e1446d3 2019-08-03 stsp return 1
526 1e1446d3 2019-08-03 stsp fi
527 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
528 1e1446d3 2019-08-03 stsp ret="$?"
529 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
530 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
531 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
532 1e1446d3 2019-08-03 stsp return 1
533 1e1446d3 2019-08-03 stsp fi
534 1e1446d3 2019-08-03 stsp done
535 1e1446d3 2019-08-03 stsp
536 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
537 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
538 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
539 1e1446d3 2019-08-03 stsp
540 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
541 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
542 1e1446d3 2019-08-03 stsp ret="$?"
543 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
544 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
545 1e1446d3 2019-08-03 stsp fi
546 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
547 1e1446d3 2019-08-03 stsp }
548 1e1446d3 2019-08-03 stsp
549 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
550 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
551 9acbc4fa 2019-08-03 stsp
552 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
553 9acbc4fa 2019-08-03 stsp ret="$?"
554 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
555 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
556 9acbc4fa 2019-08-03 stsp return 1
557 9acbc4fa 2019-08-03 stsp fi
558 9acbc4fa 2019-08-03 stsp
559 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
560 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
561 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
562 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
563 9acbc4fa 2019-08-03 stsp
564 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
565 9acbc4fa 2019-08-03 stsp
566 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
567 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
568 9acbc4fa 2019-08-03 stsp ret="$?"
569 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
570 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
571 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
572 9acbc4fa 2019-08-03 stsp return 1
573 9acbc4fa 2019-08-03 stsp fi
574 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
575 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
576 6d022e97 2019-08-04 stsp ret="$?"
577 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
578 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
579 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
580 6d022e97 2019-08-04 stsp return 1
581 6d022e97 2019-08-04 stsp fi
582 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
583 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
584 9acbc4fa 2019-08-03 stsp ret="$?"
585 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
586 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
587 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
588 9acbc4fa 2019-08-03 stsp return 1
589 9acbc4fa 2019-08-03 stsp fi
590 9acbc4fa 2019-08-03 stsp
591 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
592 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
593 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
594 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
595 9acbc4fa 2019-08-03 stsp ret="$?"
596 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
597 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
598 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
599 9acbc4fa 2019-08-03 stsp return 1
600 9acbc4fa 2019-08-03 stsp fi
601 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
602 9acbc4fa 2019-08-03 stsp ret="$?"
603 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
604 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
605 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
606 9acbc4fa 2019-08-03 stsp return 1
607 9acbc4fa 2019-08-03 stsp fi
608 9acbc4fa 2019-08-03 stsp done
609 9acbc4fa 2019-08-03 stsp
610 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
611 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
612 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
613 9acbc4fa 2019-08-03 stsp
614 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
615 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
616 9acbc4fa 2019-08-03 stsp ret="$?"
617 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
618 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
619 9acbc4fa 2019-08-03 stsp fi
620 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
621 9acbc4fa 2019-08-03 stsp }
622 24278f30 2019-08-03 stsp
623 24278f30 2019-08-03 stsp function test_stage_revert {
624 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
625 24278f30 2019-08-03 stsp
626 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
627 24278f30 2019-08-03 stsp ret="$?"
628 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
629 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
630 24278f30 2019-08-03 stsp return 1
631 24278f30 2019-08-03 stsp fi
632 24278f30 2019-08-03 stsp
633 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
634 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
635 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
636 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
637 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
638 24278f30 2019-08-03 stsp
639 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
640 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
641 24278f30 2019-08-03 stsp
642 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
643 24278f30 2019-08-03 stsp ret="$?"
644 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
645 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
646 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
647 24278f30 2019-08-03 stsp return 1
648 24278f30 2019-08-03 stsp fi
649 24278f30 2019-08-03 stsp
650 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
651 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
652 24278f30 2019-08-03 stsp ret="$?"
653 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
654 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
655 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
656 24278f30 2019-08-03 stsp return 1
657 24278f30 2019-08-03 stsp fi
658 24278f30 2019-08-03 stsp
659 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
660 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
661 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
662 24278f30 2019-08-03 stsp ret="$?"
663 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
664 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
665 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
666 24278f30 2019-08-03 stsp return 1
667 24278f30 2019-08-03 stsp fi
668 9acbc4fa 2019-08-03 stsp
669 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
670 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
671 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
672 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
673 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
674 24278f30 2019-08-03 stsp ret="$?"
675 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
676 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
677 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
678 24278f30 2019-08-03 stsp return 1
679 24278f30 2019-08-03 stsp fi
680 24278f30 2019-08-03 stsp
681 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
682 24278f30 2019-08-03 stsp ret="$?"
683 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
684 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
685 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
686 24278f30 2019-08-03 stsp return 1
687 24278f30 2019-08-03 stsp fi
688 24278f30 2019-08-03 stsp
689 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
690 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
691 24278f30 2019-08-03 stsp ret="$?"
692 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
693 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
694 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
695 24278f30 2019-08-03 stsp return 1
696 24278f30 2019-08-03 stsp fi
697 24278f30 2019-08-03 stsp
698 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
699 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
700 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
701 24278f30 2019-08-03 stsp ret="$?"
702 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
703 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
704 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
705 24278f30 2019-08-03 stsp return 1
706 24278f30 2019-08-03 stsp fi
707 24278f30 2019-08-03 stsp
708 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
709 24278f30 2019-08-03 stsp 2> $testroot/stderr)
710 24278f30 2019-08-03 stsp ret="$?"
711 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
712 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
713 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
714 24278f30 2019-08-03 stsp return 1
715 24278f30 2019-08-03 stsp fi
716 24278f30 2019-08-03 stsp
717 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stdout.expected
718 d3bcc3d1 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
719 d3bcc3d1 2019-08-08 stsp ret="$?"
720 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
721 d3bcc3d1 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
722 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
723 d3bcc3d1 2019-08-08 stsp return 1
724 d3bcc3d1 2019-08-08 stsp fi
725 d3bcc3d1 2019-08-08 stsp
726 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
727 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
728 24278f30 2019-08-03 stsp ret="$?"
729 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
730 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
731 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
732 24278f30 2019-08-03 stsp return 1
733 24278f30 2019-08-03 stsp fi
734 24278f30 2019-08-03 stsp
735 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
736 24278f30 2019-08-03 stsp ret="$?"
737 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
738 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
739 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
740 24278f30 2019-08-03 stsp return 1
741 24278f30 2019-08-03 stsp fi
742 24278f30 2019-08-03 stsp
743 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
744 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
745 24278f30 2019-08-03 stsp ret="$?"
746 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
747 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
748 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
749 24278f30 2019-08-03 stsp return 1
750 24278f30 2019-08-03 stsp fi
751 24278f30 2019-08-03 stsp
752 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
753 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
754 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
755 24278f30 2019-08-03 stsp ret="$?"
756 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
757 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
758 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
759 24278f30 2019-08-03 stsp return 1
760 24278f30 2019-08-03 stsp fi
761 24278f30 2019-08-03 stsp
762 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
763 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
764 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
765 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
766 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
767 24278f30 2019-08-03 stsp ret="$?"
768 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
769 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
770 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
771 24278f30 2019-08-03 stsp return 1
772 24278f30 2019-08-03 stsp fi
773 24278f30 2019-08-03 stsp
774 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
775 24278f30 2019-08-03 stsp ret="$?"
776 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
777 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
778 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
779 24278f30 2019-08-03 stsp return 1
780 24278f30 2019-08-03 stsp fi
781 24278f30 2019-08-03 stsp
782 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
783 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
784 24278f30 2019-08-03 stsp ret="$?"
785 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
786 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
787 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
788 24278f30 2019-08-03 stsp return 1
789 24278f30 2019-08-03 stsp fi
790 24278f30 2019-08-03 stsp
791 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
792 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
793 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
794 24278f30 2019-08-03 stsp ret="$?"
795 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
796 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
797 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
798 24278f30 2019-08-03 stsp return 1
799 24278f30 2019-08-03 stsp fi
800 24278f30 2019-08-03 stsp
801 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
802 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
803 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
804 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
805 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
806 0f6d7415 2019-08-08 stsp ret="$?"
807 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
808 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
809 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
810 0f6d7415 2019-08-08 stsp return 1
811 0f6d7415 2019-08-08 stsp fi
812 0f6d7415 2019-08-08 stsp
813 0f6d7415 2019-08-08 stsp echo "modified file again" >> $testroot/wt/alpha
814 0f6d7415 2019-08-08 stsp echo "modified added file again" >> $testroot/wt/foo
815 0f6d7415 2019-08-08 stsp
816 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout \
817 0f6d7415 2019-08-08 stsp 2> $testroot/stderr)
818 0f6d7415 2019-08-08 stsp ret="$?"
819 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
820 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
821 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
822 0f6d7415 2019-08-08 stsp return 1
823 0f6d7415 2019-08-08 stsp fi
824 0f6d7415 2019-08-08 stsp
825 0f6d7415 2019-08-08 stsp echo "R alpha" > $testroot/stdout.expected
826 d3bcc3d1 2019-08-08 stsp echo "R foo" >> $testroot/stdout.expected
827 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
828 0f6d7415 2019-08-08 stsp ret="$?"
829 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
830 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
831 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
832 0f6d7415 2019-08-08 stsp return 1
833 0f6d7415 2019-08-08 stsp fi
834 0f6d7415 2019-08-08 stsp
835 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
836 0f6d7415 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
837 0f6d7415 2019-08-08 stsp ret="$?"
838 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
839 0f6d7415 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
840 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
841 0f6d7415 2019-08-08 stsp return 1
842 0f6d7415 2019-08-08 stsp fi
843 0f6d7415 2019-08-08 stsp
844 0f6d7415 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
845 0f6d7415 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
846 d3bcc3d1 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
847 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
848 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
849 408b4ebc 2019-08-03 stsp ret="$?"
850 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
851 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
852 408b4ebc 2019-08-03 stsp fi
853 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
854 408b4ebc 2019-08-03 stsp }
855 408b4ebc 2019-08-03 stsp
856 408b4ebc 2019-08-03 stsp function test_stage_diff {
857 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
858 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
859 408b4ebc 2019-08-03 stsp
860 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
861 408b4ebc 2019-08-03 stsp ret="$?"
862 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
863 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
864 408b4ebc 2019-08-03 stsp return 1
865 408b4ebc 2019-08-03 stsp fi
866 408b4ebc 2019-08-03 stsp
867 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
868 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
869 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
870 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
871 98eaaa12 2019-08-03 stsp
872 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
873 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
874 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
875 98eaaa12 2019-08-03 stsp ret="$?"
876 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
877 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
878 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
879 98eaaa12 2019-08-03 stsp return 1
880 98eaaa12 2019-08-03 stsp fi
881 408b4ebc 2019-08-03 stsp
882 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
883 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
884 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
885 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
886 408b4ebc 2019-08-03 stsp
887 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
888 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
889 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
890 408b4ebc 2019-08-03 stsp ret="$?"
891 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
892 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
893 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
894 408b4ebc 2019-08-03 stsp return 1
895 408b4ebc 2019-08-03 stsp fi
896 408b4ebc 2019-08-03 stsp
897 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
898 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
899 408b4ebc 2019-08-03 stsp
900 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
901 408b4ebc 2019-08-03 stsp
902 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
903 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
904 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
905 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
906 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
907 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
908 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
909 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
910 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
911 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
912 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
913 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
914 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
915 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
916 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
917 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
918 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
919 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
920 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
921 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
922 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
923 98eaaa12 2019-08-03 stsp
924 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
925 98eaaa12 2019-08-03 stsp ret="$?"
926 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
927 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
928 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
929 98eaaa12 2019-08-03 stsp return 1
930 98eaaa12 2019-08-03 stsp fi
931 98eaaa12 2019-08-03 stsp
932 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
933 98eaaa12 2019-08-03 stsp
934 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
935 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
936 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
937 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
938 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
939 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
940 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
941 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
942 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
943 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
944 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
945 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
946 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
947 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
948 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
949 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
950 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
951 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
952 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
953 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
954 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
955 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
956 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
957 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
958 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
959 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
960 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
961 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
962 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
963 408b4ebc 2019-08-03 stsp
964 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
965 24278f30 2019-08-03 stsp ret="$?"
966 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
967 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
968 24278f30 2019-08-03 stsp fi
969 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
970 408b4ebc 2019-08-03 stsp
971 24278f30 2019-08-03 stsp }
972 b9622844 2019-08-03 stsp
973 b9622844 2019-08-03 stsp function test_stage_histedit {
974 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
975 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
976 b9622844 2019-08-03 stsp
977 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
978 b9622844 2019-08-03 stsp ret="$?"
979 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
980 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
981 b9622844 2019-08-03 stsp return 1
982 b9622844 2019-08-03 stsp fi
983 b9622844 2019-08-03 stsp
984 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
985 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
986 b9622844 2019-08-03 stsp
987 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
988 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
989 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
990 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
991 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
992 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
993 24278f30 2019-08-03 stsp
994 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
995 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
996 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
997 b9622844 2019-08-03 stsp
998 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
999 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1000 b9622844 2019-08-03 stsp
1001 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1002 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1003 b9622844 2019-08-03 stsp ret="$?"
1004 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
1005 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
1006 b9622844 2019-08-03 stsp test_done "$testroot" "1"
1007 b9622844 2019-08-03 stsp return 1
1008 b9622844 2019-08-03 stsp fi
1009 b9622844 2019-08-03 stsp
1010 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
1011 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1012 b9622844 2019-08-03 stsp
1013 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1014 b9622844 2019-08-03 stsp ret="$?"
1015 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1016 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1017 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1018 b9622844 2019-08-03 stsp return 1
1019 b9622844 2019-08-03 stsp fi
1020 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1021 b9622844 2019-08-03 stsp ret="$?"
1022 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1023 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1024 b9622844 2019-08-03 stsp fi
1025 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1026 243d7cf1 2019-08-03 stsp
1027 243d7cf1 2019-08-03 stsp }
1028 243d7cf1 2019-08-03 stsp
1029 243d7cf1 2019-08-03 stsp function test_stage_rebase {
1030 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
1031 243d7cf1 2019-08-03 stsp
1032 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1033 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1034 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1035 243d7cf1 2019-08-03 stsp
1036 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1037 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1038 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1039 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1040 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1041 243d7cf1 2019-08-03 stsp
1042 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1043 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
1044 243d7cf1 2019-08-03 stsp
1045 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
1046 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1047 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1048 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
1049 243d7cf1 2019-08-03 stsp
1050 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1051 243d7cf1 2019-08-03 stsp ret="$?"
1052 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1053 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1054 243d7cf1 2019-08-03 stsp return 1
1055 243d7cf1 2019-08-03 stsp fi
1056 243d7cf1 2019-08-03 stsp
1057 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1058 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1059 b9622844 2019-08-03 stsp
1060 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
1061 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1062 243d7cf1 2019-08-03 stsp ret="$?"
1063 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
1064 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
1065 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
1066 243d7cf1 2019-08-03 stsp return 1
1067 243d7cf1 2019-08-03 stsp fi
1068 243d7cf1 2019-08-03 stsp
1069 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
1070 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1071 243d7cf1 2019-08-03 stsp
1072 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1073 243d7cf1 2019-08-03 stsp ret="$?"
1074 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1075 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1076 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1077 243d7cf1 2019-08-03 stsp return 1
1078 243d7cf1 2019-08-03 stsp fi
1079 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1080 243d7cf1 2019-08-03 stsp ret="$?"
1081 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1082 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1083 243d7cf1 2019-08-03 stsp fi
1084 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1085 b9622844 2019-08-03 stsp }
1086 b9622844 2019-08-03 stsp
1087 a76c42e6 2019-08-03 stsp function test_stage_update {
1088 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1089 a76c42e6 2019-08-03 stsp
1090 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1091 a76c42e6 2019-08-03 stsp ret="$?"
1092 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1093 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1094 a76c42e6 2019-08-03 stsp return 1
1095 a76c42e6 2019-08-03 stsp fi
1096 243d7cf1 2019-08-03 stsp
1097 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1098 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1099 a76c42e6 2019-08-03 stsp
1100 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1101 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1102 a76c42e6 2019-08-03 stsp
1103 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1104 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1105 a76c42e6 2019-08-03 stsp ret="$?"
1106 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
1107 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1108 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1109 a76c42e6 2019-08-03 stsp return 1
1110 a76c42e6 2019-08-03 stsp fi
1111 a76c42e6 2019-08-03 stsp
1112 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1113 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1114 a76c42e6 2019-08-03 stsp
1115 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1116 a76c42e6 2019-08-03 stsp ret="$?"
1117 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1118 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1119 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1120 a76c42e6 2019-08-03 stsp return 1
1121 a76c42e6 2019-08-03 stsp fi
1122 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1123 a76c42e6 2019-08-03 stsp ret="$?"
1124 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1125 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1126 a76c42e6 2019-08-03 stsp fi
1127 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1128 a76c42e6 2019-08-03 stsp }
1129 f0b75401 2019-08-03 stsp
1130 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
1131 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1132 f0b75401 2019-08-03 stsp
1133 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1134 f0b75401 2019-08-03 stsp ret="$?"
1135 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1136 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1137 f0b75401 2019-08-03 stsp return 1
1138 f0b75401 2019-08-03 stsp fi
1139 f0b75401 2019-08-03 stsp
1140 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1141 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1142 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1143 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1144 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1145 a76c42e6 2019-08-03 stsp
1146 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1147 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1148 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1149 f0b75401 2019-08-03 stsp ret="$?"
1150 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
1151 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1152 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1153 f0b75401 2019-08-03 stsp return 1
1154 f0b75401 2019-08-03 stsp fi
1155 f0b75401 2019-08-03 stsp
1156 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1157 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1158 f0b75401 2019-08-03 stsp
1159 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1160 f0b75401 2019-08-03 stsp ret="$?"
1161 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1162 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1163 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1164 5f8a88c6 2019-08-03 stsp return 1
1165 5f8a88c6 2019-08-03 stsp fi
1166 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1167 5f8a88c6 2019-08-03 stsp ret="$?"
1168 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1169 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1170 5f8a88c6 2019-08-03 stsp fi
1171 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1172 5f8a88c6 2019-08-03 stsp }
1173 0f1cfa7f 2019-08-08 stsp
1174 0f1cfa7f 2019-08-08 stsp function test_stage_commit_out_of_date {
1175 0f1cfa7f 2019-08-08 stsp local testroot=`test_init stage_commit_out_of_date`
1176 0f1cfa7f 2019-08-08 stsp
1177 0f1cfa7f 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1178 0f1cfa7f 2019-08-08 stsp ret="$?"
1179 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1180 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1181 0f1cfa7f 2019-08-08 stsp return 1
1182 0f1cfa7f 2019-08-08 stsp fi
1183 0f1cfa7f 2019-08-08 stsp
1184 0f1cfa7f 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
1185 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
1186 0f1cfa7f 2019-08-08 stsp echo "new file" > $testroot/wt/foo
1187 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
1188 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1189 0f1cfa7f 2019-08-08 stsp
1190 0f1cfa7f 2019-08-08 stsp echo "changed file" > $testroot/repo/alpha
1191 0f1cfa7f 2019-08-08 stsp git_commit $testroot/repo -m "changed alpha in repo"
1192 0f1cfa7f 2019-08-08 stsp
1193 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1194 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1195 0f1cfa7f 2019-08-08 stsp ret="$?"
1196 0f1cfa7f 2019-08-08 stsp if [ "$ret" == "0" ]; then
1197 0f1cfa7f 2019-08-08 stsp echo "got commit command succeeded unexpectedly" >&2
1198 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "1"
1199 0f1cfa7f 2019-08-08 stsp return 1
1200 0f1cfa7f 2019-08-08 stsp fi
1201 0f1cfa7f 2019-08-08 stsp
1202 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1203 0f1cfa7f 2019-08-08 stsp echo -n "got: work tree must be updated before these changes " \
1204 0f1cfa7f 2019-08-08 stsp > $testroot/stderr.expected
1205 0f1cfa7f 2019-08-08 stsp echo "can be committed" >> $testroot/stderr.expected
1206 5f8a88c6 2019-08-03 stsp
1207 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1208 0f1cfa7f 2019-08-08 stsp ret="$?"
1209 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1210 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1211 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1212 0f1cfa7f 2019-08-08 stsp return 1
1213 0f1cfa7f 2019-08-08 stsp fi
1214 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1215 0f1cfa7f 2019-08-08 stsp ret="$?"
1216 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1217 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1218 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1219 0f1cfa7f 2019-08-08 stsp return 1
1220 0f1cfa7f 2019-08-08 stsp fi
1221 0f1cfa7f 2019-08-08 stsp
1222 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout \
1223 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1224 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1225 0f1cfa7f 2019-08-08 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1226 0f1cfa7f 2019-08-08 stsp
1227 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1228 0f1cfa7f 2019-08-08 stsp ret="$?"
1229 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1230 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1231 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1232 0f1cfa7f 2019-08-08 stsp return 1
1233 0f1cfa7f 2019-08-08 stsp fi
1234 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1235 0f1cfa7f 2019-08-08 stsp ret="$?"
1236 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1237 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1238 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1239 0f1cfa7f 2019-08-08 stsp return 1
1240 0f1cfa7f 2019-08-08 stsp fi
1241 0f1cfa7f 2019-08-08 stsp
1242 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got unstage > /dev/null)
1243 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
1244 0f1cfa7f 2019-08-08 stsp ret="$?"
1245 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1246 0f1cfa7f 2019-08-08 stsp echo "got update command failed unexpectedly" >&2
1247 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1248 0f1cfa7f 2019-08-08 stsp return 1
1249 0f1cfa7f 2019-08-08 stsp fi
1250 0f1cfa7f 2019-08-08 stsp
1251 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1252 0f1cfa7f 2019-08-08 stsp echo "C alpha" > $testroot/stdout.expected
1253 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1254 0f1cfa7f 2019-08-08 stsp echo "A foo" >> $testroot/stdout.expected
1255 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1256 0f1cfa7f 2019-08-08 stsp ret="$?"
1257 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1258 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1259 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1260 0f1cfa7f 2019-08-08 stsp return 1
1261 0f1cfa7f 2019-08-08 stsp fi
1262 0f1cfa7f 2019-08-08 stsp
1263 0f1cfa7f 2019-08-08 stsp # resolve conflict
1264 0f1cfa7f 2019-08-08 stsp echo "resolved file" > $testroot/wt/alpha
1265 0f1cfa7f 2019-08-08 stsp
1266 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
1267 0f1cfa7f 2019-08-08 stsp
1268 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1269 0f1cfa7f 2019-08-08 stsp ret="$?"
1270 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1271 0f1cfa7f 2019-08-08 stsp echo "got commit command failed unexpectedly" >&2
1272 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1273 0f1cfa7f 2019-08-08 stsp return 1
1274 0f1cfa7f 2019-08-08 stsp fi
1275 0f1cfa7f 2019-08-08 stsp
1276 0f1cfa7f 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1277 0f1cfa7f 2019-08-08 stsp echo "A foo" > $testroot/stdout.expected
1278 0f1cfa7f 2019-08-08 stsp echo "M alpha" >> $testroot/stdout.expected
1279 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1280 0f1cfa7f 2019-08-08 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1281 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1282 0f1cfa7f 2019-08-08 stsp ret="$?"
1283 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1284 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1285 0f1cfa7f 2019-08-08 stsp fi
1286 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1287 0f1cfa7f 2019-08-08 stsp
1288 0f1cfa7f 2019-08-08 stsp }
1289 0f1cfa7f 2019-08-08 stsp
1290 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1291 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1292 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1293 5f8a88c6 2019-08-03 stsp
1294 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1295 5f8a88c6 2019-08-03 stsp ret="$?"
1296 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1297 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1298 5f8a88c6 2019-08-03 stsp return 1
1299 5f8a88c6 2019-08-03 stsp fi
1300 5f8a88c6 2019-08-03 stsp
1301 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1302 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1303 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1304 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1305 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1306 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1307 5f8a88c6 2019-08-03 stsp
1308 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1309 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1310 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1311 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1312 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1313 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1314 5f8a88c6 2019-08-03 stsp
1315 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1316 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1317 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1318 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1319 5f8a88c6 2019-08-03 stsp
1320 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1321 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1322 5f8a88c6 2019-08-03 stsp ret="$?"
1323 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1324 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1325 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1326 5f8a88c6 2019-08-03 stsp return 1
1327 5f8a88c6 2019-08-03 stsp fi
1328 5f8a88c6 2019-08-03 stsp
1329 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1330 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1331 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1332 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1333 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1334 5f8a88c6 2019-08-03 stsp
1335 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1336 5f8a88c6 2019-08-03 stsp ret="$?"
1337 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1338 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1339 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1340 f0b75401 2019-08-03 stsp return 1
1341 f0b75401 2019-08-03 stsp fi
1342 5f8a88c6 2019-08-03 stsp
1343 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1344 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1345 5f8a88c6 2019-08-03 stsp
1346 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1347 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1348 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1349 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1350 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1351 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1352 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1353 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1354 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1355 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1356 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1357 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1358 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1359 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1360 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1361 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1362 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1363 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1364 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1365 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1366 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1367 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1368 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1369 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1370 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1371 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1372 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1373 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1374 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1375 5f8a88c6 2019-08-03 stsp
1376 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1377 f0b75401 2019-08-03 stsp ret="$?"
1378 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1379 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1380 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1381 5f8a88c6 2019-08-03 stsp return 1
1382 f0b75401 2019-08-03 stsp fi
1383 5f8a88c6 2019-08-03 stsp
1384 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1385 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1386 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1387 5f8a88c6 2019-08-03 stsp
1388 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1389 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1390 5f8a88c6 2019-08-03 stsp ret="$?"
1391 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1392 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1393 5f8a88c6 2019-08-03 stsp fi
1394 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1395 f0b75401 2019-08-03 stsp }
1396 dc424a06 2019-08-07 stsp
1397 dc424a06 2019-08-07 stsp function test_stage_patch {
1398 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1399 dc424a06 2019-08-07 stsp
1400 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1401 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1402 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1403 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1404 dc424a06 2019-08-07 stsp
1405 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1406 dc424a06 2019-08-07 stsp ret="$?"
1407 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1408 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1409 dc424a06 2019-08-07 stsp return 1
1410 dc424a06 2019-08-07 stsp fi
1411 dc424a06 2019-08-07 stsp
1412 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1413 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1414 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1415 dc424a06 2019-08-07 stsp
1416 dc424a06 2019-08-07 stsp # don't stage any hunks
1417 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1418 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1419 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1420 dc424a06 2019-08-07 stsp ret="$?"
1421 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1422 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1423 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1424 dc424a06 2019-08-07 stsp return 1
1425 dc424a06 2019-08-07 stsp fi
1426 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1427 dc424a06 2019-08-07 stsp -----------------------------------------------
1428 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1429 dc424a06 2019-08-07 stsp 1
1430 dc424a06 2019-08-07 stsp -2
1431 dc424a06 2019-08-07 stsp +a
1432 dc424a06 2019-08-07 stsp 3
1433 dc424a06 2019-08-07 stsp 4
1434 dc424a06 2019-08-07 stsp 5
1435 dc424a06 2019-08-07 stsp -----------------------------------------------
1436 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1437 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1438 dc424a06 2019-08-07 stsp -----------------------------------------------
1439 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1440 dc424a06 2019-08-07 stsp 4
1441 dc424a06 2019-08-07 stsp 5
1442 dc424a06 2019-08-07 stsp 6
1443 dc424a06 2019-08-07 stsp -7
1444 dc424a06 2019-08-07 stsp +b
1445 dc424a06 2019-08-07 stsp 8
1446 dc424a06 2019-08-07 stsp 9
1447 dc424a06 2019-08-07 stsp 10
1448 dc424a06 2019-08-07 stsp -----------------------------------------------
1449 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1450 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1451 dc424a06 2019-08-07 stsp -----------------------------------------------
1452 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1453 dc424a06 2019-08-07 stsp 13
1454 dc424a06 2019-08-07 stsp 14
1455 dc424a06 2019-08-07 stsp 15
1456 dc424a06 2019-08-07 stsp -16
1457 dc424a06 2019-08-07 stsp +c
1458 dc424a06 2019-08-07 stsp -----------------------------------------------
1459 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1460 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1461 dc424a06 2019-08-07 stsp EOF
1462 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1463 dc424a06 2019-08-07 stsp ret="$?"
1464 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1465 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1466 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1467 dc424a06 2019-08-07 stsp return 1
1468 dc424a06 2019-08-07 stsp fi
1469 f0b75401 2019-08-03 stsp
1470 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1471 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1472 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1473 dc424a06 2019-08-07 stsp ret="$?"
1474 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1475 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1476 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1477 dc424a06 2019-08-07 stsp return 1
1478 dc424a06 2019-08-07 stsp fi
1479 dc424a06 2019-08-07 stsp
1480 dc424a06 2019-08-07 stsp # stage middle hunk
1481 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1482 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1483 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1484 dc424a06 2019-08-07 stsp
1485 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1486 dc424a06 2019-08-07 stsp -----------------------------------------------
1487 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1488 dc424a06 2019-08-07 stsp 1
1489 dc424a06 2019-08-07 stsp -2
1490 dc424a06 2019-08-07 stsp +a
1491 dc424a06 2019-08-07 stsp 3
1492 dc424a06 2019-08-07 stsp 4
1493 dc424a06 2019-08-07 stsp 5
1494 dc424a06 2019-08-07 stsp -----------------------------------------------
1495 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1496 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1497 dc424a06 2019-08-07 stsp -----------------------------------------------
1498 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1499 dc424a06 2019-08-07 stsp 4
1500 dc424a06 2019-08-07 stsp 5
1501 dc424a06 2019-08-07 stsp 6
1502 dc424a06 2019-08-07 stsp -7
1503 dc424a06 2019-08-07 stsp +b
1504 dc424a06 2019-08-07 stsp 8
1505 dc424a06 2019-08-07 stsp 9
1506 dc424a06 2019-08-07 stsp 10
1507 dc424a06 2019-08-07 stsp -----------------------------------------------
1508 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1509 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1510 dc424a06 2019-08-07 stsp -----------------------------------------------
1511 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1512 dc424a06 2019-08-07 stsp 13
1513 dc424a06 2019-08-07 stsp 14
1514 dc424a06 2019-08-07 stsp 15
1515 dc424a06 2019-08-07 stsp -16
1516 dc424a06 2019-08-07 stsp +c
1517 dc424a06 2019-08-07 stsp -----------------------------------------------
1518 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1519 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1520 dc424a06 2019-08-07 stsp EOF
1521 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1522 dc424a06 2019-08-07 stsp ret="$?"
1523 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1524 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1525 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1526 dc424a06 2019-08-07 stsp return 1
1527 dc424a06 2019-08-07 stsp fi
1528 dc424a06 2019-08-07 stsp
1529 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1530 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1531 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1532 dc424a06 2019-08-07 stsp ret="$?"
1533 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1534 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1535 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1536 dc424a06 2019-08-07 stsp return 1
1537 dc424a06 2019-08-07 stsp fi
1538 dc424a06 2019-08-07 stsp
1539 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1540 dc424a06 2019-08-07 stsp
1541 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1542 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1543 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1544 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1545 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1546 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1547 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1548 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1549 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1550 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1551 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1552 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1553 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1554 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1555 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1556 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1557 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1558 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1559 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1560 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1561 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1562 dc424a06 2019-08-07 stsp ret="$?"
1563 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1564 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1565 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1566 dc424a06 2019-08-07 stsp return 1
1567 dc424a06 2019-08-07 stsp fi
1568 dc424a06 2019-08-07 stsp
1569 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1570 dc424a06 2019-08-07 stsp ret="$?"
1571 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1572 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1573 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1574 dc424a06 2019-08-07 stsp return 1
1575 dc424a06 2019-08-07 stsp fi
1576 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1577 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1578 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1579 dc424a06 2019-08-07 stsp ret="$?"
1580 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1581 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1582 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1583 dc424a06 2019-08-07 stsp return 1
1584 dc424a06 2019-08-07 stsp fi
1585 dc424a06 2019-08-07 stsp
1586 dc424a06 2019-08-07 stsp # stage last hunk
1587 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1588 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1589 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1590 dc424a06 2019-08-07 stsp
1591 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1592 dc424a06 2019-08-07 stsp -----------------------------------------------
1593 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1594 dc424a06 2019-08-07 stsp 1
1595 dc424a06 2019-08-07 stsp -2
1596 dc424a06 2019-08-07 stsp +a
1597 dc424a06 2019-08-07 stsp 3
1598 dc424a06 2019-08-07 stsp 4
1599 dc424a06 2019-08-07 stsp 5
1600 dc424a06 2019-08-07 stsp -----------------------------------------------
1601 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1602 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1603 dc424a06 2019-08-07 stsp -----------------------------------------------
1604 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1605 dc424a06 2019-08-07 stsp 4
1606 dc424a06 2019-08-07 stsp 5
1607 dc424a06 2019-08-07 stsp 6
1608 dc424a06 2019-08-07 stsp -7
1609 dc424a06 2019-08-07 stsp +b
1610 dc424a06 2019-08-07 stsp 8
1611 dc424a06 2019-08-07 stsp 9
1612 dc424a06 2019-08-07 stsp 10
1613 dc424a06 2019-08-07 stsp -----------------------------------------------
1614 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1615 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1616 dc424a06 2019-08-07 stsp -----------------------------------------------
1617 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1618 dc424a06 2019-08-07 stsp 13
1619 dc424a06 2019-08-07 stsp 14
1620 dc424a06 2019-08-07 stsp 15
1621 dc424a06 2019-08-07 stsp -16
1622 dc424a06 2019-08-07 stsp +c
1623 dc424a06 2019-08-07 stsp -----------------------------------------------
1624 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1625 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1626 dc424a06 2019-08-07 stsp EOF
1627 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1628 dc424a06 2019-08-07 stsp ret="$?"
1629 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1630 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1631 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1632 dc424a06 2019-08-07 stsp return 1
1633 dc424a06 2019-08-07 stsp fi
1634 dc424a06 2019-08-07 stsp
1635 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1636 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1637 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1638 dc424a06 2019-08-07 stsp ret="$?"
1639 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1640 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1641 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1642 dc424a06 2019-08-07 stsp return 1
1643 dc424a06 2019-08-07 stsp fi
1644 dc424a06 2019-08-07 stsp
1645 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1646 dc424a06 2019-08-07 stsp
1647 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1648 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1649 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1650 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1651 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1652 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1653 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1654 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1655 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1656 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1657 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1658 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1659 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1660 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1661 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1662 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1663 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1664 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1665 af5a81b2 2019-08-08 stsp ret="$?"
1666 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1667 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1668 af5a81b2 2019-08-08 stsp fi
1669 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1670 af5a81b2 2019-08-08 stsp }
1671 af5a81b2 2019-08-08 stsp
1672 af5a81b2 2019-08-08 stsp function test_stage_patch_twice {
1673 af5a81b2 2019-08-08 stsp local testroot=`test_init stage_patch_twice`
1674 af5a81b2 2019-08-08 stsp
1675 af5a81b2 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1676 af5a81b2 2019-08-08 stsp (cd $testroot/repo && git add numbers)
1677 af5a81b2 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
1678 af5a81b2 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1679 af5a81b2 2019-08-08 stsp
1680 af5a81b2 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1681 af5a81b2 2019-08-08 stsp ret="$?"
1682 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1683 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1684 af5a81b2 2019-08-08 stsp return 1
1685 af5a81b2 2019-08-08 stsp fi
1686 af5a81b2 2019-08-08 stsp
1687 af5a81b2 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1688 af5a81b2 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1689 af5a81b2 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1690 af5a81b2 2019-08-08 stsp
1691 af5a81b2 2019-08-08 stsp # stage middle hunk
1692 af5a81b2 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
1693 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1694 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1695 af5a81b2 2019-08-08 stsp
1696 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1697 af5a81b2 2019-08-08 stsp -----------------------------------------------
1698 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1699 af5a81b2 2019-08-08 stsp 1
1700 af5a81b2 2019-08-08 stsp -2
1701 af5a81b2 2019-08-08 stsp +a
1702 af5a81b2 2019-08-08 stsp 3
1703 af5a81b2 2019-08-08 stsp 4
1704 af5a81b2 2019-08-08 stsp 5
1705 af5a81b2 2019-08-08 stsp -----------------------------------------------
1706 af5a81b2 2019-08-08 stsp M numbers (change 1 of 3)
1707 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1708 af5a81b2 2019-08-08 stsp -----------------------------------------------
1709 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1710 af5a81b2 2019-08-08 stsp 4
1711 af5a81b2 2019-08-08 stsp 5
1712 af5a81b2 2019-08-08 stsp 6
1713 af5a81b2 2019-08-08 stsp -7
1714 af5a81b2 2019-08-08 stsp +b
1715 af5a81b2 2019-08-08 stsp 8
1716 af5a81b2 2019-08-08 stsp 9
1717 af5a81b2 2019-08-08 stsp 10
1718 af5a81b2 2019-08-08 stsp -----------------------------------------------
1719 af5a81b2 2019-08-08 stsp M numbers (change 2 of 3)
1720 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1721 af5a81b2 2019-08-08 stsp -----------------------------------------------
1722 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1723 af5a81b2 2019-08-08 stsp 13
1724 af5a81b2 2019-08-08 stsp 14
1725 af5a81b2 2019-08-08 stsp 15
1726 af5a81b2 2019-08-08 stsp -16
1727 af5a81b2 2019-08-08 stsp +c
1728 af5a81b2 2019-08-08 stsp -----------------------------------------------
1729 af5a81b2 2019-08-08 stsp M numbers (change 3 of 3)
1730 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1731 af5a81b2 2019-08-08 stsp EOF
1732 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1733 af5a81b2 2019-08-08 stsp ret="$?"
1734 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1735 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1736 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1737 af5a81b2 2019-08-08 stsp return 1
1738 af5a81b2 2019-08-08 stsp fi
1739 af5a81b2 2019-08-08 stsp
1740 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1741 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1742 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1743 af5a81b2 2019-08-08 stsp ret="$?"
1744 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1745 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1746 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1747 af5a81b2 2019-08-08 stsp return 1
1748 af5a81b2 2019-08-08 stsp fi
1749 af5a81b2 2019-08-08 stsp
1750 af5a81b2 2019-08-08 stsp # stage last hunk
1751 af5a81b2 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
1752 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1753 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1754 af5a81b2 2019-08-08 stsp
1755 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1756 af5a81b2 2019-08-08 stsp -----------------------------------------------
1757 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@ b
1758 af5a81b2 2019-08-08 stsp 1
1759 af5a81b2 2019-08-08 stsp -2
1760 af5a81b2 2019-08-08 stsp +a
1761 af5a81b2 2019-08-08 stsp 3
1762 af5a81b2 2019-08-08 stsp 4
1763 af5a81b2 2019-08-08 stsp 5
1764 af5a81b2 2019-08-08 stsp -----------------------------------------------
1765 af5a81b2 2019-08-08 stsp M numbers (change 1 of 2)
1766 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1767 af5a81b2 2019-08-08 stsp -----------------------------------------------
1768 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@ b
1769 af5a81b2 2019-08-08 stsp 13
1770 af5a81b2 2019-08-08 stsp 14
1771 af5a81b2 2019-08-08 stsp 15
1772 af5a81b2 2019-08-08 stsp -16
1773 af5a81b2 2019-08-08 stsp +c
1774 af5a81b2 2019-08-08 stsp -----------------------------------------------
1775 af5a81b2 2019-08-08 stsp M numbers (change 2 of 2)
1776 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1777 af5a81b2 2019-08-08 stsp EOF
1778 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1779 af5a81b2 2019-08-08 stsp ret="$?"
1780 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1781 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1782 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1783 af5a81b2 2019-08-08 stsp return 1
1784 af5a81b2 2019-08-08 stsp fi
1785 af5a81b2 2019-08-08 stsp
1786 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1787 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1788 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1789 af5a81b2 2019-08-08 stsp ret="$?"
1790 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1791 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1792 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1793 af5a81b2 2019-08-08 stsp return 1
1794 af5a81b2 2019-08-08 stsp fi
1795 af5a81b2 2019-08-08 stsp
1796 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1797 af5a81b2 2019-08-08 stsp
1798 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1799 af5a81b2 2019-08-08 stsp > $testroot/stdout.expected
1800 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1801 af5a81b2 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
1802 af5a81b2 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1803 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1804 af5a81b2 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1805 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1806 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1807 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1808 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1809 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1810 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1811 af5a81b2 2019-08-08 stsp 4
1812 af5a81b2 2019-08-08 stsp 5
1813 af5a81b2 2019-08-08 stsp 6
1814 af5a81b2 2019-08-08 stsp -7
1815 af5a81b2 2019-08-08 stsp +b
1816 af5a81b2 2019-08-08 stsp 8
1817 af5a81b2 2019-08-08 stsp 9
1818 af5a81b2 2019-08-08 stsp 10
1819 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1820 af5a81b2 2019-08-08 stsp 13
1821 af5a81b2 2019-08-08 stsp 14
1822 af5a81b2 2019-08-08 stsp 15
1823 af5a81b2 2019-08-08 stsp -16
1824 af5a81b2 2019-08-08 stsp +c
1825 af5a81b2 2019-08-08 stsp EOF
1826 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1827 af5a81b2 2019-08-08 stsp ret="$?"
1828 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1829 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1830 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1831 af5a81b2 2019-08-08 stsp return 1
1832 af5a81b2 2019-08-08 stsp fi
1833 af5a81b2 2019-08-08 stsp
1834 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1835 af5a81b2 2019-08-08 stsp
1836 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
1837 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1838 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
1839 af5a81b2 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
1840 af5a81b2 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
1841 af5a81b2 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
1842 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1843 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1844 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1845 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1846 af5a81b2 2019-08-08 stsp 1
1847 af5a81b2 2019-08-08 stsp -2
1848 af5a81b2 2019-08-08 stsp +a
1849 af5a81b2 2019-08-08 stsp 3
1850 af5a81b2 2019-08-08 stsp 4
1851 af5a81b2 2019-08-08 stsp 5
1852 af5a81b2 2019-08-08 stsp EOF
1853 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1854 dc424a06 2019-08-07 stsp ret="$?"
1855 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1856 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1857 dc424a06 2019-08-07 stsp fi
1858 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1859 dc424a06 2019-08-07 stsp }
1860 dc424a06 2019-08-07 stsp
1861 dc424a06 2019-08-07 stsp function test_stage_patch_added {
1862 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1863 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1864 dc424a06 2019-08-07 stsp
1865 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1866 dc424a06 2019-08-07 stsp ret="$?"
1867 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1868 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1869 dc424a06 2019-08-07 stsp return 1
1870 dc424a06 2019-08-07 stsp fi
1871 dc424a06 2019-08-07 stsp
1872 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1873 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1874 dc424a06 2019-08-07 stsp
1875 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1876 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1877 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1878 dc424a06 2019-08-07 stsp
1879 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1880 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1881 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1882 dc424a06 2019-08-07 stsp ret="$?"
1883 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1884 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1885 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1886 dc424a06 2019-08-07 stsp return 1
1887 dc424a06 2019-08-07 stsp fi
1888 dc424a06 2019-08-07 stsp
1889 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1890 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1891 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1892 dc424a06 2019-08-07 stsp ret="$?"
1893 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1894 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1895 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1896 dc424a06 2019-08-07 stsp return 1
1897 dc424a06 2019-08-07 stsp fi
1898 dc424a06 2019-08-07 stsp
1899 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1900 dc424a06 2019-08-07 stsp
1901 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1902 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1903 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1904 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1905 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1906 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1907 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1908 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1909 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1910 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1911 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1912 e70a841e 2019-08-08 stsp ret="$?"
1913 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1914 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1915 e70a841e 2019-08-08 stsp fi
1916 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1917 e70a841e 2019-08-08 stsp }
1918 e70a841e 2019-08-08 stsp
1919 e70a841e 2019-08-08 stsp function test_stage_patch_added_twice {
1920 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_added_twice`
1921 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1922 e70a841e 2019-08-08 stsp
1923 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1924 e70a841e 2019-08-08 stsp ret="$?"
1925 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1926 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1927 e70a841e 2019-08-08 stsp return 1
1928 e70a841e 2019-08-08 stsp fi
1929 e70a841e 2019-08-08 stsp
1930 e70a841e 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
1931 e70a841e 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1932 e70a841e 2019-08-08 stsp
1933 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1934 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1935 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout)
1936 e70a841e 2019-08-08 stsp
1937 e70a841e 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
1938 e70a841e 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1939 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1940 e70a841e 2019-08-08 stsp ret="$?"
1941 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1942 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1943 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1944 e70a841e 2019-08-08 stsp return 1
1945 e70a841e 2019-08-08 stsp fi
1946 e70a841e 2019-08-08 stsp
1947 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1948 e70a841e 2019-08-08 stsp echo " A epsilon/new" > $testroot/stdout.expected
1949 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1950 dc424a06 2019-08-07 stsp ret="$?"
1951 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1952 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1953 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1954 e70a841e 2019-08-08 stsp return 1
1955 dc424a06 2019-08-07 stsp fi
1956 e70a841e 2019-08-08 stsp
1957 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1958 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout 2> $testroot/stderr)
1959 e70a841e 2019-08-08 stsp ret="$?"
1960 e70a841e 2019-08-08 stsp if [ "$ret" == "0" ]; then
1961 e70a841e 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
1962 e70a841e 2019-08-08 stsp test_done "$testroot" "1"
1963 e70a841e 2019-08-08 stsp return 1
1964 e70a841e 2019-08-08 stsp fi
1965 e70a841e 2019-08-08 stsp
1966 e70a841e 2019-08-08 stsp echo "got: epsilon/new: no changes to stage" > $testroot/stderr.expected
1967 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1968 e70a841e 2019-08-08 stsp ret="$?"
1969 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1970 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1971 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1972 e70a841e 2019-08-08 stsp return 1
1973 e70a841e 2019-08-08 stsp fi
1974 e70a841e 2019-08-08 stsp
1975 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
1976 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1977 e70a841e 2019-08-08 stsp ret="$?"
1978 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1979 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1980 e70a841e 2019-08-08 stsp fi
1981 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1982 dc424a06 2019-08-07 stsp }
1983 dc424a06 2019-08-07 stsp
1984 dc424a06 2019-08-07 stsp function test_stage_patch_removed {
1985 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
1986 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1987 dc424a06 2019-08-07 stsp
1988 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1989 dc424a06 2019-08-07 stsp ret="$?"
1990 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1991 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1992 dc424a06 2019-08-07 stsp return 1
1993 dc424a06 2019-08-07 stsp fi
1994 dc424a06 2019-08-07 stsp
1995 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
1996 dc424a06 2019-08-07 stsp
1997 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1998 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1999 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
2000 dc424a06 2019-08-07 stsp
2001 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
2002 dc424a06 2019-08-07 stsp
2003 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
2004 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2005 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2006 dc424a06 2019-08-07 stsp ret="$?"
2007 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2008 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2009 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2010 dc424a06 2019-08-07 stsp return 1
2011 dc424a06 2019-08-07 stsp fi
2012 dc424a06 2019-08-07 stsp
2013 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2014 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
2015 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2016 dc424a06 2019-08-07 stsp ret="$?"
2017 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2018 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2019 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2020 dc424a06 2019-08-07 stsp return 1
2021 dc424a06 2019-08-07 stsp fi
2022 dc424a06 2019-08-07 stsp
2023 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2024 dc424a06 2019-08-07 stsp
2025 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2026 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
2027 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2028 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
2029 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
2030 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2031 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
2032 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
2033 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
2034 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
2035 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2036 dc424a06 2019-08-07 stsp ret="$?"
2037 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2038 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2039 dc424a06 2019-08-07 stsp fi
2040 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2041 dc424a06 2019-08-07 stsp }
2042 b353a198 2019-08-07 stsp
2043 e70a841e 2019-08-08 stsp function test_stage_patch_removed_twice {
2044 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_removed_twice`
2045 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2046 e70a841e 2019-08-08 stsp
2047 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2048 e70a841e 2019-08-08 stsp ret="$?"
2049 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2050 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2051 e70a841e 2019-08-08 stsp return 1
2052 e70a841e 2019-08-08 stsp fi
2053 e70a841e 2019-08-08 stsp
2054 e70a841e 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
2055 e70a841e 2019-08-08 stsp
2056 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2057 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2058 e70a841e 2019-08-08 stsp beta > $testroot/stdout)
2059 e70a841e 2019-08-08 stsp
2060 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2061 e70a841e 2019-08-08 stsp
2062 e70a841e 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
2063 e70a841e 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2064 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2065 e70a841e 2019-08-08 stsp ret="$?"
2066 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2067 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2068 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2069 e70a841e 2019-08-08 stsp return 1
2070 e70a841e 2019-08-08 stsp fi
2071 e70a841e 2019-08-08 stsp
2072 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2073 e70a841e 2019-08-08 stsp echo " D beta" > $testroot/stdout.expected
2074 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2075 e70a841e 2019-08-08 stsp ret="$?"
2076 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2077 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2078 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2079 e70a841e 2019-08-08 stsp return 1
2080 e70a841e 2019-08-08 stsp fi
2081 e70a841e 2019-08-08 stsp
2082 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p beta \
2083 e70a841e 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2084 e70a841e 2019-08-08 stsp ret="$?"
2085 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2086 e70a841e 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
2087 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2088 e70a841e 2019-08-08 stsp return 1
2089 e70a841e 2019-08-08 stsp fi
2090 e70a841e 2019-08-08 stsp
2091 e70a841e 2019-08-08 stsp echo -n > $testroot/stderr.expected
2092 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2093 e70a841e 2019-08-08 stsp ret="$?"
2094 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2095 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2096 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2097 e70a841e 2019-08-08 stsp return 1
2098 e70a841e 2019-08-08 stsp fi
2099 e70a841e 2019-08-08 stsp
2100 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2101 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2102 e70a841e 2019-08-08 stsp ret="$?"
2103 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2104 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2105 e70a841e 2019-08-08 stsp fi
2106 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2107 e70a841e 2019-08-08 stsp }
2108 e70a841e 2019-08-08 stsp
2109 b353a198 2019-08-07 stsp function test_stage_patch_quit {
2110 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
2111 b353a198 2019-08-07 stsp
2112 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
2113 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2114 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2115 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2116 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2117 b353a198 2019-08-07 stsp
2118 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2119 b353a198 2019-08-07 stsp ret="$?"
2120 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2121 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2122 b353a198 2019-08-07 stsp return 1
2123 b353a198 2019-08-07 stsp fi
2124 dc424a06 2019-08-07 stsp
2125 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2126 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2127 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2128 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
2129 b353a198 2019-08-07 stsp
2130 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
2131 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
2132 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
2133 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2134 2db2652d 2019-08-07 stsp > $testroot/stdout)
2135 b353a198 2019-08-07 stsp ret="$?"
2136 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2137 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
2138 b353a198 2019-08-07 stsp test_done "$testroot" "1"
2139 b353a198 2019-08-07 stsp return 1
2140 b353a198 2019-08-07 stsp fi
2141 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
2142 b353a198 2019-08-07 stsp -----------------------------------------------
2143 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
2144 b353a198 2019-08-07 stsp 1
2145 b353a198 2019-08-07 stsp -2
2146 b353a198 2019-08-07 stsp +a
2147 b353a198 2019-08-07 stsp 3
2148 b353a198 2019-08-07 stsp 4
2149 b353a198 2019-08-07 stsp 5
2150 b353a198 2019-08-07 stsp -----------------------------------------------
2151 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
2152 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
2153 b353a198 2019-08-07 stsp -----------------------------------------------
2154 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
2155 b353a198 2019-08-07 stsp 4
2156 b353a198 2019-08-07 stsp 5
2157 b353a198 2019-08-07 stsp 6
2158 b353a198 2019-08-07 stsp -7
2159 b353a198 2019-08-07 stsp +b
2160 b353a198 2019-08-07 stsp 8
2161 b353a198 2019-08-07 stsp 9
2162 b353a198 2019-08-07 stsp 10
2163 b353a198 2019-08-07 stsp -----------------------------------------------
2164 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
2165 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
2166 88f33a19 2019-08-08 stsp D zzz
2167 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
2168 b353a198 2019-08-07 stsp EOF
2169 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2170 b353a198 2019-08-07 stsp ret="$?"
2171 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2172 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2173 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2174 b353a198 2019-08-07 stsp return 1
2175 b353a198 2019-08-07 stsp fi
2176 b353a198 2019-08-07 stsp
2177 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2178 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
2179 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
2180 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2181 b353a198 2019-08-07 stsp ret="$?"
2182 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2183 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2184 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2185 b353a198 2019-08-07 stsp return 1
2186 b353a198 2019-08-07 stsp fi
2187 b353a198 2019-08-07 stsp
2188 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2189 b353a198 2019-08-07 stsp
2190 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2191 b353a198 2019-08-07 stsp > $testroot/stdout.expected
2192 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2193 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
2194 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
2195 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2196 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2197 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
2198 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2199 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
2200 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
2201 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
2202 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
2203 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
2204 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
2205 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
2206 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
2207 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
2208 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2209 b353a198 2019-08-07 stsp ret="$?"
2210 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2211 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2212 b353a198 2019-08-07 stsp fi
2213 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2214 b353a198 2019-08-07 stsp
2215 b353a198 2019-08-07 stsp }
2216 b353a198 2019-08-07 stsp
2217 eba70f38 2019-08-08 stsp function test_stage_patch_incomplete_script {
2218 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
2219 eba70f38 2019-08-08 stsp
2220 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
2221 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2222 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2223 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2224 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2225 eba70f38 2019-08-08 stsp
2226 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2227 eba70f38 2019-08-08 stsp ret="$?"
2228 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2229 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2230 eba70f38 2019-08-08 stsp return 1
2231 eba70f38 2019-08-08 stsp fi
2232 eba70f38 2019-08-08 stsp
2233 eba70f38 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2234 eba70f38 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2235 eba70f38 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2236 eba70f38 2019-08-08 stsp
2237 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
2238 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2239 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2240 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2241 eba70f38 2019-08-08 stsp ret="$?"
2242 eba70f38 2019-08-08 stsp if [ "$ret" == "0" ]; then
2243 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2244 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
2245 eba70f38 2019-08-08 stsp return 1
2246 eba70f38 2019-08-08 stsp fi
2247 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
2248 eba70f38 2019-08-08 stsp -----------------------------------------------
2249 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
2250 eba70f38 2019-08-08 stsp 1
2251 eba70f38 2019-08-08 stsp -2
2252 eba70f38 2019-08-08 stsp +a
2253 eba70f38 2019-08-08 stsp 3
2254 eba70f38 2019-08-08 stsp 4
2255 eba70f38 2019-08-08 stsp 5
2256 eba70f38 2019-08-08 stsp -----------------------------------------------
2257 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
2258 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
2259 eba70f38 2019-08-08 stsp -----------------------------------------------
2260 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
2261 eba70f38 2019-08-08 stsp 4
2262 eba70f38 2019-08-08 stsp 5
2263 eba70f38 2019-08-08 stsp 6
2264 eba70f38 2019-08-08 stsp -7
2265 eba70f38 2019-08-08 stsp +b
2266 eba70f38 2019-08-08 stsp 8
2267 eba70f38 2019-08-08 stsp 9
2268 eba70f38 2019-08-08 stsp 10
2269 eba70f38 2019-08-08 stsp -----------------------------------------------
2270 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
2271 eba70f38 2019-08-08 stsp EOF
2272 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
2273 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
2274 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2275 eba70f38 2019-08-08 stsp ret="$?"
2276 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2277 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2278 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2279 eba70f38 2019-08-08 stsp return 1
2280 eba70f38 2019-08-08 stsp fi
2281 eba70f38 2019-08-08 stsp
2282 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2283 eba70f38 2019-08-08 stsp ret="$?"
2284 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2285 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2286 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2287 eba70f38 2019-08-08 stsp return 1
2288 eba70f38 2019-08-08 stsp fi
2289 eba70f38 2019-08-08 stsp
2290 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2291 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
2292 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2293 eba70f38 2019-08-08 stsp ret="$?"
2294 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2295 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2296 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2297 eba70f38 2019-08-08 stsp return 1
2298 eba70f38 2019-08-08 stsp fi
2299 eba70f38 2019-08-08 stsp
2300 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2301 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
2302 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2303 eba70f38 2019-08-08 stsp ret="$?"
2304 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2305 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2306 eba70f38 2019-08-08 stsp fi
2307 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2308 eba70f38 2019-08-08 stsp
2309 eba70f38 2019-08-08 stsp }
2310 eba70f38 2019-08-08 stsp
2311 fccbfb98 2019-08-03 stsp run_test test_stage_basic
2312 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
2313 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
2314 8564cb21 2019-08-08 stsp run_test test_stage_nonexistent
2315 a4f692bb 2019-08-04 stsp run_test test_stage_list
2316 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
2317 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
2318 d3e7c587 2019-08-03 stsp run_test test_double_stage
2319 c363b2c1 2019-08-03 stsp run_test test_stage_status
2320 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
2321 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
2322 24278f30 2019-08-03 stsp run_test test_stage_revert
2323 408b4ebc 2019-08-03 stsp run_test test_stage_diff
2324 b9622844 2019-08-03 stsp run_test test_stage_histedit
2325 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
2326 a76c42e6 2019-08-03 stsp run_test test_stage_update
2327 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
2328 0f1cfa7f 2019-08-08 stsp run_test test_stage_commit_out_of_date
2329 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
2330 dc424a06 2019-08-07 stsp run_test test_stage_patch
2331 af5a81b2 2019-08-08 stsp run_test test_stage_patch_twice
2332 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
2333 e70a841e 2019-08-08 stsp run_test test_stage_patch_added_twice
2334 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
2335 e70a841e 2019-08-08 stsp run_test test_stage_patch_removed_twice
2336 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
2337 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script