Blame


1 fccbfb98 2019-08-03 stsp #!/bin/sh
2 fccbfb98 2019-08-03 stsp #
3 fccbfb98 2019-08-03 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 fccbfb98 2019-08-03 stsp #
5 fccbfb98 2019-08-03 stsp # Permission to use, copy, modify, and distribute this software for any
6 fccbfb98 2019-08-03 stsp # purpose with or without fee is hereby granted, provided that the above
7 fccbfb98 2019-08-03 stsp # copyright notice and this permission notice appear in all copies.
8 fccbfb98 2019-08-03 stsp #
9 fccbfb98 2019-08-03 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 fccbfb98 2019-08-03 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 fccbfb98 2019-08-03 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 fccbfb98 2019-08-03 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 fccbfb98 2019-08-03 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 fccbfb98 2019-08-03 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 fccbfb98 2019-08-03 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 fccbfb98 2019-08-03 stsp
17 fccbfb98 2019-08-03 stsp . ./common.sh
18 fccbfb98 2019-08-03 stsp
19 fccbfb98 2019-08-03 stsp function test_stage_basic {
20 fccbfb98 2019-08-03 stsp local testroot=`test_init stage_basic`
21 fccbfb98 2019-08-03 stsp
22 fccbfb98 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 fccbfb98 2019-08-03 stsp ret="$?"
24 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
25 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
26 fccbfb98 2019-08-03 stsp return 1
27 fccbfb98 2019-08-03 stsp fi
28 fccbfb98 2019-08-03 stsp
29 fccbfb98 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
30 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
31 fccbfb98 2019-08-03 stsp echo "new file" > $testroot/wt/foo
32 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
33 fccbfb98 2019-08-03 stsp
34 88d0e355 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
35 88d0e355 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
36 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
37 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
38 d3e7c587 2019-08-03 stsp
39 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
40 d3e7c587 2019-08-03 stsp ret="$?"
41 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
42 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
43 d3e7c587 2019-08-03 stsp fi
44 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
45 d3e7c587 2019-08-03 stsp }
46 d3e7c587 2019-08-03 stsp
47 31b20a6e 2019-08-06 stsp function test_stage_no_changes {
48 31b20a6e 2019-08-06 stsp local testroot=`test_init stage_no_changes`
49 31b20a6e 2019-08-06 stsp
50 31b20a6e 2019-08-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
51 31b20a6e 2019-08-06 stsp ret="$?"
52 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
53 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
54 31b20a6e 2019-08-06 stsp return 1
55 31b20a6e 2019-08-06 stsp fi
56 31b20a6e 2019-08-06 stsp
57 31b20a6e 2019-08-06 stsp (cd $testroot/wt && got stage alpha beta > $testroot/stdout \
58 31b20a6e 2019-08-06 stsp 2> $testroot/stderr)
59 31b20a6e 2019-08-06 stsp ret="$?"
60 31b20a6e 2019-08-06 stsp if [ "$ret" == "0" ]; then
61 31b20a6e 2019-08-06 stsp echo "got stage command succeeded unexpectedly" >&2
62 31b20a6e 2019-08-06 stsp test_done "$testroot" "1"
63 31b20a6e 2019-08-06 stsp return 1
64 31b20a6e 2019-08-06 stsp fi
65 31b20a6e 2019-08-06 stsp
66 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 a4f692bb 2019-08-04 stsp function test_stage_list {
86 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
87 a4f692bb 2019-08-04 stsp
88 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
89 a4f692bb 2019-08-04 stsp ret="$?"
90 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
91 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
92 a4f692bb 2019-08-04 stsp return 1
93 a4f692bb 2019-08-04 stsp fi
94 a4f692bb 2019-08-04 stsp
95 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
96 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
97 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
98 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
99 a4f692bb 2019-08-04 stsp
100 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
101 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
102 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
103 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
104 a4f692bb 2019-08-04 stsp
105 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
106 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
107 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
108 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
109 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
110 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
111 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
112 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
113 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
114 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
115 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
116 a4f692bb 2019-08-04 stsp ret="$?"
117 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
118 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
119 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
120 a4f692bb 2019-08-04 stsp return 1
121 a4f692bb 2019-08-04 stsp fi
122 a4f692bb 2019-08-04 stsp
123 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
124 a4f692bb 2019-08-04 stsp > $testroot/stdout)
125 a4f692bb 2019-08-04 stsp
126 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
127 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
128 a4f692bb 2019-08-04 stsp ret="$?"
129 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
130 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
131 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
132 a4f692bb 2019-08-04 stsp return 1
133 a4f692bb 2019-08-04 stsp fi
134 a4f692bb 2019-08-04 stsp
135 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
136 a4f692bb 2019-08-04 stsp
137 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
138 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
139 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
140 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
141 a4f692bb 2019-08-04 stsp ret="$?"
142 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
143 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
144 a4f692bb 2019-08-04 stsp fi
145 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
146 a4f692bb 2019-08-04 stsp
147 a4f692bb 2019-08-04 stsp }
148 a4f692bb 2019-08-04 stsp
149 ebf48fd5 2019-08-03 stsp function test_stage_conflict {
150 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
151 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
152 ebf48fd5 2019-08-03 stsp
153 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
154 ebf48fd5 2019-08-03 stsp ret="$?"
155 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
156 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
157 ebf48fd5 2019-08-03 stsp return 1
158 ebf48fd5 2019-08-03 stsp fi
159 ebf48fd5 2019-08-03 stsp
160 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
161 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
162 ebf48fd5 2019-08-03 stsp
163 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
164 ebf48fd5 2019-08-03 stsp
165 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
166 ebf48fd5 2019-08-03 stsp
167 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
168 ebf48fd5 2019-08-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
169 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
170 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
171 ebf48fd5 2019-08-03 stsp
172 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
173 ebf48fd5 2019-08-03 stsp
174 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
175 ebf48fd5 2019-08-03 stsp ret="$?"
176 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
177 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
178 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
179 ebf48fd5 2019-08-03 stsp return 1
180 ebf48fd5 2019-08-03 stsp fi
181 ebf48fd5 2019-08-03 stsp
182 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
183 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
184 ebf48fd5 2019-08-03 stsp ret="$?"
185 ebf48fd5 2019-08-03 stsp if [ "$ret" == "0" ]; then
186 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
187 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
188 ebf48fd5 2019-08-03 stsp return 1
189 ebf48fd5 2019-08-03 stsp fi
190 ebf48fd5 2019-08-03 stsp
191 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
192 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
193 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
194 735ef5ac 2019-08-03 stsp
195 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
196 735ef5ac 2019-08-03 stsp ret="$?"
197 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
198 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
199 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
200 735ef5ac 2019-08-03 stsp return 1
201 735ef5ac 2019-08-03 stsp fi
202 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
203 735ef5ac 2019-08-03 stsp ret="$?"
204 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
205 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
206 735ef5ac 2019-08-03 stsp fi
207 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
208 735ef5ac 2019-08-03 stsp }
209 735ef5ac 2019-08-03 stsp
210 735ef5ac 2019-08-03 stsp function test_stage_out_of_date {
211 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
212 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
213 735ef5ac 2019-08-03 stsp
214 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
215 735ef5ac 2019-08-03 stsp ret="$?"
216 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
217 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
218 735ef5ac 2019-08-03 stsp return 1
219 735ef5ac 2019-08-03 stsp fi
220 735ef5ac 2019-08-03 stsp
221 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
222 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
223 735ef5ac 2019-08-03 stsp
224 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
225 735ef5ac 2019-08-03 stsp
226 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
227 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
228 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
229 735ef5ac 2019-08-03 stsp ret="$?"
230 735ef5ac 2019-08-03 stsp if [ "$ret" == "0" ]; then
231 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
232 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
233 735ef5ac 2019-08-03 stsp return 1
234 735ef5ac 2019-08-03 stsp fi
235 735ef5ac 2019-08-03 stsp
236 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
237 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
238 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
239 ebf48fd5 2019-08-03 stsp
240 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
241 ebf48fd5 2019-08-03 stsp ret="$?"
242 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
243 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
244 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
245 ebf48fd5 2019-08-03 stsp return 1
246 ebf48fd5 2019-08-03 stsp fi
247 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
248 ebf48fd5 2019-08-03 stsp ret="$?"
249 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
250 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
251 ebf48fd5 2019-08-03 stsp fi
252 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
253 ebf48fd5 2019-08-03 stsp }
254 ebf48fd5 2019-08-03 stsp
255 ebf48fd5 2019-08-03 stsp
256 d3e7c587 2019-08-03 stsp function test_double_stage {
257 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
258 d3e7c587 2019-08-03 stsp
259 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
260 d3e7c587 2019-08-03 stsp ret="$?"
261 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
262 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
263 d3e7c587 2019-08-03 stsp return 1
264 d3e7c587 2019-08-03 stsp fi
265 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
266 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
267 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
268 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
269 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
270 d3e7c587 2019-08-03 stsp
271 d3e7c587 2019-08-03 stsp echo "got: alpha: no changes to stage" > $testroot/stderr.expected
272 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
273 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
274 d3e7c587 2019-08-03 stsp ret="$?"
275 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
276 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
277 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
278 d3e7c587 2019-08-03 stsp return 1
279 d3e7c587 2019-08-03 stsp fi
280 d3e7c587 2019-08-03 stsp
281 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage beta > $testroot/stdout)
282 9c5c5eed 2019-08-03 stsp ret="$?"
283 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
284 d3e7c587 2019-08-03 stsp echo "got stage command failed unexpectedly" >&2
285 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
286 d3e7c587 2019-08-03 stsp return 1
287 d3e7c587 2019-08-03 stsp fi
288 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
289 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
290 d3e7c587 2019-08-03 stsp ret="$?"
291 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
292 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
293 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
294 d3e7c587 2019-08-03 stsp return 1
295 d3e7c587 2019-08-03 stsp fi
296 d3e7c587 2019-08-03 stsp
297 d3e7c587 2019-08-03 stsp echo "got: foo: no changes to stage" > $testroot/stderr.expected
298 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
299 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
300 d3e7c587 2019-08-03 stsp ret="$?"
301 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
302 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
303 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
304 d3e7c587 2019-08-03 stsp return 1
305 d3e7c587 2019-08-03 stsp fi
306 d3e7c587 2019-08-03 stsp
307 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
308 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
309 d3e7c587 2019-08-03 stsp
310 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
311 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
312 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
313 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
314 d3e7c587 2019-08-03 stsp ret="$?"
315 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
316 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
317 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
318 d3e7c587 2019-08-03 stsp return 1
319 d3e7c587 2019-08-03 stsp fi
320 d3e7c587 2019-08-03 stsp
321 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
322 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
323 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
324 fccbfb98 2019-08-03 stsp
325 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
326 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
327 fccbfb98 2019-08-03 stsp ret="$?"
328 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
329 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
330 fccbfb98 2019-08-03 stsp fi
331 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
332 fccbfb98 2019-08-03 stsp }
333 fccbfb98 2019-08-03 stsp
334 c363b2c1 2019-08-03 stsp function test_stage_status {
335 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
336 c363b2c1 2019-08-03 stsp
337 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
338 c363b2c1 2019-08-03 stsp ret="$?"
339 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
340 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
341 c363b2c1 2019-08-03 stsp return 1
342 c363b2c1 2019-08-03 stsp fi
343 c363b2c1 2019-08-03 stsp
344 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
345 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
346 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
347 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
348 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
349 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
350 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
351 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
352 c363b2c1 2019-08-03 stsp
353 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
354 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
355 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
356 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
357 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
358 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
359 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
360 c363b2c1 2019-08-03 stsp
361 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
362 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
363 c363b2c1 2019-08-03 stsp ret="$?"
364 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
365 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
366 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
367 244725f2 2019-08-03 stsp return 1
368 c363b2c1 2019-08-03 stsp fi
369 244725f2 2019-08-03 stsp
370 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
371 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
372 244725f2 2019-08-03 stsp
373 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
374 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
375 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
376 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
377 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
378 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
379 244725f2 2019-08-03 stsp
380 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
381 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
382 244725f2 2019-08-03 stsp ret="$?"
383 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
384 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
385 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
386 244725f2 2019-08-03 stsp return 1
387 244725f2 2019-08-03 stsp fi
388 244725f2 2019-08-03 stsp
389 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
390 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
391 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
392 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
393 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
394 244725f2 2019-08-03 stsp ret="$?"
395 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
396 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
397 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
398 244725f2 2019-08-03 stsp return 1
399 244725f2 2019-08-03 stsp fi
400 244725f2 2019-08-03 stsp
401 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
402 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
403 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
404 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
405 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
406 244725f2 2019-08-03 stsp ret="$?"
407 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
408 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
409 244725f2 2019-08-03 stsp fi
410 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
411 244725f2 2019-08-03 stsp
412 c363b2c1 2019-08-03 stsp }
413 c363b2c1 2019-08-03 stsp
414 1e1446d3 2019-08-03 stsp function test_stage_add_already_staged_file {
415 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
416 1e1446d3 2019-08-03 stsp
417 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
418 1e1446d3 2019-08-03 stsp ret="$?"
419 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
420 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
421 1e1446d3 2019-08-03 stsp return 1
422 1e1446d3 2019-08-03 stsp fi
423 1e1446d3 2019-08-03 stsp
424 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
425 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
426 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
427 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
428 1e1446d3 2019-08-03 stsp
429 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
430 1e1446d3 2019-08-03 stsp
431 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
432 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
433 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
434 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
435 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
436 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
437 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
438 1e1446d3 2019-08-03 stsp ret="$?"
439 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
440 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
441 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
442 1e1446d3 2019-08-03 stsp return 1
443 1e1446d3 2019-08-03 stsp fi
444 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
445 1e1446d3 2019-08-03 stsp ret="$?"
446 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
447 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
449 1e1446d3 2019-08-03 stsp return 1
450 1e1446d3 2019-08-03 stsp fi
451 1e1446d3 2019-08-03 stsp done
452 1e1446d3 2019-08-03 stsp
453 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
454 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
455 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
456 1e1446d3 2019-08-03 stsp
457 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
458 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
459 1e1446d3 2019-08-03 stsp ret="$?"
460 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
461 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
462 1e1446d3 2019-08-03 stsp fi
463 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
464 1e1446d3 2019-08-03 stsp }
465 1e1446d3 2019-08-03 stsp
466 9acbc4fa 2019-08-03 stsp function test_stage_rm_already_staged_file {
467 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
468 9acbc4fa 2019-08-03 stsp
469 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
470 9acbc4fa 2019-08-03 stsp ret="$?"
471 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
472 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
473 9acbc4fa 2019-08-03 stsp return 1
474 9acbc4fa 2019-08-03 stsp fi
475 9acbc4fa 2019-08-03 stsp
476 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
477 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
478 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
479 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
480 9acbc4fa 2019-08-03 stsp
481 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
482 9acbc4fa 2019-08-03 stsp
483 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
484 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
485 9acbc4fa 2019-08-03 stsp ret="$?"
486 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
487 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
488 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
489 9acbc4fa 2019-08-03 stsp return 1
490 9acbc4fa 2019-08-03 stsp fi
491 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
492 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
493 6d022e97 2019-08-04 stsp ret="$?"
494 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
495 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
496 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
497 6d022e97 2019-08-04 stsp return 1
498 6d022e97 2019-08-04 stsp fi
499 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
500 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
501 9acbc4fa 2019-08-03 stsp ret="$?"
502 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
503 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
504 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
505 9acbc4fa 2019-08-03 stsp return 1
506 9acbc4fa 2019-08-03 stsp fi
507 9acbc4fa 2019-08-03 stsp
508 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
509 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
510 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
511 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
512 9acbc4fa 2019-08-03 stsp ret="$?"
513 9acbc4fa 2019-08-03 stsp if [ "$ret" == "0" ]; then
514 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
515 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
516 9acbc4fa 2019-08-03 stsp return 1
517 9acbc4fa 2019-08-03 stsp fi
518 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
519 9acbc4fa 2019-08-03 stsp ret="$?"
520 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
521 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
522 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
523 9acbc4fa 2019-08-03 stsp return 1
524 9acbc4fa 2019-08-03 stsp fi
525 9acbc4fa 2019-08-03 stsp done
526 9acbc4fa 2019-08-03 stsp
527 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
528 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
529 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
530 9acbc4fa 2019-08-03 stsp
531 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
532 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
533 9acbc4fa 2019-08-03 stsp ret="$?"
534 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
535 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
536 9acbc4fa 2019-08-03 stsp fi
537 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
538 9acbc4fa 2019-08-03 stsp }
539 24278f30 2019-08-03 stsp
540 24278f30 2019-08-03 stsp function test_stage_revert {
541 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
542 24278f30 2019-08-03 stsp
543 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
544 24278f30 2019-08-03 stsp ret="$?"
545 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
546 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
547 24278f30 2019-08-03 stsp return 1
548 24278f30 2019-08-03 stsp fi
549 24278f30 2019-08-03 stsp
550 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
551 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
552 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
553 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
554 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
555 24278f30 2019-08-03 stsp
556 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
557 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
558 24278f30 2019-08-03 stsp
559 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
560 24278f30 2019-08-03 stsp ret="$?"
561 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
562 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
563 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
564 24278f30 2019-08-03 stsp return 1
565 24278f30 2019-08-03 stsp fi
566 24278f30 2019-08-03 stsp
567 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
568 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
569 24278f30 2019-08-03 stsp ret="$?"
570 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
571 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
572 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
573 24278f30 2019-08-03 stsp return 1
574 24278f30 2019-08-03 stsp fi
575 24278f30 2019-08-03 stsp
576 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
577 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
578 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
579 24278f30 2019-08-03 stsp ret="$?"
580 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
581 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
582 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
583 24278f30 2019-08-03 stsp return 1
584 24278f30 2019-08-03 stsp fi
585 9acbc4fa 2019-08-03 stsp
586 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
587 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
588 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
589 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
590 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
591 24278f30 2019-08-03 stsp ret="$?"
592 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
593 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
594 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
595 24278f30 2019-08-03 stsp return 1
596 24278f30 2019-08-03 stsp fi
597 24278f30 2019-08-03 stsp
598 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
599 24278f30 2019-08-03 stsp ret="$?"
600 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
601 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
602 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
603 24278f30 2019-08-03 stsp return 1
604 24278f30 2019-08-03 stsp fi
605 24278f30 2019-08-03 stsp
606 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
607 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
608 24278f30 2019-08-03 stsp ret="$?"
609 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
610 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
611 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
612 24278f30 2019-08-03 stsp return 1
613 24278f30 2019-08-03 stsp fi
614 24278f30 2019-08-03 stsp
615 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
616 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
617 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
618 24278f30 2019-08-03 stsp ret="$?"
619 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
620 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
621 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
622 24278f30 2019-08-03 stsp return 1
623 24278f30 2019-08-03 stsp fi
624 24278f30 2019-08-03 stsp
625 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
626 24278f30 2019-08-03 stsp 2> $testroot/stderr)
627 24278f30 2019-08-03 stsp ret="$?"
628 24278f30 2019-08-03 stsp if [ "$ret" == "0" ]; then
629 24278f30 2019-08-03 stsp echo "revert command succeeded unexpectedly" >&2
630 24278f30 2019-08-03 stsp test_done "$testroot" "1"
631 24278f30 2019-08-03 stsp return 1
632 24278f30 2019-08-03 stsp fi
633 24278f30 2019-08-03 stsp
634 24278f30 2019-08-03 stsp echo "got: beta: file is staged" > $testroot/stderr.expected
635 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
636 24278f30 2019-08-03 stsp ret="$?"
637 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
638 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
639 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
640 24278f30 2019-08-03 stsp return 1
641 24278f30 2019-08-03 stsp fi
642 24278f30 2019-08-03 stsp
643 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
644 24278f30 2019-08-03 stsp ret="$?"
645 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
646 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
647 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
648 24278f30 2019-08-03 stsp return 1
649 24278f30 2019-08-03 stsp fi
650 24278f30 2019-08-03 stsp
651 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
652 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
653 24278f30 2019-08-03 stsp ret="$?"
654 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
655 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
656 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
657 24278f30 2019-08-03 stsp return 1
658 24278f30 2019-08-03 stsp fi
659 24278f30 2019-08-03 stsp
660 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
661 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
662 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
663 24278f30 2019-08-03 stsp ret="$?"
664 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
665 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
666 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
667 24278f30 2019-08-03 stsp return 1
668 24278f30 2019-08-03 stsp fi
669 24278f30 2019-08-03 stsp
670 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
671 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
672 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
673 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
674 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
675 24278f30 2019-08-03 stsp ret="$?"
676 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
677 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
678 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
679 24278f30 2019-08-03 stsp return 1
680 24278f30 2019-08-03 stsp fi
681 24278f30 2019-08-03 stsp
682 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
683 24278f30 2019-08-03 stsp ret="$?"
684 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
685 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
686 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
687 24278f30 2019-08-03 stsp return 1
688 24278f30 2019-08-03 stsp fi
689 24278f30 2019-08-03 stsp
690 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
691 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
692 24278f30 2019-08-03 stsp ret="$?"
693 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
694 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
695 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
696 24278f30 2019-08-03 stsp return 1
697 24278f30 2019-08-03 stsp fi
698 24278f30 2019-08-03 stsp
699 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
700 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
701 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
702 24278f30 2019-08-03 stsp ret="$?"
703 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
704 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
705 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
706 24278f30 2019-08-03 stsp return 1
707 24278f30 2019-08-03 stsp fi
708 24278f30 2019-08-03 stsp
709 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
710 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
711 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
712 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
713 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
714 408b4ebc 2019-08-03 stsp ret="$?"
715 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
716 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
717 408b4ebc 2019-08-03 stsp fi
718 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
719 408b4ebc 2019-08-03 stsp }
720 408b4ebc 2019-08-03 stsp
721 408b4ebc 2019-08-03 stsp function test_stage_diff {
722 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
723 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
724 408b4ebc 2019-08-03 stsp
725 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
726 408b4ebc 2019-08-03 stsp ret="$?"
727 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
728 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
729 408b4ebc 2019-08-03 stsp return 1
730 408b4ebc 2019-08-03 stsp fi
731 408b4ebc 2019-08-03 stsp
732 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
733 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
734 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
735 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
736 98eaaa12 2019-08-03 stsp
737 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
738 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
739 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
740 98eaaa12 2019-08-03 stsp ret="$?"
741 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
742 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
743 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
744 98eaaa12 2019-08-03 stsp return 1
745 98eaaa12 2019-08-03 stsp fi
746 408b4ebc 2019-08-03 stsp
747 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
748 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
749 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
750 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
751 408b4ebc 2019-08-03 stsp
752 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
753 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
754 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
755 408b4ebc 2019-08-03 stsp ret="$?"
756 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
757 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
758 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
759 408b4ebc 2019-08-03 stsp return 1
760 408b4ebc 2019-08-03 stsp fi
761 408b4ebc 2019-08-03 stsp
762 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
763 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
764 408b4ebc 2019-08-03 stsp
765 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
766 408b4ebc 2019-08-03 stsp
767 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
768 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
769 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
770 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
771 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
772 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
773 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
774 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
775 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
776 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
777 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
778 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
779 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
780 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
781 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
782 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
783 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
784 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
785 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
786 98eaaa12 2019-08-03 stsp
787 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
788 98eaaa12 2019-08-03 stsp ret="$?"
789 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
790 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
791 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
792 98eaaa12 2019-08-03 stsp return 1
793 98eaaa12 2019-08-03 stsp fi
794 98eaaa12 2019-08-03 stsp
795 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
796 98eaaa12 2019-08-03 stsp
797 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
798 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
799 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
800 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
801 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
802 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
803 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
804 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
805 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
806 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
807 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
808 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
809 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
810 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
811 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
812 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
813 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
814 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
815 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
816 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
817 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
818 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
819 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
820 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
821 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
822 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
823 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
824 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
825 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
826 408b4ebc 2019-08-03 stsp
827 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
828 24278f30 2019-08-03 stsp ret="$?"
829 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
830 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
831 24278f30 2019-08-03 stsp fi
832 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
833 408b4ebc 2019-08-03 stsp
834 24278f30 2019-08-03 stsp }
835 b9622844 2019-08-03 stsp
836 b9622844 2019-08-03 stsp function test_stage_histedit {
837 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
838 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
839 b9622844 2019-08-03 stsp
840 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
841 b9622844 2019-08-03 stsp ret="$?"
842 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
843 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
844 b9622844 2019-08-03 stsp return 1
845 b9622844 2019-08-03 stsp fi
846 b9622844 2019-08-03 stsp
847 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
848 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
849 b9622844 2019-08-03 stsp
850 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
851 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
852 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
853 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
854 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
855 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
856 24278f30 2019-08-03 stsp
857 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
858 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
859 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
860 b9622844 2019-08-03 stsp
861 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
862 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
863 b9622844 2019-08-03 stsp
864 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
865 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
866 b9622844 2019-08-03 stsp ret="$?"
867 b9622844 2019-08-03 stsp if [ "$ret" == "0" ]; then
868 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
869 b9622844 2019-08-03 stsp test_done "$testroot" "1"
870 b9622844 2019-08-03 stsp return 1
871 b9622844 2019-08-03 stsp fi
872 b9622844 2019-08-03 stsp
873 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
874 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
875 b9622844 2019-08-03 stsp
876 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
877 b9622844 2019-08-03 stsp ret="$?"
878 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
879 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
880 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
881 b9622844 2019-08-03 stsp return 1
882 b9622844 2019-08-03 stsp fi
883 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
884 b9622844 2019-08-03 stsp ret="$?"
885 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
886 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
887 b9622844 2019-08-03 stsp fi
888 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
889 243d7cf1 2019-08-03 stsp
890 243d7cf1 2019-08-03 stsp }
891 243d7cf1 2019-08-03 stsp
892 243d7cf1 2019-08-03 stsp function test_stage_rebase {
893 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
894 243d7cf1 2019-08-03 stsp
895 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
896 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
897 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
898 243d7cf1 2019-08-03 stsp
899 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
900 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
901 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
902 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
903 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
904 243d7cf1 2019-08-03 stsp
905 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
906 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
907 243d7cf1 2019-08-03 stsp
908 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
909 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
910 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
911 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
912 243d7cf1 2019-08-03 stsp
913 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
914 243d7cf1 2019-08-03 stsp ret="$?"
915 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
916 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
917 243d7cf1 2019-08-03 stsp return 1
918 243d7cf1 2019-08-03 stsp fi
919 243d7cf1 2019-08-03 stsp
920 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
921 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
922 b9622844 2019-08-03 stsp
923 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
924 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
925 243d7cf1 2019-08-03 stsp ret="$?"
926 243d7cf1 2019-08-03 stsp if [ "$ret" == "0" ]; then
927 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
928 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
929 243d7cf1 2019-08-03 stsp return 1
930 243d7cf1 2019-08-03 stsp fi
931 243d7cf1 2019-08-03 stsp
932 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
933 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
934 243d7cf1 2019-08-03 stsp
935 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
936 243d7cf1 2019-08-03 stsp ret="$?"
937 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
938 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
939 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
940 243d7cf1 2019-08-03 stsp return 1
941 243d7cf1 2019-08-03 stsp fi
942 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
943 243d7cf1 2019-08-03 stsp ret="$?"
944 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
945 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
946 243d7cf1 2019-08-03 stsp fi
947 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
948 b9622844 2019-08-03 stsp }
949 b9622844 2019-08-03 stsp
950 a76c42e6 2019-08-03 stsp function test_stage_update {
951 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
952 a76c42e6 2019-08-03 stsp
953 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
954 a76c42e6 2019-08-03 stsp ret="$?"
955 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
956 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
957 a76c42e6 2019-08-03 stsp return 1
958 a76c42e6 2019-08-03 stsp fi
959 243d7cf1 2019-08-03 stsp
960 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
961 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
962 a76c42e6 2019-08-03 stsp
963 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
964 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
965 a76c42e6 2019-08-03 stsp
966 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
967 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
968 a76c42e6 2019-08-03 stsp ret="$?"
969 a76c42e6 2019-08-03 stsp if [ "$ret" == "0" ]; then
970 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
971 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
972 a76c42e6 2019-08-03 stsp return 1
973 a76c42e6 2019-08-03 stsp fi
974 a76c42e6 2019-08-03 stsp
975 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
976 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
977 a76c42e6 2019-08-03 stsp
978 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
979 a76c42e6 2019-08-03 stsp ret="$?"
980 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
981 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
982 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
983 a76c42e6 2019-08-03 stsp return 1
984 a76c42e6 2019-08-03 stsp fi
985 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
986 a76c42e6 2019-08-03 stsp ret="$?"
987 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
988 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
989 a76c42e6 2019-08-03 stsp fi
990 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
991 a76c42e6 2019-08-03 stsp }
992 f0b75401 2019-08-03 stsp
993 f0b75401 2019-08-03 stsp function test_stage_commit_non_staged {
994 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
995 f0b75401 2019-08-03 stsp
996 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
997 f0b75401 2019-08-03 stsp ret="$?"
998 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
999 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1000 f0b75401 2019-08-03 stsp return 1
1001 f0b75401 2019-08-03 stsp fi
1002 f0b75401 2019-08-03 stsp
1003 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1004 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1005 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1006 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1007 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1008 a76c42e6 2019-08-03 stsp
1009 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1010 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1011 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1012 f0b75401 2019-08-03 stsp ret="$?"
1013 f0b75401 2019-08-03 stsp if [ "$ret" == "0" ]; then
1014 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1015 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1016 f0b75401 2019-08-03 stsp return 1
1017 f0b75401 2019-08-03 stsp fi
1018 f0b75401 2019-08-03 stsp
1019 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1020 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1021 f0b75401 2019-08-03 stsp
1022 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1023 f0b75401 2019-08-03 stsp ret="$?"
1024 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1025 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1026 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1027 5f8a88c6 2019-08-03 stsp return 1
1028 5f8a88c6 2019-08-03 stsp fi
1029 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1030 5f8a88c6 2019-08-03 stsp ret="$?"
1031 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1032 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1033 5f8a88c6 2019-08-03 stsp fi
1034 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1035 5f8a88c6 2019-08-03 stsp }
1036 5f8a88c6 2019-08-03 stsp
1037 5f8a88c6 2019-08-03 stsp function test_stage_commit {
1038 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1039 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1040 5f8a88c6 2019-08-03 stsp
1041 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1042 5f8a88c6 2019-08-03 stsp ret="$?"
1043 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1044 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1045 5f8a88c6 2019-08-03 stsp return 1
1046 5f8a88c6 2019-08-03 stsp fi
1047 5f8a88c6 2019-08-03 stsp
1048 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1049 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1050 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1051 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1052 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1053 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1054 5f8a88c6 2019-08-03 stsp
1055 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1056 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1057 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1058 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1059 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1060 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1061 5f8a88c6 2019-08-03 stsp
1062 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1063 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1064 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1065 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1066 5f8a88c6 2019-08-03 stsp
1067 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1068 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1069 5f8a88c6 2019-08-03 stsp ret="$?"
1070 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1071 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1072 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1073 5f8a88c6 2019-08-03 stsp return 1
1074 5f8a88c6 2019-08-03 stsp fi
1075 5f8a88c6 2019-08-03 stsp
1076 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1077 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1078 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1079 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1080 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1081 5f8a88c6 2019-08-03 stsp
1082 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1083 5f8a88c6 2019-08-03 stsp ret="$?"
1084 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1085 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1086 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1087 f0b75401 2019-08-03 stsp return 1
1088 f0b75401 2019-08-03 stsp fi
1089 5f8a88c6 2019-08-03 stsp
1090 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1091 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1092 5f8a88c6 2019-08-03 stsp
1093 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1094 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1095 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1096 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1097 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1098 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1099 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1100 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1101 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1102 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1103 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1104 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1105 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1106 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1107 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1108 5f8a88c6 2019-08-03 stsp | grep 'beta$' | cut -d' ' -f 1 \
1109 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1110 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1111 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1112 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1113 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1114 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1115 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1116 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1117 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_foo >> $testroot/stdout.expected
1118 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1119 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1120 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1121 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1122 5f8a88c6 2019-08-03 stsp
1123 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1124 f0b75401 2019-08-03 stsp ret="$?"
1125 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1126 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1127 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1128 5f8a88c6 2019-08-03 stsp return 1
1129 f0b75401 2019-08-03 stsp fi
1130 5f8a88c6 2019-08-03 stsp
1131 5f8a88c6 2019-08-03 stsp echo 'A epsilon/new' > $testroot/stdout.expected
1132 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1133 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1134 5f8a88c6 2019-08-03 stsp
1135 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1136 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1137 5f8a88c6 2019-08-03 stsp ret="$?"
1138 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1139 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1140 5f8a88c6 2019-08-03 stsp fi
1141 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1142 f0b75401 2019-08-03 stsp }
1143 dc424a06 2019-08-07 stsp
1144 dc424a06 2019-08-07 stsp function test_stage_patch {
1145 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1146 dc424a06 2019-08-07 stsp
1147 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1148 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1149 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1150 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1151 dc424a06 2019-08-07 stsp
1152 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1153 dc424a06 2019-08-07 stsp ret="$?"
1154 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1155 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1156 dc424a06 2019-08-07 stsp return 1
1157 dc424a06 2019-08-07 stsp fi
1158 dc424a06 2019-08-07 stsp
1159 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1160 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1161 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1162 dc424a06 2019-08-07 stsp
1163 dc424a06 2019-08-07 stsp # don't stage any hunks
1164 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1165 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1166 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1167 dc424a06 2019-08-07 stsp ret="$?"
1168 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1169 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1170 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1171 dc424a06 2019-08-07 stsp return 1
1172 dc424a06 2019-08-07 stsp fi
1173 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1174 dc424a06 2019-08-07 stsp -----------------------------------------------
1175 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1176 dc424a06 2019-08-07 stsp 1
1177 dc424a06 2019-08-07 stsp -2
1178 dc424a06 2019-08-07 stsp +a
1179 dc424a06 2019-08-07 stsp 3
1180 dc424a06 2019-08-07 stsp 4
1181 dc424a06 2019-08-07 stsp 5
1182 dc424a06 2019-08-07 stsp -----------------------------------------------
1183 dc424a06 2019-08-07 stsp M numbers
1184 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1185 dc424a06 2019-08-07 stsp -----------------------------------------------
1186 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1187 dc424a06 2019-08-07 stsp 4
1188 dc424a06 2019-08-07 stsp 5
1189 dc424a06 2019-08-07 stsp 6
1190 dc424a06 2019-08-07 stsp -7
1191 dc424a06 2019-08-07 stsp +b
1192 dc424a06 2019-08-07 stsp 8
1193 dc424a06 2019-08-07 stsp 9
1194 dc424a06 2019-08-07 stsp 10
1195 dc424a06 2019-08-07 stsp -----------------------------------------------
1196 dc424a06 2019-08-07 stsp M numbers
1197 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1198 dc424a06 2019-08-07 stsp -----------------------------------------------
1199 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1200 dc424a06 2019-08-07 stsp 13
1201 dc424a06 2019-08-07 stsp 14
1202 dc424a06 2019-08-07 stsp 15
1203 dc424a06 2019-08-07 stsp -16
1204 dc424a06 2019-08-07 stsp +c
1205 dc424a06 2019-08-07 stsp -----------------------------------------------
1206 dc424a06 2019-08-07 stsp M numbers
1207 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1208 dc424a06 2019-08-07 stsp EOF
1209 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1210 dc424a06 2019-08-07 stsp ret="$?"
1211 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1212 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1213 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1214 dc424a06 2019-08-07 stsp return 1
1215 dc424a06 2019-08-07 stsp fi
1216 f0b75401 2019-08-03 stsp
1217 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1218 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1219 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1220 dc424a06 2019-08-07 stsp ret="$?"
1221 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1222 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1223 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1224 dc424a06 2019-08-07 stsp return 1
1225 dc424a06 2019-08-07 stsp fi
1226 dc424a06 2019-08-07 stsp
1227 dc424a06 2019-08-07 stsp # stage middle hunk
1228 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1229 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1230 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1231 dc424a06 2019-08-07 stsp
1232 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1233 dc424a06 2019-08-07 stsp -----------------------------------------------
1234 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1235 dc424a06 2019-08-07 stsp 1
1236 dc424a06 2019-08-07 stsp -2
1237 dc424a06 2019-08-07 stsp +a
1238 dc424a06 2019-08-07 stsp 3
1239 dc424a06 2019-08-07 stsp 4
1240 dc424a06 2019-08-07 stsp 5
1241 dc424a06 2019-08-07 stsp -----------------------------------------------
1242 dc424a06 2019-08-07 stsp M numbers
1243 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1244 dc424a06 2019-08-07 stsp -----------------------------------------------
1245 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1246 dc424a06 2019-08-07 stsp 4
1247 dc424a06 2019-08-07 stsp 5
1248 dc424a06 2019-08-07 stsp 6
1249 dc424a06 2019-08-07 stsp -7
1250 dc424a06 2019-08-07 stsp +b
1251 dc424a06 2019-08-07 stsp 8
1252 dc424a06 2019-08-07 stsp 9
1253 dc424a06 2019-08-07 stsp 10
1254 dc424a06 2019-08-07 stsp -----------------------------------------------
1255 dc424a06 2019-08-07 stsp M numbers
1256 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1257 dc424a06 2019-08-07 stsp -----------------------------------------------
1258 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1259 dc424a06 2019-08-07 stsp 13
1260 dc424a06 2019-08-07 stsp 14
1261 dc424a06 2019-08-07 stsp 15
1262 dc424a06 2019-08-07 stsp -16
1263 dc424a06 2019-08-07 stsp +c
1264 dc424a06 2019-08-07 stsp -----------------------------------------------
1265 dc424a06 2019-08-07 stsp M numbers
1266 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1267 dc424a06 2019-08-07 stsp EOF
1268 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1269 dc424a06 2019-08-07 stsp ret="$?"
1270 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1271 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1272 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1273 dc424a06 2019-08-07 stsp return 1
1274 dc424a06 2019-08-07 stsp fi
1275 dc424a06 2019-08-07 stsp
1276 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1277 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1278 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1279 dc424a06 2019-08-07 stsp ret="$?"
1280 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1281 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1282 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1283 dc424a06 2019-08-07 stsp return 1
1284 dc424a06 2019-08-07 stsp fi
1285 dc424a06 2019-08-07 stsp
1286 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1287 dc424a06 2019-08-07 stsp
1288 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1289 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1290 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1291 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1292 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1293 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1294 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1295 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1296 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1297 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1298 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1299 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1300 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1301 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1302 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1303 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1304 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1305 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1306 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1307 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1308 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1309 dc424a06 2019-08-07 stsp ret="$?"
1310 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1311 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1312 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1313 dc424a06 2019-08-07 stsp return 1
1314 dc424a06 2019-08-07 stsp fi
1315 dc424a06 2019-08-07 stsp
1316 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1317 dc424a06 2019-08-07 stsp ret="$?"
1318 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1319 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1320 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1321 dc424a06 2019-08-07 stsp return 1
1322 dc424a06 2019-08-07 stsp fi
1323 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1324 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1325 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1326 dc424a06 2019-08-07 stsp ret="$?"
1327 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1328 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1329 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1330 dc424a06 2019-08-07 stsp return 1
1331 dc424a06 2019-08-07 stsp fi
1332 dc424a06 2019-08-07 stsp
1333 dc424a06 2019-08-07 stsp # stage last hunk
1334 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1335 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1336 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1337 dc424a06 2019-08-07 stsp
1338 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1339 dc424a06 2019-08-07 stsp -----------------------------------------------
1340 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1341 dc424a06 2019-08-07 stsp 1
1342 dc424a06 2019-08-07 stsp -2
1343 dc424a06 2019-08-07 stsp +a
1344 dc424a06 2019-08-07 stsp 3
1345 dc424a06 2019-08-07 stsp 4
1346 dc424a06 2019-08-07 stsp 5
1347 dc424a06 2019-08-07 stsp -----------------------------------------------
1348 dc424a06 2019-08-07 stsp M numbers
1349 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1350 dc424a06 2019-08-07 stsp -----------------------------------------------
1351 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1352 dc424a06 2019-08-07 stsp 4
1353 dc424a06 2019-08-07 stsp 5
1354 dc424a06 2019-08-07 stsp 6
1355 dc424a06 2019-08-07 stsp -7
1356 dc424a06 2019-08-07 stsp +b
1357 dc424a06 2019-08-07 stsp 8
1358 dc424a06 2019-08-07 stsp 9
1359 dc424a06 2019-08-07 stsp 10
1360 dc424a06 2019-08-07 stsp -----------------------------------------------
1361 dc424a06 2019-08-07 stsp M numbers
1362 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1363 dc424a06 2019-08-07 stsp -----------------------------------------------
1364 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1365 dc424a06 2019-08-07 stsp 13
1366 dc424a06 2019-08-07 stsp 14
1367 dc424a06 2019-08-07 stsp 15
1368 dc424a06 2019-08-07 stsp -16
1369 dc424a06 2019-08-07 stsp +c
1370 dc424a06 2019-08-07 stsp -----------------------------------------------
1371 dc424a06 2019-08-07 stsp M numbers
1372 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1373 dc424a06 2019-08-07 stsp EOF
1374 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1375 dc424a06 2019-08-07 stsp ret="$?"
1376 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1377 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1378 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1379 dc424a06 2019-08-07 stsp return 1
1380 dc424a06 2019-08-07 stsp fi
1381 dc424a06 2019-08-07 stsp
1382 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1383 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1384 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1385 dc424a06 2019-08-07 stsp ret="$?"
1386 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1387 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1388 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1389 dc424a06 2019-08-07 stsp return 1
1390 dc424a06 2019-08-07 stsp fi
1391 dc424a06 2019-08-07 stsp
1392 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1393 dc424a06 2019-08-07 stsp
1394 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1395 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1396 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1397 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1398 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1399 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1400 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1401 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1402 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1403 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1404 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1405 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1406 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1407 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1408 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1409 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1410 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1411 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1412 dc424a06 2019-08-07 stsp ret="$?"
1413 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1414 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1415 dc424a06 2019-08-07 stsp fi
1416 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1417 dc424a06 2019-08-07 stsp }
1418 dc424a06 2019-08-07 stsp
1419 dc424a06 2019-08-07 stsp function test_stage_patch_added {
1420 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1421 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1422 dc424a06 2019-08-07 stsp
1423 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1424 dc424a06 2019-08-07 stsp ret="$?"
1425 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1426 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1427 dc424a06 2019-08-07 stsp return 1
1428 dc424a06 2019-08-07 stsp fi
1429 dc424a06 2019-08-07 stsp
1430 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1431 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1432 dc424a06 2019-08-07 stsp
1433 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1434 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1435 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1436 dc424a06 2019-08-07 stsp
1437 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1438 b353a198 2019-08-07 stsp echo "stage this addition? [y/n/q] y" >> $testroot/stdout.expected
1439 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1440 dc424a06 2019-08-07 stsp ret="$?"
1441 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1442 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1443 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1444 dc424a06 2019-08-07 stsp return 1
1445 dc424a06 2019-08-07 stsp fi
1446 dc424a06 2019-08-07 stsp
1447 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1448 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1449 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1450 dc424a06 2019-08-07 stsp ret="$?"
1451 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1452 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1453 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1454 dc424a06 2019-08-07 stsp return 1
1455 dc424a06 2019-08-07 stsp fi
1456 dc424a06 2019-08-07 stsp
1457 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1458 dc424a06 2019-08-07 stsp
1459 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1460 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1461 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1462 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1463 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1464 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1465 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1466 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1467 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1468 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1469 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1470 dc424a06 2019-08-07 stsp ret="$?"
1471 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1472 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1473 dc424a06 2019-08-07 stsp fi
1474 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1475 dc424a06 2019-08-07 stsp }
1476 dc424a06 2019-08-07 stsp
1477 dc424a06 2019-08-07 stsp function test_stage_patch_removed {
1478 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
1479 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1480 dc424a06 2019-08-07 stsp
1481 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1482 dc424a06 2019-08-07 stsp ret="$?"
1483 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1484 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1485 dc424a06 2019-08-07 stsp return 1
1486 dc424a06 2019-08-07 stsp fi
1487 dc424a06 2019-08-07 stsp
1488 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
1489 dc424a06 2019-08-07 stsp
1490 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1491 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1492 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
1493 dc424a06 2019-08-07 stsp
1494 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
1495 dc424a06 2019-08-07 stsp
1496 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
1497 b353a198 2019-08-07 stsp echo "stage deletion? [y/n/q] y" >> $testroot/stdout.expected
1498 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1499 dc424a06 2019-08-07 stsp ret="$?"
1500 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1501 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1502 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1503 dc424a06 2019-08-07 stsp return 1
1504 dc424a06 2019-08-07 stsp fi
1505 dc424a06 2019-08-07 stsp
1506 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1507 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
1508 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1509 dc424a06 2019-08-07 stsp ret="$?"
1510 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1511 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1512 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1513 dc424a06 2019-08-07 stsp return 1
1514 dc424a06 2019-08-07 stsp fi
1515 dc424a06 2019-08-07 stsp
1516 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1517 dc424a06 2019-08-07 stsp
1518 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1519 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1520 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1521 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
1522 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1523 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1524 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
1525 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
1526 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
1527 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
1528 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1529 dc424a06 2019-08-07 stsp ret="$?"
1530 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1531 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1532 dc424a06 2019-08-07 stsp fi
1533 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1534 dc424a06 2019-08-07 stsp }
1535 b353a198 2019-08-07 stsp
1536 b353a198 2019-08-07 stsp function test_stage_patch_quit {
1537 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
1538 b353a198 2019-08-07 stsp
1539 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1540 b353a198 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1541 b353a198 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1542 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1543 b353a198 2019-08-07 stsp
1544 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1545 b353a198 2019-08-07 stsp ret="$?"
1546 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1547 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1548 b353a198 2019-08-07 stsp return 1
1549 b353a198 2019-08-07 stsp fi
1550 dc424a06 2019-08-07 stsp
1551 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1552 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1553 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1554 b353a198 2019-08-07 stsp
1555 2db2652d 2019-08-07 stsp # stage first hunk and quit; and don't pass a path argument
1556 b353a198 2019-08-07 stsp printf "y\nq\n" > $testroot/patchscript
1557 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1558 2db2652d 2019-08-07 stsp > $testroot/stdout)
1559 b353a198 2019-08-07 stsp ret="$?"
1560 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1561 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1562 b353a198 2019-08-07 stsp test_done "$testroot" "1"
1563 b353a198 2019-08-07 stsp return 1
1564 b353a198 2019-08-07 stsp fi
1565 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1566 b353a198 2019-08-07 stsp -----------------------------------------------
1567 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
1568 b353a198 2019-08-07 stsp 1
1569 b353a198 2019-08-07 stsp -2
1570 b353a198 2019-08-07 stsp +a
1571 b353a198 2019-08-07 stsp 3
1572 b353a198 2019-08-07 stsp 4
1573 b353a198 2019-08-07 stsp 5
1574 b353a198 2019-08-07 stsp -----------------------------------------------
1575 b353a198 2019-08-07 stsp M numbers
1576 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1577 b353a198 2019-08-07 stsp -----------------------------------------------
1578 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
1579 b353a198 2019-08-07 stsp 4
1580 b353a198 2019-08-07 stsp 5
1581 b353a198 2019-08-07 stsp 6
1582 b353a198 2019-08-07 stsp -7
1583 b353a198 2019-08-07 stsp +b
1584 b353a198 2019-08-07 stsp 8
1585 b353a198 2019-08-07 stsp 9
1586 b353a198 2019-08-07 stsp 10
1587 b353a198 2019-08-07 stsp -----------------------------------------------
1588 b353a198 2019-08-07 stsp M numbers
1589 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
1590 b353a198 2019-08-07 stsp EOF
1591 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1592 b353a198 2019-08-07 stsp ret="$?"
1593 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1594 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1595 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1596 b353a198 2019-08-07 stsp return 1
1597 b353a198 2019-08-07 stsp fi
1598 b353a198 2019-08-07 stsp
1599 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1600 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1601 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1602 b353a198 2019-08-07 stsp ret="$?"
1603 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1604 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1605 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1606 b353a198 2019-08-07 stsp return 1
1607 b353a198 2019-08-07 stsp fi
1608 b353a198 2019-08-07 stsp
1609 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1610 b353a198 2019-08-07 stsp
1611 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1612 b353a198 2019-08-07 stsp > $testroot/stdout.expected
1613 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1614 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1615 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1616 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1617 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1618 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1619 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
1620 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1621 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1622 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
1623 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
1624 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
1625 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
1626 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
1627 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1628 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1629 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1630 b353a198 2019-08-07 stsp ret="$?"
1631 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
1632 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1633 b353a198 2019-08-07 stsp fi
1634 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
1635 b353a198 2019-08-07 stsp
1636 b353a198 2019-08-07 stsp }
1637 b353a198 2019-08-07 stsp
1638 fccbfb98 2019-08-03 stsp run_test test_stage_basic
1639 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
1640 a4f692bb 2019-08-04 stsp run_test test_stage_list
1641 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
1642 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
1643 d3e7c587 2019-08-03 stsp run_test test_double_stage
1644 c363b2c1 2019-08-03 stsp run_test test_stage_status
1645 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
1646 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
1647 24278f30 2019-08-03 stsp run_test test_stage_revert
1648 408b4ebc 2019-08-03 stsp run_test test_stage_diff
1649 b9622844 2019-08-03 stsp run_test test_stage_histedit
1650 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
1651 a76c42e6 2019-08-03 stsp run_test test_stage_update
1652 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
1653 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
1654 dc424a06 2019-08-07 stsp run_test test_stage_patch
1655 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
1656 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
1657 b353a198 2019-08-07 stsp run_test test_stage_patch_quit