Blame


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