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