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 f6cae3ed 2020-09-13 naddy 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 fc414659 2022-04-16 thomas ret=$?
24 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
41 fc414659 2022-04-16 thomas if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 fc414659 2022-04-16 thomas ret=$?
52 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
60 fc414659 2022-04-16 thomas if [ $ret -eq 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 fc414659 2022-04-16 thomas ret=$?
70 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
79 fc414659 2022-04-16 thomas if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 fc414659 2022-04-16 thomas ret=$?
90 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
103 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
111 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
120 fc414659 2022-04-16 thomas if [ $ret -ne 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 fc414659 2022-04-16 thomas ret=$?
131 fc414659 2022-04-16 thomas if [ $ret -eq 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 fc414659 2022-04-16 thomas ret=$?
140 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
141 8b13ce36 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
142 8b13ce36 2019-08-08 stsp fi
143 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
144 8564cb21 2019-08-08 stsp
145 8564cb21 2019-08-08 stsp }
146 8564cb21 2019-08-08 stsp
147 f6cae3ed 2020-09-13 naddy test_stage_nonexistent() {
148 8564cb21 2019-08-08 stsp local testroot=`test_init stage_nonexistent`
149 8564cb21 2019-08-08 stsp
150 8564cb21 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
151 fc414659 2022-04-16 thomas ret=$?
152 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
153 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
154 8564cb21 2019-08-08 stsp return 1
155 8564cb21 2019-08-08 stsp fi
156 8b13ce36 2019-08-08 stsp
157 8564cb21 2019-08-08 stsp (cd $testroot/wt && got stage nonexistent-file \
158 8564cb21 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
159 2a06fe5f 2019-08-24 stsp echo "got: nonexistent-file: No such file or directory" \
160 2a06fe5f 2019-08-24 stsp > $testroot/stderr.expected
161 8564cb21 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
162 fc414659 2022-04-16 thomas ret=$?
163 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
164 8564cb21 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
165 8564cb21 2019-08-08 stsp fi
166 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
167 8b13ce36 2019-08-08 stsp }
168 8b13ce36 2019-08-08 stsp
169 f6cae3ed 2020-09-13 naddy test_stage_list() {
170 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
171 a4f692bb 2019-08-04 stsp
172 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
173 fc414659 2022-04-16 thomas ret=$?
174 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
175 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
176 a4f692bb 2019-08-04 stsp return 1
177 a4f692bb 2019-08-04 stsp fi
178 a4f692bb 2019-08-04 stsp
179 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
180 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
181 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
182 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
183 a4f692bb 2019-08-04 stsp
184 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
185 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
186 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
187 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
188 a4f692bb 2019-08-04 stsp
189 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
190 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
191 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
192 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
193 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
194 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
195 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
196 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
197 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
198 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
199 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
200 fc414659 2022-04-16 thomas ret=$?
201 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
202 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
203 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
204 a4f692bb 2019-08-04 stsp return 1
205 a4f692bb 2019-08-04 stsp fi
206 a4f692bb 2019-08-04 stsp
207 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
208 a4f692bb 2019-08-04 stsp > $testroot/stdout)
209 a4f692bb 2019-08-04 stsp
210 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
211 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
212 fc414659 2022-04-16 thomas ret=$?
213 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
214 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
215 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
216 a4f692bb 2019-08-04 stsp return 1
217 a4f692bb 2019-08-04 stsp fi
218 a4f692bb 2019-08-04 stsp
219 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
220 a4f692bb 2019-08-04 stsp
221 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
222 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
223 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
224 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
225 fc414659 2022-04-16 thomas ret=$?
226 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
227 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
228 a4f692bb 2019-08-04 stsp fi
229 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
230 a4f692bb 2019-08-04 stsp
231 a4f692bb 2019-08-04 stsp }
232 a4f692bb 2019-08-04 stsp
233 f6cae3ed 2020-09-13 naddy test_stage_conflict() {
234 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
235 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
236 ebf48fd5 2019-08-03 stsp
237 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
238 fc414659 2022-04-16 thomas ret=$?
239 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
240 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
241 ebf48fd5 2019-08-03 stsp return 1
242 ebf48fd5 2019-08-03 stsp fi
243 ebf48fd5 2019-08-03 stsp
244 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
245 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
246 ebf48fd5 2019-08-03 stsp
247 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
248 ebf48fd5 2019-08-03 stsp
249 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
250 ebf48fd5 2019-08-03 stsp
251 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
252 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
253 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
254 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
255 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
256 ebf48fd5 2019-08-03 stsp
257 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
258 ebf48fd5 2019-08-03 stsp
259 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
260 fc414659 2022-04-16 thomas ret=$?
261 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
262 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
263 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
264 ebf48fd5 2019-08-03 stsp return 1
265 ebf48fd5 2019-08-03 stsp fi
266 ebf48fd5 2019-08-03 stsp
267 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
268 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
269 fc414659 2022-04-16 thomas ret=$?
270 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
271 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
272 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
273 ebf48fd5 2019-08-03 stsp return 1
274 ebf48fd5 2019-08-03 stsp fi
275 ebf48fd5 2019-08-03 stsp
276 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
277 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
278 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
279 735ef5ac 2019-08-03 stsp
280 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
281 fc414659 2022-04-16 thomas ret=$?
282 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
283 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
284 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
285 735ef5ac 2019-08-03 stsp return 1
286 735ef5ac 2019-08-03 stsp fi
287 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
288 fc414659 2022-04-16 thomas ret=$?
289 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
290 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
291 735ef5ac 2019-08-03 stsp fi
292 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
293 735ef5ac 2019-08-03 stsp }
294 735ef5ac 2019-08-03 stsp
295 f6cae3ed 2020-09-13 naddy test_stage_out_of_date() {
296 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
297 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
298 735ef5ac 2019-08-03 stsp
299 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
300 fc414659 2022-04-16 thomas ret=$?
301 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
302 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
303 735ef5ac 2019-08-03 stsp return 1
304 735ef5ac 2019-08-03 stsp fi
305 735ef5ac 2019-08-03 stsp
306 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
307 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
308 735ef5ac 2019-08-03 stsp
309 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
310 735ef5ac 2019-08-03 stsp
311 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
312 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
313 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
314 fc414659 2022-04-16 thomas ret=$?
315 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
316 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
317 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
318 735ef5ac 2019-08-03 stsp return 1
319 735ef5ac 2019-08-03 stsp fi
320 735ef5ac 2019-08-03 stsp
321 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
322 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
323 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
324 ebf48fd5 2019-08-03 stsp
325 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
326 fc414659 2022-04-16 thomas ret=$?
327 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
328 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
329 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
330 ebf48fd5 2019-08-03 stsp return 1
331 ebf48fd5 2019-08-03 stsp fi
332 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
333 fc414659 2022-04-16 thomas ret=$?
334 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
335 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
336 ebf48fd5 2019-08-03 stsp fi
337 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
338 ebf48fd5 2019-08-03 stsp }
339 ebf48fd5 2019-08-03 stsp
340 ebf48fd5 2019-08-03 stsp
341 f6cae3ed 2020-09-13 naddy test_double_stage() {
342 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
343 d3e7c587 2019-08-03 stsp
344 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
345 fc414659 2022-04-16 thomas ret=$?
346 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
347 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
348 d3e7c587 2019-08-03 stsp return 1
349 d3e7c587 2019-08-03 stsp fi
350 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
351 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
352 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
353 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
354 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
355 d3e7c587 2019-08-03 stsp
356 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
357 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
358 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
359 fc414659 2022-04-16 thomas ret=$?
360 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
361 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
362 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
363 d3e7c587 2019-08-03 stsp return 1
364 d3e7c587 2019-08-03 stsp fi
365 d3e7c587 2019-08-03 stsp
366 7b5dc508 2019-10-28 stsp (cd $testroot/wt && got stage beta \
367 7b5dc508 2019-10-28 stsp > $testroot/stdout 2> $testroot/stderr)
368 fc414659 2022-04-16 thomas ret=$?
369 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
370 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
371 7b5dc508 2019-10-28 stsp test_done "$testroot" "1"
372 7b5dc508 2019-10-28 stsp return 1
373 7b5dc508 2019-10-28 stsp fi
374 7b5dc508 2019-10-28 stsp echo -n > $testroot/stdout.expected
375 7b5dc508 2019-10-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
376 fc414659 2022-04-16 thomas ret=$?
377 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
378 7b5dc508 2019-10-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
379 7b5dc508 2019-10-28 stsp test_done "$testroot" "$ret"
380 7b5dc508 2019-10-28 stsp return 1
381 7b5dc508 2019-10-28 stsp fi
382 7b5dc508 2019-10-28 stsp
383 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
384 7b5dc508 2019-10-28 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
385 7b5dc508 2019-10-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
386 fc414659 2022-04-16 thomas ret=$?
387 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
388 7b5dc508 2019-10-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
389 7b5dc508 2019-10-28 stsp test_done "$testroot" "$ret"
390 7b5dc508 2019-10-28 stsp return 1
391 7b5dc508 2019-10-28 stsp fi
392 7b5dc508 2019-10-28 stsp
393 7b5dc508 2019-10-28 stsp printf "q\n" > $testroot/patchscript
394 7b5dc508 2019-10-28 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
395 7b5dc508 2019-10-28 stsp > $testroot/stdout 2> $testroot/stderr)
396 fc414659 2022-04-16 thomas ret=$?
397 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
398 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
399 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
400 d3e7c587 2019-08-03 stsp return 1
401 d3e7c587 2019-08-03 stsp fi
402 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
403 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
404 fc414659 2022-04-16 thomas ret=$?
405 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
406 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
407 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
408 d3e7c587 2019-08-03 stsp return 1
409 d3e7c587 2019-08-03 stsp fi
410 d3e7c587 2019-08-03 stsp
411 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
412 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
413 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
414 fc414659 2022-04-16 thomas ret=$?
415 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
416 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
417 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
418 d3e7c587 2019-08-03 stsp return 1
419 d3e7c587 2019-08-03 stsp fi
420 d3e7c587 2019-08-03 stsp
421 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
422 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
423 d3e7c587 2019-08-03 stsp
424 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
425 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
426 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
427 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
428 fc414659 2022-04-16 thomas ret=$?
429 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
430 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
431 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
432 d3e7c587 2019-08-03 stsp return 1
433 d3e7c587 2019-08-03 stsp fi
434 d3e7c587 2019-08-03 stsp
435 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
436 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
437 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
438 fccbfb98 2019-08-03 stsp
439 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
440 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
441 fc414659 2022-04-16 thomas ret=$?
442 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
443 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
444 fccbfb98 2019-08-03 stsp fi
445 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
446 fccbfb98 2019-08-03 stsp }
447 fccbfb98 2019-08-03 stsp
448 f6cae3ed 2020-09-13 naddy test_stage_status() {
449 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
450 c363b2c1 2019-08-03 stsp
451 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
452 fc414659 2022-04-16 thomas ret=$?
453 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
454 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
455 c363b2c1 2019-08-03 stsp return 1
456 c363b2c1 2019-08-03 stsp fi
457 c363b2c1 2019-08-03 stsp
458 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
459 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
460 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
461 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
462 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
463 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
464 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
465 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
466 c363b2c1 2019-08-03 stsp
467 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
468 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
469 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
470 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
471 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
472 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
473 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
474 c363b2c1 2019-08-03 stsp
475 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
476 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
477 fc414659 2022-04-16 thomas ret=$?
478 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
479 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
480 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
481 244725f2 2019-08-03 stsp return 1
482 c363b2c1 2019-08-03 stsp fi
483 244725f2 2019-08-03 stsp
484 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
485 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
486 244725f2 2019-08-03 stsp
487 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
488 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
489 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
490 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
491 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
492 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
493 244725f2 2019-08-03 stsp
494 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
495 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
496 fc414659 2022-04-16 thomas ret=$?
497 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
498 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
499 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
500 244725f2 2019-08-03 stsp return 1
501 244725f2 2019-08-03 stsp fi
502 244725f2 2019-08-03 stsp
503 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
504 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
505 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
506 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
507 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
508 fc414659 2022-04-16 thomas ret=$?
509 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
510 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
511 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
512 244725f2 2019-08-03 stsp return 1
513 244725f2 2019-08-03 stsp fi
514 244725f2 2019-08-03 stsp
515 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
516 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
517 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
518 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
519 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
520 fc414659 2022-04-16 thomas ret=$?
521 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
522 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
523 244725f2 2019-08-03 stsp fi
524 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
525 244725f2 2019-08-03 stsp
526 c363b2c1 2019-08-03 stsp }
527 c363b2c1 2019-08-03 stsp
528 f6cae3ed 2020-09-13 naddy test_stage_add_already_staged_file() {
529 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
530 1e1446d3 2019-08-03 stsp
531 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
532 fc414659 2022-04-16 thomas ret=$?
533 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
534 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
535 1e1446d3 2019-08-03 stsp return 1
536 1e1446d3 2019-08-03 stsp fi
537 1e1446d3 2019-08-03 stsp
538 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
539 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
540 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
541 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
542 1e1446d3 2019-08-03 stsp
543 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
544 1e1446d3 2019-08-03 stsp
545 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
546 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
547 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
548 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
549 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
550 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
551 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
552 fc414659 2022-04-16 thomas ret=$?
553 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
554 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
555 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
556 1e1446d3 2019-08-03 stsp return 1
557 1e1446d3 2019-08-03 stsp fi
558 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
559 fc414659 2022-04-16 thomas ret=$?
560 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
561 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
562 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
563 1e1446d3 2019-08-03 stsp return 1
564 1e1446d3 2019-08-03 stsp fi
565 1e1446d3 2019-08-03 stsp done
566 1e1446d3 2019-08-03 stsp
567 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
568 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
569 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
570 1e1446d3 2019-08-03 stsp
571 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
572 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
573 fc414659 2022-04-16 thomas ret=$?
574 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
575 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
576 1e1446d3 2019-08-03 stsp fi
577 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
578 1e1446d3 2019-08-03 stsp }
579 1e1446d3 2019-08-03 stsp
580 f6cae3ed 2020-09-13 naddy test_stage_rm_already_staged_file() {
581 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
582 9acbc4fa 2019-08-03 stsp
583 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
584 fc414659 2022-04-16 thomas ret=$?
585 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
586 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
587 9acbc4fa 2019-08-03 stsp return 1
588 9acbc4fa 2019-08-03 stsp fi
589 9acbc4fa 2019-08-03 stsp
590 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
591 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
592 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
593 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
594 9acbc4fa 2019-08-03 stsp
595 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
596 9acbc4fa 2019-08-03 stsp
597 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
598 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
599 fc414659 2022-04-16 thomas ret=$?
600 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
601 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
602 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
603 9acbc4fa 2019-08-03 stsp return 1
604 9acbc4fa 2019-08-03 stsp fi
605 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
606 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
607 fc414659 2022-04-16 thomas ret=$?
608 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
609 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
610 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
611 6d022e97 2019-08-04 stsp return 1
612 6d022e97 2019-08-04 stsp fi
613 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
614 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
615 fc414659 2022-04-16 thomas ret=$?
616 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
617 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
618 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
619 9acbc4fa 2019-08-03 stsp return 1
620 9acbc4fa 2019-08-03 stsp fi
621 9acbc4fa 2019-08-03 stsp
622 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
623 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
624 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
625 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
626 fc414659 2022-04-16 thomas ret=$?
627 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
628 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
629 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
630 9acbc4fa 2019-08-03 stsp return 1
631 9acbc4fa 2019-08-03 stsp fi
632 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
633 fc414659 2022-04-16 thomas ret=$?
634 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
635 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
636 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
637 9acbc4fa 2019-08-03 stsp return 1
638 9acbc4fa 2019-08-03 stsp fi
639 9acbc4fa 2019-08-03 stsp done
640 9acbc4fa 2019-08-03 stsp
641 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
642 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
643 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
644 9acbc4fa 2019-08-03 stsp
645 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
646 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
647 fc414659 2022-04-16 thomas ret=$?
648 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
649 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
650 9acbc4fa 2019-08-03 stsp fi
651 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
652 9acbc4fa 2019-08-03 stsp }
653 24278f30 2019-08-03 stsp
654 f6cae3ed 2020-09-13 naddy test_stage_revert() {
655 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
656 24278f30 2019-08-03 stsp
657 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
658 fc414659 2022-04-16 thomas ret=$?
659 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
660 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
661 24278f30 2019-08-03 stsp return 1
662 24278f30 2019-08-03 stsp fi
663 24278f30 2019-08-03 stsp
664 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
665 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
666 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
667 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
668 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
669 24278f30 2019-08-03 stsp
670 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
671 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
672 24278f30 2019-08-03 stsp
673 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
674 fc414659 2022-04-16 thomas ret=$?
675 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
676 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
677 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
678 24278f30 2019-08-03 stsp return 1
679 24278f30 2019-08-03 stsp fi
680 24278f30 2019-08-03 stsp
681 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
682 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
683 fc414659 2022-04-16 thomas ret=$?
684 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
685 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
686 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
687 24278f30 2019-08-03 stsp return 1
688 24278f30 2019-08-03 stsp fi
689 24278f30 2019-08-03 stsp
690 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
691 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
692 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
693 fc414659 2022-04-16 thomas ret=$?
694 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
695 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
696 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
697 24278f30 2019-08-03 stsp return 1
698 24278f30 2019-08-03 stsp fi
699 9acbc4fa 2019-08-03 stsp
700 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
701 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
702 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
703 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
704 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
705 fc414659 2022-04-16 thomas ret=$?
706 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
707 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
708 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
709 24278f30 2019-08-03 stsp return 1
710 24278f30 2019-08-03 stsp fi
711 24278f30 2019-08-03 stsp
712 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
713 fc414659 2022-04-16 thomas ret=$?
714 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
715 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
716 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
717 24278f30 2019-08-03 stsp return 1
718 24278f30 2019-08-03 stsp fi
719 24278f30 2019-08-03 stsp
720 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
721 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
722 fc414659 2022-04-16 thomas ret=$?
723 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
724 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
725 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
726 24278f30 2019-08-03 stsp return 1
727 24278f30 2019-08-03 stsp fi
728 24278f30 2019-08-03 stsp
729 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
730 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
731 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
732 fc414659 2022-04-16 thomas ret=$?
733 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
734 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
735 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
736 24278f30 2019-08-03 stsp return 1
737 24278f30 2019-08-03 stsp fi
738 24278f30 2019-08-03 stsp
739 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
740 24278f30 2019-08-03 stsp 2> $testroot/stderr)
741 fc414659 2022-04-16 thomas ret=$?
742 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
743 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
744 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
745 24278f30 2019-08-03 stsp return 1
746 24278f30 2019-08-03 stsp fi
747 24278f30 2019-08-03 stsp
748 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stdout.expected
749 d3bcc3d1 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
750 fc414659 2022-04-16 thomas ret=$?
751 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
752 d3bcc3d1 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
753 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
754 d3bcc3d1 2019-08-08 stsp return 1
755 d3bcc3d1 2019-08-08 stsp fi
756 d3bcc3d1 2019-08-08 stsp
757 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
758 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
759 fc414659 2022-04-16 thomas ret=$?
760 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
761 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
762 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
763 24278f30 2019-08-03 stsp return 1
764 24278f30 2019-08-03 stsp fi
765 24278f30 2019-08-03 stsp
766 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
767 fc414659 2022-04-16 thomas ret=$?
768 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
769 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
770 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
771 24278f30 2019-08-03 stsp return 1
772 24278f30 2019-08-03 stsp fi
773 24278f30 2019-08-03 stsp
774 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
775 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
776 fc414659 2022-04-16 thomas ret=$?
777 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
778 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
779 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
780 24278f30 2019-08-03 stsp return 1
781 24278f30 2019-08-03 stsp fi
782 24278f30 2019-08-03 stsp
783 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
784 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
785 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
786 fc414659 2022-04-16 thomas ret=$?
787 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
788 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
789 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
790 24278f30 2019-08-03 stsp return 1
791 24278f30 2019-08-03 stsp fi
792 24278f30 2019-08-03 stsp
793 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
794 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
795 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
796 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
797 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
798 fc414659 2022-04-16 thomas ret=$?
799 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
800 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
801 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
802 24278f30 2019-08-03 stsp return 1
803 24278f30 2019-08-03 stsp fi
804 24278f30 2019-08-03 stsp
805 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
806 fc414659 2022-04-16 thomas ret=$?
807 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
808 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
809 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
810 24278f30 2019-08-03 stsp return 1
811 24278f30 2019-08-03 stsp fi
812 24278f30 2019-08-03 stsp
813 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
814 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
815 fc414659 2022-04-16 thomas ret=$?
816 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
817 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
818 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
819 24278f30 2019-08-03 stsp return 1
820 24278f30 2019-08-03 stsp fi
821 24278f30 2019-08-03 stsp
822 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
823 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
824 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
825 fc414659 2022-04-16 thomas ret=$?
826 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
827 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
828 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
829 24278f30 2019-08-03 stsp return 1
830 24278f30 2019-08-03 stsp fi
831 24278f30 2019-08-03 stsp
832 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
833 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
834 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
835 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
836 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
837 fc414659 2022-04-16 thomas ret=$?
838 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
839 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
840 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
841 0f6d7415 2019-08-08 stsp return 1
842 0f6d7415 2019-08-08 stsp fi
843 0f6d7415 2019-08-08 stsp
844 0f6d7415 2019-08-08 stsp echo "modified file again" >> $testroot/wt/alpha
845 0f6d7415 2019-08-08 stsp echo "modified added file again" >> $testroot/wt/foo
846 0f6d7415 2019-08-08 stsp
847 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout \
848 0f6d7415 2019-08-08 stsp 2> $testroot/stderr)
849 fc414659 2022-04-16 thomas ret=$?
850 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
851 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
852 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
853 0f6d7415 2019-08-08 stsp return 1
854 0f6d7415 2019-08-08 stsp fi
855 0f6d7415 2019-08-08 stsp
856 0f6d7415 2019-08-08 stsp echo "R alpha" > $testroot/stdout.expected
857 d3bcc3d1 2019-08-08 stsp echo "R foo" >> $testroot/stdout.expected
858 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
859 fc414659 2022-04-16 thomas ret=$?
860 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
861 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
862 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
863 0f6d7415 2019-08-08 stsp return 1
864 0f6d7415 2019-08-08 stsp fi
865 0f6d7415 2019-08-08 stsp
866 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
867 0f6d7415 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
868 fc414659 2022-04-16 thomas ret=$?
869 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
870 0f6d7415 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
871 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
872 0f6d7415 2019-08-08 stsp return 1
873 0f6d7415 2019-08-08 stsp fi
874 0f6d7415 2019-08-08 stsp
875 0f6d7415 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
876 0f6d7415 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
877 d3bcc3d1 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
878 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
879 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
880 fc414659 2022-04-16 thomas ret=$?
881 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
882 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
883 408b4ebc 2019-08-03 stsp fi
884 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
885 408b4ebc 2019-08-03 stsp }
886 408b4ebc 2019-08-03 stsp
887 f6cae3ed 2020-09-13 naddy test_stage_diff() {
888 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
889 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
890 408b4ebc 2019-08-03 stsp
891 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
892 fc414659 2022-04-16 thomas ret=$?
893 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
894 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
895 408b4ebc 2019-08-03 stsp return 1
896 408b4ebc 2019-08-03 stsp fi
897 408b4ebc 2019-08-03 stsp
898 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
899 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
900 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
901 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
902 98eaaa12 2019-08-03 stsp
903 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
904 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
905 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
906 fc414659 2022-04-16 thomas ret=$?
907 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
908 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
909 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
910 98eaaa12 2019-08-03 stsp return 1
911 98eaaa12 2019-08-03 stsp fi
912 408b4ebc 2019-08-03 stsp
913 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
914 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
915 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
916 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
917 408b4ebc 2019-08-03 stsp
918 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
919 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
920 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
921 fc414659 2022-04-16 thomas ret=$?
922 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
923 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
924 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
925 408b4ebc 2019-08-03 stsp return 1
926 408b4ebc 2019-08-03 stsp fi
927 408b4ebc 2019-08-03 stsp
928 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
929 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
930 408b4ebc 2019-08-03 stsp
931 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
932 408b4ebc 2019-08-03 stsp
933 9b4458b4 2022-06-26 thomas echo "diff $testroot/wt" > $testroot/stdout.expected
934 9b4458b4 2022-06-26 thomas echo "commit - $head_commit" >> $testroot/stdout.expected
935 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt" >> $testroot/stdout.expected
936 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
937 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
938 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
939 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
940 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
941 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
942 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
943 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
944 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
945 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
946 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
947 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
948 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
949 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
950 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
951 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
952 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
953 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
954 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
955 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
956 98eaaa12 2019-08-03 stsp
957 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
958 fc414659 2022-04-16 thomas ret=$?
959 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
960 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
961 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
962 98eaaa12 2019-08-03 stsp return 1
963 98eaaa12 2019-08-03 stsp fi
964 98eaaa12 2019-08-03 stsp
965 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
966 98eaaa12 2019-08-03 stsp
967 9b4458b4 2022-06-26 thomas echo "diff -s $testroot/wt" > $testroot/stdout.expected
968 9b4458b4 2022-06-26 thomas echo "commit - $head_commit" >> $testroot/stdout.expected
969 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
970 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
971 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
972 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
973 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
974 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
975 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
976 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
977 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
978 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
979 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
980 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
981 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
982 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
983 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
984 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
985 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
986 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
987 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
988 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
989 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
990 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
991 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
992 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
993 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
994 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
995 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
996 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
997 408b4ebc 2019-08-03 stsp
998 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
999 fc414659 2022-04-16 thomas ret=$?
1000 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1001 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1002 24278f30 2019-08-03 stsp fi
1003 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
1004 408b4ebc 2019-08-03 stsp
1005 24278f30 2019-08-03 stsp }
1006 b9622844 2019-08-03 stsp
1007 f6cae3ed 2020-09-13 naddy test_stage_histedit() {
1008 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
1009 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
1010 b9622844 2019-08-03 stsp
1011 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1012 fc414659 2022-04-16 thomas ret=$?
1013 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1014 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1015 b9622844 2019-08-03 stsp return 1
1016 b9622844 2019-08-03 stsp fi
1017 b9622844 2019-08-03 stsp
1018 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1019 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1020 b9622844 2019-08-03 stsp
1021 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
1022 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1023 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
1024 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1025 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
1026 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
1027 24278f30 2019-08-03 stsp
1028 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1029 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1030 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
1031 b9622844 2019-08-03 stsp
1032 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
1033 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1034 b9622844 2019-08-03 stsp
1035 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1036 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1037 fc414659 2022-04-16 thomas ret=$?
1038 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1039 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
1040 b9622844 2019-08-03 stsp test_done "$testroot" "1"
1041 b9622844 2019-08-03 stsp return 1
1042 b9622844 2019-08-03 stsp fi
1043 b9622844 2019-08-03 stsp
1044 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
1045 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1046 b9622844 2019-08-03 stsp
1047 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1048 fc414659 2022-04-16 thomas ret=$?
1049 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1050 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1051 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1052 b9622844 2019-08-03 stsp return 1
1053 b9622844 2019-08-03 stsp fi
1054 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1055 fc414659 2022-04-16 thomas ret=$?
1056 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1057 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1058 b9622844 2019-08-03 stsp fi
1059 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1060 243d7cf1 2019-08-03 stsp
1061 243d7cf1 2019-08-03 stsp }
1062 243d7cf1 2019-08-03 stsp
1063 f6cae3ed 2020-09-13 naddy test_stage_rebase() {
1064 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
1065 243d7cf1 2019-08-03 stsp
1066 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1067 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1068 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1069 243d7cf1 2019-08-03 stsp
1070 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1071 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1072 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1073 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1074 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1075 243d7cf1 2019-08-03 stsp
1076 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1077 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
1078 243d7cf1 2019-08-03 stsp
1079 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
1080 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1081 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1082 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
1083 243d7cf1 2019-08-03 stsp
1084 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1085 fc414659 2022-04-16 thomas ret=$?
1086 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1087 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1088 243d7cf1 2019-08-03 stsp return 1
1089 243d7cf1 2019-08-03 stsp fi
1090 243d7cf1 2019-08-03 stsp
1091 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1092 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1093 b9622844 2019-08-03 stsp
1094 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
1095 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1096 fc414659 2022-04-16 thomas ret=$?
1097 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1098 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
1099 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
1100 243d7cf1 2019-08-03 stsp return 1
1101 243d7cf1 2019-08-03 stsp fi
1102 243d7cf1 2019-08-03 stsp
1103 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
1104 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1105 243d7cf1 2019-08-03 stsp
1106 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1107 fc414659 2022-04-16 thomas ret=$?
1108 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1109 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1110 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1111 243d7cf1 2019-08-03 stsp return 1
1112 243d7cf1 2019-08-03 stsp fi
1113 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1114 fc414659 2022-04-16 thomas ret=$?
1115 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1116 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1117 243d7cf1 2019-08-03 stsp fi
1118 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1119 b9622844 2019-08-03 stsp }
1120 b9622844 2019-08-03 stsp
1121 f6cae3ed 2020-09-13 naddy test_stage_update() {
1122 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1123 a76c42e6 2019-08-03 stsp
1124 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1125 fc414659 2022-04-16 thomas ret=$?
1126 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1127 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1128 a76c42e6 2019-08-03 stsp return 1
1129 a76c42e6 2019-08-03 stsp fi
1130 243d7cf1 2019-08-03 stsp
1131 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1132 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1133 a76c42e6 2019-08-03 stsp
1134 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1135 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1136 a76c42e6 2019-08-03 stsp
1137 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1138 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1139 fc414659 2022-04-16 thomas ret=$?
1140 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1141 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1142 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1143 a76c42e6 2019-08-03 stsp return 1
1144 a76c42e6 2019-08-03 stsp fi
1145 a76c42e6 2019-08-03 stsp
1146 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1147 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1148 a76c42e6 2019-08-03 stsp
1149 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1150 fc414659 2022-04-16 thomas ret=$?
1151 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1152 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1153 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1154 a76c42e6 2019-08-03 stsp return 1
1155 a76c42e6 2019-08-03 stsp fi
1156 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1157 fc414659 2022-04-16 thomas ret=$?
1158 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1159 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1160 a76c42e6 2019-08-03 stsp fi
1161 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1162 a76c42e6 2019-08-03 stsp }
1163 f0b75401 2019-08-03 stsp
1164 f6cae3ed 2020-09-13 naddy test_stage_commit_non_staged() {
1165 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1166 f0b75401 2019-08-03 stsp
1167 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1168 fc414659 2022-04-16 thomas ret=$?
1169 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1170 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1171 f0b75401 2019-08-03 stsp return 1
1172 f0b75401 2019-08-03 stsp fi
1173 f0b75401 2019-08-03 stsp
1174 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1175 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1176 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1177 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1178 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1179 a76c42e6 2019-08-03 stsp
1180 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1181 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1182 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1183 fc414659 2022-04-16 thomas ret=$?
1184 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1185 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1186 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1187 f0b75401 2019-08-03 stsp return 1
1188 f0b75401 2019-08-03 stsp fi
1189 f0b75401 2019-08-03 stsp
1190 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1191 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1192 f0b75401 2019-08-03 stsp
1193 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1194 fc414659 2022-04-16 thomas ret=$?
1195 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1196 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1197 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1198 5f8a88c6 2019-08-03 stsp return 1
1199 5f8a88c6 2019-08-03 stsp fi
1200 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1201 fc414659 2022-04-16 thomas ret=$?
1202 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1203 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1204 5f8a88c6 2019-08-03 stsp fi
1205 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1206 5f8a88c6 2019-08-03 stsp }
1207 0f1cfa7f 2019-08-08 stsp
1208 f6cae3ed 2020-09-13 naddy test_stage_commit_out_of_date() {
1209 0f1cfa7f 2019-08-08 stsp local testroot=`test_init stage_commit_out_of_date`
1210 0f1cfa7f 2019-08-08 stsp
1211 0f1cfa7f 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1212 fc414659 2022-04-16 thomas ret=$?
1213 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1214 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1215 0f1cfa7f 2019-08-08 stsp return 1
1216 0f1cfa7f 2019-08-08 stsp fi
1217 0f1cfa7f 2019-08-08 stsp
1218 0f1cfa7f 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
1219 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
1220 0f1cfa7f 2019-08-08 stsp echo "new file" > $testroot/wt/foo
1221 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
1222 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1223 0f1cfa7f 2019-08-08 stsp
1224 0f1cfa7f 2019-08-08 stsp echo "changed file" > $testroot/repo/alpha
1225 0f1cfa7f 2019-08-08 stsp git_commit $testroot/repo -m "changed alpha in repo"
1226 0f1cfa7f 2019-08-08 stsp
1227 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1228 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1229 fc414659 2022-04-16 thomas ret=$?
1230 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1231 0f1cfa7f 2019-08-08 stsp echo "got commit command succeeded unexpectedly" >&2
1232 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "1"
1233 0f1cfa7f 2019-08-08 stsp return 1
1234 0f1cfa7f 2019-08-08 stsp fi
1235 0f1cfa7f 2019-08-08 stsp
1236 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1237 0f1cfa7f 2019-08-08 stsp echo -n "got: work tree must be updated before these changes " \
1238 0f1cfa7f 2019-08-08 stsp > $testroot/stderr.expected
1239 0f1cfa7f 2019-08-08 stsp echo "can be committed" >> $testroot/stderr.expected
1240 5f8a88c6 2019-08-03 stsp
1241 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1242 fc414659 2022-04-16 thomas ret=$?
1243 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1244 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1245 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1246 0f1cfa7f 2019-08-08 stsp return 1
1247 0f1cfa7f 2019-08-08 stsp fi
1248 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1249 fc414659 2022-04-16 thomas ret=$?
1250 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1251 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1252 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1253 0f1cfa7f 2019-08-08 stsp return 1
1254 0f1cfa7f 2019-08-08 stsp fi
1255 0f1cfa7f 2019-08-08 stsp
1256 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout \
1257 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1258 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1259 0f1cfa7f 2019-08-08 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1260 0f1cfa7f 2019-08-08 stsp
1261 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1262 fc414659 2022-04-16 thomas ret=$?
1263 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1264 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1265 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1266 0f1cfa7f 2019-08-08 stsp return 1
1267 0f1cfa7f 2019-08-08 stsp fi
1268 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1269 fc414659 2022-04-16 thomas ret=$?
1270 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1271 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1272 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1273 0f1cfa7f 2019-08-08 stsp return 1
1274 0f1cfa7f 2019-08-08 stsp fi
1275 0f1cfa7f 2019-08-08 stsp
1276 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got unstage > /dev/null)
1277 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
1278 fc414659 2022-04-16 thomas ret=$?
1279 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1280 0f1cfa7f 2019-08-08 stsp echo "got update command failed unexpectedly" >&2
1281 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1282 0f1cfa7f 2019-08-08 stsp return 1
1283 0f1cfa7f 2019-08-08 stsp fi
1284 0f1cfa7f 2019-08-08 stsp
1285 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1286 0f1cfa7f 2019-08-08 stsp echo "C alpha" > $testroot/stdout.expected
1287 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1288 0f1cfa7f 2019-08-08 stsp echo "A foo" >> $testroot/stdout.expected
1289 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1290 fc414659 2022-04-16 thomas ret=$?
1291 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1292 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1293 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1294 0f1cfa7f 2019-08-08 stsp return 1
1295 0f1cfa7f 2019-08-08 stsp fi
1296 0f1cfa7f 2019-08-08 stsp
1297 0f1cfa7f 2019-08-08 stsp # resolve conflict
1298 0f1cfa7f 2019-08-08 stsp echo "resolved file" > $testroot/wt/alpha
1299 0f1cfa7f 2019-08-08 stsp
1300 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
1301 0f1cfa7f 2019-08-08 stsp
1302 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1303 fc414659 2022-04-16 thomas ret=$?
1304 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1305 0f1cfa7f 2019-08-08 stsp echo "got commit command failed unexpectedly" >&2
1306 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1307 0f1cfa7f 2019-08-08 stsp return 1
1308 0f1cfa7f 2019-08-08 stsp fi
1309 0f1cfa7f 2019-08-08 stsp
1310 0f1cfa7f 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1311 0f1cfa7f 2019-08-08 stsp echo "A foo" > $testroot/stdout.expected
1312 0f1cfa7f 2019-08-08 stsp echo "M alpha" >> $testroot/stdout.expected
1313 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1314 0f1cfa7f 2019-08-08 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1315 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1316 fc414659 2022-04-16 thomas ret=$?
1317 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1318 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1319 0f1cfa7f 2019-08-08 stsp fi
1320 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1321 0f1cfa7f 2019-08-08 stsp
1322 0f1cfa7f 2019-08-08 stsp }
1323 0f1cfa7f 2019-08-08 stsp
1324 f6cae3ed 2020-09-13 naddy test_stage_commit() {
1325 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1326 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1327 5f8a88c6 2019-08-03 stsp
1328 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1329 fc414659 2022-04-16 thomas ret=$?
1330 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1331 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1332 5f8a88c6 2019-08-03 stsp return 1
1333 5f8a88c6 2019-08-03 stsp fi
1334 5f8a88c6 2019-08-03 stsp
1335 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1336 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1337 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1338 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1339 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1340 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1341 5f8a88c6 2019-08-03 stsp
1342 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1343 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1344 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1345 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1346 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1347 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1348 5f8a88c6 2019-08-03 stsp
1349 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1350 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1351 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1352 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1353 5f8a88c6 2019-08-03 stsp
1354 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1355 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1356 fc414659 2022-04-16 thomas ret=$?
1357 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1358 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1359 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1360 5f8a88c6 2019-08-03 stsp return 1
1361 5f8a88c6 2019-08-03 stsp fi
1362 5f8a88c6 2019-08-03 stsp
1363 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1364 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1365 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1366 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1367 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1368 5f8a88c6 2019-08-03 stsp
1369 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1370 fc414659 2022-04-16 thomas ret=$?
1371 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1372 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1373 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1374 f0b75401 2019-08-03 stsp return 1
1375 f0b75401 2019-08-03 stsp fi
1376 5f8a88c6 2019-08-03 stsp
1377 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1378 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1379 5f8a88c6 2019-08-03 stsp
1380 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1381 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1382 9b4458b4 2022-06-26 thomas echo "commit - $first_commit" >> $testroot/stdout.expected
1383 9b4458b4 2022-06-26 thomas echo "commit + $head_commit" >> $testroot/stdout.expected
1384 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1385 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1386 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1387 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1388 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1389 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1390 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1391 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1392 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1393 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1394 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1395 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1396 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1397 46f68b20 2019-10-19 stsp | grep 'beta$' | cut -d' ' -f 1 | tr -d '\n' \
1398 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1399 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
1400 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1401 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1402 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1403 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1404 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1405 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1406 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1407 46f68b20 2019-10-19 stsp cat $testroot/blob_id_foo | tr -d '\n' >> $testroot/stdout.expected
1408 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
1409 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1410 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1411 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1412 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1413 5f8a88c6 2019-08-03 stsp
1414 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1415 fc414659 2022-04-16 thomas ret=$?
1416 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1417 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1418 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1419 5f8a88c6 2019-08-03 stsp return 1
1420 f0b75401 2019-08-03 stsp fi
1421 5f8a88c6 2019-08-03 stsp
1422 72fd46fa 2019-09-06 stsp echo 'M alpha' > $testroot/stdout.expected
1423 72fd46fa 2019-09-06 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
1424 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1425 72fd46fa 2019-09-06 stsp echo 'M foo' >> $testroot/stdout.expected
1426 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1427 5f8a88c6 2019-08-03 stsp
1428 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1429 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1430 fc414659 2022-04-16 thomas ret=$?
1431 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1432 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1433 5f8a88c6 2019-08-03 stsp fi
1434 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1435 f0b75401 2019-08-03 stsp }
1436 dc424a06 2019-08-07 stsp
1437 f6cae3ed 2020-09-13 naddy test_stage_patch() {
1438 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1439 dc424a06 2019-08-07 stsp
1440 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1441 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1442 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1443 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1444 dc424a06 2019-08-07 stsp
1445 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1446 fc414659 2022-04-16 thomas ret=$?
1447 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1448 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1449 dc424a06 2019-08-07 stsp return 1
1450 dc424a06 2019-08-07 stsp fi
1451 dc424a06 2019-08-07 stsp
1452 c206b220 2021-10-09 thomas sed -i '' -e 's/^2$/a/' $testroot/wt/numbers
1453 c206b220 2021-10-09 thomas sed -i '' -e 's/^7$/b/' $testroot/wt/numbers
1454 c206b220 2021-10-09 thomas sed -i '' -e 's/^16$/c/' $testroot/wt/numbers
1455 dc424a06 2019-08-07 stsp
1456 dc424a06 2019-08-07 stsp # don't stage any hunks
1457 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1458 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1459 7b5dc508 2019-10-28 stsp numbers > $testroot/stdout 2> $testroot/stderr)
1460 fc414659 2022-04-16 thomas ret=$?
1461 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1462 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
1463 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1464 dc424a06 2019-08-07 stsp return 1
1465 dc424a06 2019-08-07 stsp fi
1466 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1467 dc424a06 2019-08-07 stsp -----------------------------------------------
1468 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1469 dc424a06 2019-08-07 stsp 1
1470 dc424a06 2019-08-07 stsp -2
1471 dc424a06 2019-08-07 stsp +a
1472 dc424a06 2019-08-07 stsp 3
1473 dc424a06 2019-08-07 stsp 4
1474 dc424a06 2019-08-07 stsp 5
1475 dc424a06 2019-08-07 stsp -----------------------------------------------
1476 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1477 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1478 dc424a06 2019-08-07 stsp -----------------------------------------------
1479 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1480 dc424a06 2019-08-07 stsp 4
1481 dc424a06 2019-08-07 stsp 5
1482 dc424a06 2019-08-07 stsp 6
1483 dc424a06 2019-08-07 stsp -7
1484 dc424a06 2019-08-07 stsp +b
1485 dc424a06 2019-08-07 stsp 8
1486 dc424a06 2019-08-07 stsp 9
1487 dc424a06 2019-08-07 stsp 10
1488 dc424a06 2019-08-07 stsp -----------------------------------------------
1489 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1490 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1491 dc424a06 2019-08-07 stsp -----------------------------------------------
1492 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1493 dc424a06 2019-08-07 stsp 13
1494 dc424a06 2019-08-07 stsp 14
1495 dc424a06 2019-08-07 stsp 15
1496 dc424a06 2019-08-07 stsp -16
1497 dc424a06 2019-08-07 stsp +c
1498 dc424a06 2019-08-07 stsp -----------------------------------------------
1499 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1500 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1501 dc424a06 2019-08-07 stsp EOF
1502 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1503 fc414659 2022-04-16 thomas ret=$?
1504 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1505 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1506 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1507 dc424a06 2019-08-07 stsp return 1
1508 dc424a06 2019-08-07 stsp fi
1509 f0b75401 2019-08-03 stsp
1510 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
1511 7b5dc508 2019-10-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1512 fc414659 2022-04-16 thomas ret=$?
1513 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1514 7b5dc508 2019-10-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
1515 7b5dc508 2019-10-28 stsp test_done "$testroot" "$ret"
1516 7b5dc508 2019-10-28 stsp return 1
1517 7b5dc508 2019-10-28 stsp fi
1518 7b5dc508 2019-10-28 stsp
1519 7b5dc508 2019-10-28 stsp
1520 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1521 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1522 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1523 fc414659 2022-04-16 thomas ret=$?
1524 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1525 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1526 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1527 dc424a06 2019-08-07 stsp return 1
1528 dc424a06 2019-08-07 stsp fi
1529 dc424a06 2019-08-07 stsp
1530 dc424a06 2019-08-07 stsp # stage middle hunk
1531 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1532 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1533 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1534 dc424a06 2019-08-07 stsp
1535 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1536 dc424a06 2019-08-07 stsp -----------------------------------------------
1537 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1538 dc424a06 2019-08-07 stsp 1
1539 dc424a06 2019-08-07 stsp -2
1540 dc424a06 2019-08-07 stsp +a
1541 dc424a06 2019-08-07 stsp 3
1542 dc424a06 2019-08-07 stsp 4
1543 dc424a06 2019-08-07 stsp 5
1544 dc424a06 2019-08-07 stsp -----------------------------------------------
1545 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1546 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1547 dc424a06 2019-08-07 stsp -----------------------------------------------
1548 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1549 dc424a06 2019-08-07 stsp 4
1550 dc424a06 2019-08-07 stsp 5
1551 dc424a06 2019-08-07 stsp 6
1552 dc424a06 2019-08-07 stsp -7
1553 dc424a06 2019-08-07 stsp +b
1554 dc424a06 2019-08-07 stsp 8
1555 dc424a06 2019-08-07 stsp 9
1556 dc424a06 2019-08-07 stsp 10
1557 dc424a06 2019-08-07 stsp -----------------------------------------------
1558 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1559 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1560 dc424a06 2019-08-07 stsp -----------------------------------------------
1561 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1562 dc424a06 2019-08-07 stsp 13
1563 dc424a06 2019-08-07 stsp 14
1564 dc424a06 2019-08-07 stsp 15
1565 dc424a06 2019-08-07 stsp -16
1566 dc424a06 2019-08-07 stsp +c
1567 dc424a06 2019-08-07 stsp -----------------------------------------------
1568 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1569 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1570 dc424a06 2019-08-07 stsp EOF
1571 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1572 fc414659 2022-04-16 thomas ret=$?
1573 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1574 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1575 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1576 dc424a06 2019-08-07 stsp return 1
1577 dc424a06 2019-08-07 stsp fi
1578 dc424a06 2019-08-07 stsp
1579 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1580 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1581 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1582 fc414659 2022-04-16 thomas ret=$?
1583 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1584 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1585 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1586 dc424a06 2019-08-07 stsp return 1
1587 dc424a06 2019-08-07 stsp fi
1588 dc424a06 2019-08-07 stsp
1589 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1590 dc424a06 2019-08-07 stsp
1591 9b4458b4 2022-06-26 thomas echo "diff -s $testroot/wt" > $testroot/stdout.expected
1592 9b4458b4 2022-06-26 thomas echo "commit - $commit_id" >> $testroot/stdout.expected
1593 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
1594 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1595 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1596 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1597 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1598 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1599 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1600 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1601 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1602 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1603 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1604 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1605 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1606 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1607 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1608 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1609 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1610 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1611 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1612 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1613 fc414659 2022-04-16 thomas ret=$?
1614 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1615 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1616 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1617 dc424a06 2019-08-07 stsp return 1
1618 dc424a06 2019-08-07 stsp fi
1619 dc424a06 2019-08-07 stsp
1620 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1621 fc414659 2022-04-16 thomas ret=$?
1622 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1623 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1624 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1625 dc424a06 2019-08-07 stsp return 1
1626 dc424a06 2019-08-07 stsp fi
1627 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1628 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1629 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1630 fc414659 2022-04-16 thomas ret=$?
1631 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1632 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1633 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1634 dc424a06 2019-08-07 stsp return 1
1635 dc424a06 2019-08-07 stsp fi
1636 dc424a06 2019-08-07 stsp
1637 dc424a06 2019-08-07 stsp # stage last hunk
1638 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1639 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1640 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1641 dc424a06 2019-08-07 stsp
1642 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1643 dc424a06 2019-08-07 stsp -----------------------------------------------
1644 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1645 dc424a06 2019-08-07 stsp 1
1646 dc424a06 2019-08-07 stsp -2
1647 dc424a06 2019-08-07 stsp +a
1648 dc424a06 2019-08-07 stsp 3
1649 dc424a06 2019-08-07 stsp 4
1650 dc424a06 2019-08-07 stsp 5
1651 dc424a06 2019-08-07 stsp -----------------------------------------------
1652 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1653 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1654 dc424a06 2019-08-07 stsp -----------------------------------------------
1655 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1656 dc424a06 2019-08-07 stsp 4
1657 dc424a06 2019-08-07 stsp 5
1658 dc424a06 2019-08-07 stsp 6
1659 dc424a06 2019-08-07 stsp -7
1660 dc424a06 2019-08-07 stsp +b
1661 dc424a06 2019-08-07 stsp 8
1662 dc424a06 2019-08-07 stsp 9
1663 dc424a06 2019-08-07 stsp 10
1664 dc424a06 2019-08-07 stsp -----------------------------------------------
1665 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1666 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1667 dc424a06 2019-08-07 stsp -----------------------------------------------
1668 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1669 dc424a06 2019-08-07 stsp 13
1670 dc424a06 2019-08-07 stsp 14
1671 dc424a06 2019-08-07 stsp 15
1672 dc424a06 2019-08-07 stsp -16
1673 dc424a06 2019-08-07 stsp +c
1674 dc424a06 2019-08-07 stsp -----------------------------------------------
1675 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1676 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1677 dc424a06 2019-08-07 stsp EOF
1678 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1679 fc414659 2022-04-16 thomas ret=$?
1680 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1681 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1682 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1683 dc424a06 2019-08-07 stsp return 1
1684 dc424a06 2019-08-07 stsp fi
1685 dc424a06 2019-08-07 stsp
1686 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1687 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1688 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1689 fc414659 2022-04-16 thomas ret=$?
1690 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1691 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1692 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1693 dc424a06 2019-08-07 stsp return 1
1694 dc424a06 2019-08-07 stsp fi
1695 dc424a06 2019-08-07 stsp
1696 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1697 dc424a06 2019-08-07 stsp
1698 9b4458b4 2022-06-26 thomas echo "diff -s $testroot/wt" > $testroot/stdout.expected
1699 9b4458b4 2022-06-26 thomas echo "commit - $commit_id" >> $testroot/stdout.expected
1700 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
1701 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1702 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1703 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1704 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1705 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1706 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1707 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1708 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1709 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1710 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1711 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1712 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1713 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1714 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1715 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1716 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1717 fc414659 2022-04-16 thomas ret=$?
1718 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1719 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1720 af5a81b2 2019-08-08 stsp fi
1721 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1722 af5a81b2 2019-08-08 stsp }
1723 af5a81b2 2019-08-08 stsp
1724 f6cae3ed 2020-09-13 naddy test_stage_patch_twice() {
1725 af5a81b2 2019-08-08 stsp local testroot=`test_init stage_patch_twice`
1726 af5a81b2 2019-08-08 stsp
1727 af5a81b2 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1728 af5a81b2 2019-08-08 stsp (cd $testroot/repo && git add numbers)
1729 af5a81b2 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
1730 af5a81b2 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1731 af5a81b2 2019-08-08 stsp
1732 af5a81b2 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1733 fc414659 2022-04-16 thomas ret=$?
1734 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1735 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1736 af5a81b2 2019-08-08 stsp return 1
1737 af5a81b2 2019-08-08 stsp fi
1738 af5a81b2 2019-08-08 stsp
1739 c206b220 2021-10-09 thomas sed -i '' -e 's/^2$/a/' $testroot/wt/numbers
1740 c206b220 2021-10-09 thomas sed -i '' -e 's/^7$/b/' $testroot/wt/numbers
1741 c206b220 2021-10-09 thomas sed -i '' -e 's/^16$/c/' $testroot/wt/numbers
1742 af5a81b2 2019-08-08 stsp
1743 af5a81b2 2019-08-08 stsp # stage middle hunk
1744 af5a81b2 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
1745 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1746 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1747 af5a81b2 2019-08-08 stsp
1748 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1749 af5a81b2 2019-08-08 stsp -----------------------------------------------
1750 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1751 af5a81b2 2019-08-08 stsp 1
1752 af5a81b2 2019-08-08 stsp -2
1753 af5a81b2 2019-08-08 stsp +a
1754 af5a81b2 2019-08-08 stsp 3
1755 af5a81b2 2019-08-08 stsp 4
1756 af5a81b2 2019-08-08 stsp 5
1757 af5a81b2 2019-08-08 stsp -----------------------------------------------
1758 af5a81b2 2019-08-08 stsp M numbers (change 1 of 3)
1759 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1760 af5a81b2 2019-08-08 stsp -----------------------------------------------
1761 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1762 af5a81b2 2019-08-08 stsp 4
1763 af5a81b2 2019-08-08 stsp 5
1764 af5a81b2 2019-08-08 stsp 6
1765 af5a81b2 2019-08-08 stsp -7
1766 af5a81b2 2019-08-08 stsp +b
1767 af5a81b2 2019-08-08 stsp 8
1768 af5a81b2 2019-08-08 stsp 9
1769 af5a81b2 2019-08-08 stsp 10
1770 af5a81b2 2019-08-08 stsp -----------------------------------------------
1771 af5a81b2 2019-08-08 stsp M numbers (change 2 of 3)
1772 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1773 af5a81b2 2019-08-08 stsp -----------------------------------------------
1774 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1775 af5a81b2 2019-08-08 stsp 13
1776 af5a81b2 2019-08-08 stsp 14
1777 af5a81b2 2019-08-08 stsp 15
1778 af5a81b2 2019-08-08 stsp -16
1779 af5a81b2 2019-08-08 stsp +c
1780 af5a81b2 2019-08-08 stsp -----------------------------------------------
1781 af5a81b2 2019-08-08 stsp M numbers (change 3 of 3)
1782 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1783 af5a81b2 2019-08-08 stsp EOF
1784 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1785 fc414659 2022-04-16 thomas ret=$?
1786 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1787 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1788 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1789 af5a81b2 2019-08-08 stsp return 1
1790 af5a81b2 2019-08-08 stsp fi
1791 af5a81b2 2019-08-08 stsp
1792 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1793 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1794 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1795 fc414659 2022-04-16 thomas ret=$?
1796 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1797 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1798 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1799 af5a81b2 2019-08-08 stsp return 1
1800 af5a81b2 2019-08-08 stsp fi
1801 af5a81b2 2019-08-08 stsp
1802 af5a81b2 2019-08-08 stsp # stage last hunk
1803 af5a81b2 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
1804 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1805 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1806 af5a81b2 2019-08-08 stsp
1807 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1808 af5a81b2 2019-08-08 stsp -----------------------------------------------
1809 fe621944 2020-11-10 stsp @@ -1,5 +1,5 @@
1810 af5a81b2 2019-08-08 stsp 1
1811 af5a81b2 2019-08-08 stsp -2
1812 af5a81b2 2019-08-08 stsp +a
1813 af5a81b2 2019-08-08 stsp 3
1814 af5a81b2 2019-08-08 stsp 4
1815 af5a81b2 2019-08-08 stsp 5
1816 af5a81b2 2019-08-08 stsp -----------------------------------------------
1817 af5a81b2 2019-08-08 stsp M numbers (change 1 of 2)
1818 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1819 af5a81b2 2019-08-08 stsp -----------------------------------------------
1820 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@ b
1821 af5a81b2 2019-08-08 stsp 13
1822 af5a81b2 2019-08-08 stsp 14
1823 af5a81b2 2019-08-08 stsp 15
1824 af5a81b2 2019-08-08 stsp -16
1825 af5a81b2 2019-08-08 stsp +c
1826 af5a81b2 2019-08-08 stsp -----------------------------------------------
1827 af5a81b2 2019-08-08 stsp M numbers (change 2 of 2)
1828 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1829 af5a81b2 2019-08-08 stsp EOF
1830 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1831 fc414659 2022-04-16 thomas ret=$?
1832 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1833 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1834 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1835 af5a81b2 2019-08-08 stsp return 1
1836 af5a81b2 2019-08-08 stsp fi
1837 af5a81b2 2019-08-08 stsp
1838 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1839 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1840 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1841 fc414659 2022-04-16 thomas ret=$?
1842 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1843 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1844 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1845 af5a81b2 2019-08-08 stsp return 1
1846 af5a81b2 2019-08-08 stsp fi
1847 af5a81b2 2019-08-08 stsp
1848 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1849 af5a81b2 2019-08-08 stsp
1850 9b4458b4 2022-06-26 thomas echo "diff -s $testroot/wt" > $testroot/stdout.expected
1851 9b4458b4 2022-06-26 thomas echo "commit - $commit_id" >> $testroot/stdout.expected
1852 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
1853 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1854 af5a81b2 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
1855 af5a81b2 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1856 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1857 af5a81b2 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1858 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1859 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1860 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1861 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1862 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1863 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1864 af5a81b2 2019-08-08 stsp 4
1865 af5a81b2 2019-08-08 stsp 5
1866 af5a81b2 2019-08-08 stsp 6
1867 af5a81b2 2019-08-08 stsp -7
1868 af5a81b2 2019-08-08 stsp +b
1869 af5a81b2 2019-08-08 stsp 8
1870 af5a81b2 2019-08-08 stsp 9
1871 af5a81b2 2019-08-08 stsp 10
1872 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1873 af5a81b2 2019-08-08 stsp 13
1874 af5a81b2 2019-08-08 stsp 14
1875 af5a81b2 2019-08-08 stsp 15
1876 af5a81b2 2019-08-08 stsp -16
1877 af5a81b2 2019-08-08 stsp +c
1878 af5a81b2 2019-08-08 stsp EOF
1879 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1880 fc414659 2022-04-16 thomas ret=$?
1881 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1882 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1883 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1884 af5a81b2 2019-08-08 stsp return 1
1885 af5a81b2 2019-08-08 stsp fi
1886 af5a81b2 2019-08-08 stsp
1887 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1888 af5a81b2 2019-08-08 stsp
1889 9b4458b4 2022-06-26 thomas echo "diff $testroot/wt" > $testroot/stdout.expected
1890 9b4458b4 2022-06-26 thomas echo "commit - $commit_id" >> $testroot/stdout.expected
1891 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt" >> $testroot/stdout.expected
1892 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1893 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
1894 af5a81b2 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
1895 af5a81b2 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
1896 af5a81b2 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
1897 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1898 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1899 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1900 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1901 af5a81b2 2019-08-08 stsp 1
1902 af5a81b2 2019-08-08 stsp -2
1903 af5a81b2 2019-08-08 stsp +a
1904 af5a81b2 2019-08-08 stsp 3
1905 af5a81b2 2019-08-08 stsp 4
1906 af5a81b2 2019-08-08 stsp 5
1907 af5a81b2 2019-08-08 stsp EOF
1908 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1909 fc414659 2022-04-16 thomas ret=$?
1910 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1911 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1912 dc424a06 2019-08-07 stsp fi
1913 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1914 dc424a06 2019-08-07 stsp }
1915 dc424a06 2019-08-07 stsp
1916 f6cae3ed 2020-09-13 naddy test_stage_patch_added() {
1917 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1918 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1919 dc424a06 2019-08-07 stsp
1920 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1921 fc414659 2022-04-16 thomas ret=$?
1922 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1923 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1924 dc424a06 2019-08-07 stsp return 1
1925 dc424a06 2019-08-07 stsp fi
1926 dc424a06 2019-08-07 stsp
1927 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1928 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1929 dc424a06 2019-08-07 stsp
1930 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1931 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1932 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1933 dc424a06 2019-08-07 stsp
1934 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1935 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1936 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1937 fc414659 2022-04-16 thomas ret=$?
1938 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1939 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1940 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1941 dc424a06 2019-08-07 stsp return 1
1942 dc424a06 2019-08-07 stsp fi
1943 dc424a06 2019-08-07 stsp
1944 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1945 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1946 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1947 fc414659 2022-04-16 thomas ret=$?
1948 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1949 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1950 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1951 dc424a06 2019-08-07 stsp return 1
1952 dc424a06 2019-08-07 stsp fi
1953 dc424a06 2019-08-07 stsp
1954 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1955 dc424a06 2019-08-07 stsp
1956 9b4458b4 2022-06-26 thomas echo "diff -s $testroot/wt" > $testroot/stdout.expected
1957 9b4458b4 2022-06-26 thomas echo "commit - $commit_id" >> $testroot/stdout.expected
1958 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
1959 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1960 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1961 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1962 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1963 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1964 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1965 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1966 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1967 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1968 fc414659 2022-04-16 thomas ret=$?
1969 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1970 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1971 e70a841e 2019-08-08 stsp fi
1972 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1973 e70a841e 2019-08-08 stsp }
1974 e70a841e 2019-08-08 stsp
1975 f6cae3ed 2020-09-13 naddy test_stage_patch_added_twice() {
1976 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_added_twice`
1977 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1978 e70a841e 2019-08-08 stsp
1979 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1980 fc414659 2022-04-16 thomas ret=$?
1981 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1982 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1983 e70a841e 2019-08-08 stsp return 1
1984 e70a841e 2019-08-08 stsp fi
1985 e70a841e 2019-08-08 stsp
1986 e70a841e 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
1987 e70a841e 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1988 e70a841e 2019-08-08 stsp
1989 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1990 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1991 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout)
1992 e70a841e 2019-08-08 stsp
1993 e70a841e 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
1994 e70a841e 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1995 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1996 fc414659 2022-04-16 thomas ret=$?
1997 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1998 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1999 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2000 e70a841e 2019-08-08 stsp return 1
2001 e70a841e 2019-08-08 stsp fi
2002 e70a841e 2019-08-08 stsp
2003 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2004 e70a841e 2019-08-08 stsp echo " A epsilon/new" > $testroot/stdout.expected
2005 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2006 fc414659 2022-04-16 thomas ret=$?
2007 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2008 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2009 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2010 e70a841e 2019-08-08 stsp return 1
2011 dc424a06 2019-08-07 stsp fi
2012 e70a841e 2019-08-08 stsp
2013 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2014 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout 2> $testroot/stderr)
2015 fc414659 2022-04-16 thomas ret=$?
2016 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
2017 e70a841e 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2018 e70a841e 2019-08-08 stsp test_done "$testroot" "1"
2019 e70a841e 2019-08-08 stsp return 1
2020 e70a841e 2019-08-08 stsp fi
2021 e70a841e 2019-08-08 stsp
2022 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
2023 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2024 fc414659 2022-04-16 thomas ret=$?
2025 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2026 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2027 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2028 e70a841e 2019-08-08 stsp return 1
2029 e70a841e 2019-08-08 stsp fi
2030 e70a841e 2019-08-08 stsp
2031 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2032 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2033 fc414659 2022-04-16 thomas ret=$?
2034 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2035 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2036 e70a841e 2019-08-08 stsp fi
2037 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2038 dc424a06 2019-08-07 stsp }
2039 dc424a06 2019-08-07 stsp
2040 f6cae3ed 2020-09-13 naddy test_stage_patch_removed() {
2041 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
2042 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2043 dc424a06 2019-08-07 stsp
2044 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2045 fc414659 2022-04-16 thomas ret=$?
2046 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2047 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2048 dc424a06 2019-08-07 stsp return 1
2049 dc424a06 2019-08-07 stsp fi
2050 dc424a06 2019-08-07 stsp
2051 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
2052 dc424a06 2019-08-07 stsp
2053 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
2054 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2055 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
2056 dc424a06 2019-08-07 stsp
2057 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
2058 dc424a06 2019-08-07 stsp
2059 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
2060 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2061 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2062 fc414659 2022-04-16 thomas ret=$?
2063 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2064 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2065 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2066 dc424a06 2019-08-07 stsp return 1
2067 dc424a06 2019-08-07 stsp fi
2068 dc424a06 2019-08-07 stsp
2069 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2070 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
2071 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2072 fc414659 2022-04-16 thomas ret=$?
2073 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2074 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2075 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2076 dc424a06 2019-08-07 stsp return 1
2077 dc424a06 2019-08-07 stsp fi
2078 dc424a06 2019-08-07 stsp
2079 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2080 dc424a06 2019-08-07 stsp
2081 9b4458b4 2022-06-26 thomas echo "diff -s $testroot/wt" > $testroot/stdout.expected
2082 9b4458b4 2022-06-26 thomas echo "commit - $commit_id" >> $testroot/stdout.expected
2083 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
2084 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2085 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
2086 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
2087 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2088 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
2089 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
2090 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
2091 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
2092 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2093 fc414659 2022-04-16 thomas ret=$?
2094 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2095 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2096 dc424a06 2019-08-07 stsp fi
2097 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2098 dc424a06 2019-08-07 stsp }
2099 b353a198 2019-08-07 stsp
2100 f6cae3ed 2020-09-13 naddy test_stage_patch_removed_twice() {
2101 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_removed_twice`
2102 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2103 e70a841e 2019-08-08 stsp
2104 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2105 fc414659 2022-04-16 thomas ret=$?
2106 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2107 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2108 e70a841e 2019-08-08 stsp return 1
2109 e70a841e 2019-08-08 stsp fi
2110 e70a841e 2019-08-08 stsp
2111 e70a841e 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
2112 e70a841e 2019-08-08 stsp
2113 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2114 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2115 e70a841e 2019-08-08 stsp beta > $testroot/stdout)
2116 e70a841e 2019-08-08 stsp
2117 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2118 e70a841e 2019-08-08 stsp
2119 e70a841e 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
2120 e70a841e 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2121 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2122 fc414659 2022-04-16 thomas ret=$?
2123 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2124 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2125 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2126 e70a841e 2019-08-08 stsp return 1
2127 e70a841e 2019-08-08 stsp fi
2128 e70a841e 2019-08-08 stsp
2129 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2130 e70a841e 2019-08-08 stsp echo " D beta" > $testroot/stdout.expected
2131 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2132 fc414659 2022-04-16 thomas ret=$?
2133 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2134 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2135 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2136 e70a841e 2019-08-08 stsp return 1
2137 e70a841e 2019-08-08 stsp fi
2138 e70a841e 2019-08-08 stsp
2139 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p beta \
2140 e70a841e 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2141 fc414659 2022-04-16 thomas ret=$?
2142 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
2143 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
2144 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2145 e70a841e 2019-08-08 stsp return 1
2146 e70a841e 2019-08-08 stsp fi
2147 e70a841e 2019-08-08 stsp
2148 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
2149 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2150 fc414659 2022-04-16 thomas ret=$?
2151 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2152 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2153 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2154 e70a841e 2019-08-08 stsp return 1
2155 e70a841e 2019-08-08 stsp fi
2156 e70a841e 2019-08-08 stsp
2157 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2158 f289c82c 2022-06-13 thomas cmp -s $testroot/stdout.expected $testroot/stdout
2159 f289c82c 2022-06-13 thomas ret=$?
2160 f289c82c 2022-06-13 thomas if [ $ret -ne 0 ]; then
2161 f289c82c 2022-06-13 thomas diff -u $testroot/stdout.expected $testroot/stdout
2162 f289c82c 2022-06-13 thomas fi
2163 f289c82c 2022-06-13 thomas test_done "$testroot" "$ret"
2164 f289c82c 2022-06-13 thomas }
2165 f289c82c 2022-06-13 thomas
2166 f289c82c 2022-06-13 thomas test_stage_patch_reversed() {
2167 f289c82c 2022-06-13 thomas local testroot=`test_init stage_patch_reversed`
2168 f289c82c 2022-06-13 thomas
2169 f289c82c 2022-06-13 thomas got checkout $testroot/repo $testroot/wt > /dev/null
2170 f289c82c 2022-06-13 thomas ret=$?
2171 f289c82c 2022-06-13 thomas if [ $ret -ne 0 ]; then
2172 f289c82c 2022-06-13 thomas test_done "$testroot" "$ret"
2173 f289c82c 2022-06-13 thomas return 1
2174 f289c82c 2022-06-13 thomas fi
2175 f289c82c 2022-06-13 thomas
2176 f289c82c 2022-06-13 thomas echo 'ALPHA' > $testroot/wt/alpha
2177 f289c82c 2022-06-13 thomas (cd $testroot/wt && got stage alpha > $testroot/stdout)
2178 f289c82c 2022-06-13 thomas ret=$?
2179 f289c82c 2022-06-13 thomas if [ $ret -ne 0 ]; then
2180 f289c82c 2022-06-13 thomas test_done "$testroot" "$ret"
2181 f289c82c 2022-06-13 thomas return 1
2182 f289c82c 2022-06-13 thomas fi
2183 f289c82c 2022-06-13 thomas
2184 f289c82c 2022-06-13 thomas echo ' M alpha' > $testroot/stdout.expected
2185 f289c82c 2022-06-13 thomas cmp -s $testroot/stdout.expected $testroot/stdout
2186 f289c82c 2022-06-13 thomas ret=$?
2187 f289c82c 2022-06-13 thomas if [ $ret -ne 0 ]; then
2188 f289c82c 2022-06-13 thomas diff -u $testroot/stdout.expected $testroot/stdout
2189 f289c82c 2022-06-13 thomas test_done "$testroot" "$ret"
2190 f289c82c 2022-06-13 thomas return 1
2191 f289c82c 2022-06-13 thomas fi
2192 f289c82c 2022-06-13 thomas
2193 f289c82c 2022-06-13 thomas echo 'alpha' > $testroot/wt/alpha
2194 f289c82c 2022-06-13 thomas (cd $testroot/wt && got stage alpha > $testroot/stdout)
2195 f289c82c 2022-06-13 thomas ret=$?
2196 f289c82c 2022-06-13 thomas if [ $ret -ne 0 ]; then
2197 f289c82c 2022-06-13 thomas test_done "$testroot" "$ret"
2198 f289c82c 2022-06-13 thomas return 1
2199 f289c82c 2022-06-13 thomas fi
2200 f289c82c 2022-06-13 thomas
2201 f289c82c 2022-06-13 thomas echo ' M alpha' > $testroot/stdout.expected
2202 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2203 fc414659 2022-04-16 thomas ret=$?
2204 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2205 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2206 f289c82c 2022-06-13 thomas test_done "$testroot" "$ret"
2207 f289c82c 2022-06-13 thomas return 1
2208 f289c82c 2022-06-13 thomas fi
2209 f289c82c 2022-06-13 thomas
2210 f289c82c 2022-06-13 thomas (cd $testroot/wt && got status > $testroot/stdout)
2211 f289c82c 2022-06-13 thomas cmp -s /dev/null $testroot/stdout
2212 f289c82c 2022-06-13 thomas ret=$?
2213 f289c82c 2022-06-13 thomas if [ $ret -ne 0 ]; then
2214 f289c82c 2022-06-13 thomas diff -u /dev/null $testroot/stdout
2215 e70a841e 2019-08-08 stsp fi
2216 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2217 e70a841e 2019-08-08 stsp }
2218 e70a841e 2019-08-08 stsp
2219 f6cae3ed 2020-09-13 naddy test_stage_patch_quit() {
2220 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
2221 b353a198 2019-08-07 stsp
2222 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
2223 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2224 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2225 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2226 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2227 b353a198 2019-08-07 stsp
2228 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2229 fc414659 2022-04-16 thomas ret=$?
2230 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2231 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2232 b353a198 2019-08-07 stsp return 1
2233 b353a198 2019-08-07 stsp fi
2234 dc424a06 2019-08-07 stsp
2235 c206b220 2021-10-09 thomas sed -i '' -e 's/^2$/a/' $testroot/wt/numbers
2236 c206b220 2021-10-09 thomas sed -i '' -e 's/^7$/b/' $testroot/wt/numbers
2237 c206b220 2021-10-09 thomas sed -i '' -e 's/^16$/c/' $testroot/wt/numbers
2238 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
2239 b353a198 2019-08-07 stsp
2240 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
2241 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
2242 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
2243 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2244 2db2652d 2019-08-07 stsp > $testroot/stdout)
2245 fc414659 2022-04-16 thomas ret=$?
2246 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2247 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
2248 b353a198 2019-08-07 stsp test_done "$testroot" "1"
2249 b353a198 2019-08-07 stsp return 1
2250 b353a198 2019-08-07 stsp fi
2251 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
2252 b353a198 2019-08-07 stsp -----------------------------------------------
2253 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
2254 b353a198 2019-08-07 stsp 1
2255 b353a198 2019-08-07 stsp -2
2256 b353a198 2019-08-07 stsp +a
2257 b353a198 2019-08-07 stsp 3
2258 b353a198 2019-08-07 stsp 4
2259 b353a198 2019-08-07 stsp 5
2260 b353a198 2019-08-07 stsp -----------------------------------------------
2261 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
2262 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
2263 b353a198 2019-08-07 stsp -----------------------------------------------
2264 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
2265 b353a198 2019-08-07 stsp 4
2266 b353a198 2019-08-07 stsp 5
2267 b353a198 2019-08-07 stsp 6
2268 b353a198 2019-08-07 stsp -7
2269 b353a198 2019-08-07 stsp +b
2270 b353a198 2019-08-07 stsp 8
2271 b353a198 2019-08-07 stsp 9
2272 b353a198 2019-08-07 stsp 10
2273 b353a198 2019-08-07 stsp -----------------------------------------------
2274 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
2275 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
2276 88f33a19 2019-08-08 stsp D zzz
2277 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
2278 b353a198 2019-08-07 stsp EOF
2279 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2280 fc414659 2022-04-16 thomas ret=$?
2281 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2282 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2283 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2284 b353a198 2019-08-07 stsp return 1
2285 b353a198 2019-08-07 stsp fi
2286 b353a198 2019-08-07 stsp
2287 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2288 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
2289 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
2290 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2291 fc414659 2022-04-16 thomas ret=$?
2292 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2293 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2294 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2295 b353a198 2019-08-07 stsp return 1
2296 b353a198 2019-08-07 stsp fi
2297 b353a198 2019-08-07 stsp
2298 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2299 b353a198 2019-08-07 stsp
2300 9b4458b4 2022-06-26 thomas echo "diff -s $testroot/wt" > $testroot/stdout.expected
2301 9b4458b4 2022-06-26 thomas echo "commit - $commit_id" >> $testroot/stdout.expected
2302 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
2303 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2304 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
2305 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
2306 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2307 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2308 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
2309 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2310 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
2311 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
2312 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
2313 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
2314 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
2315 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
2316 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
2317 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
2318 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
2319 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2320 fc414659 2022-04-16 thomas ret=$?
2321 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2322 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2323 b353a198 2019-08-07 stsp fi
2324 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2325 b353a198 2019-08-07 stsp
2326 b353a198 2019-08-07 stsp }
2327 b353a198 2019-08-07 stsp
2328 f6cae3ed 2020-09-13 naddy test_stage_patch_incomplete_script() {
2329 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
2330 eba70f38 2019-08-08 stsp
2331 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
2332 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2333 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2334 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2335 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2336 eba70f38 2019-08-08 stsp
2337 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2338 fc414659 2022-04-16 thomas ret=$?
2339 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2340 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2341 eba70f38 2019-08-08 stsp return 1
2342 eba70f38 2019-08-08 stsp fi
2343 eba70f38 2019-08-08 stsp
2344 c206b220 2021-10-09 thomas sed -i '' -e 's/^2$/a/' $testroot/wt/numbers
2345 c206b220 2021-10-09 thomas sed -i '' -e 's/^7$/b/' $testroot/wt/numbers
2346 c206b220 2021-10-09 thomas sed -i '' -e 's/^16$/c/' $testroot/wt/numbers
2347 eba70f38 2019-08-08 stsp
2348 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
2349 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2350 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2351 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2352 fc414659 2022-04-16 thomas ret=$?
2353 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
2354 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2355 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
2356 eba70f38 2019-08-08 stsp return 1
2357 eba70f38 2019-08-08 stsp fi
2358 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
2359 eba70f38 2019-08-08 stsp -----------------------------------------------
2360 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
2361 eba70f38 2019-08-08 stsp 1
2362 eba70f38 2019-08-08 stsp -2
2363 eba70f38 2019-08-08 stsp +a
2364 eba70f38 2019-08-08 stsp 3
2365 eba70f38 2019-08-08 stsp 4
2366 eba70f38 2019-08-08 stsp 5
2367 eba70f38 2019-08-08 stsp -----------------------------------------------
2368 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
2369 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
2370 eba70f38 2019-08-08 stsp -----------------------------------------------
2371 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
2372 eba70f38 2019-08-08 stsp 4
2373 eba70f38 2019-08-08 stsp 5
2374 eba70f38 2019-08-08 stsp 6
2375 eba70f38 2019-08-08 stsp -7
2376 eba70f38 2019-08-08 stsp +b
2377 eba70f38 2019-08-08 stsp 8
2378 eba70f38 2019-08-08 stsp 9
2379 eba70f38 2019-08-08 stsp 10
2380 eba70f38 2019-08-08 stsp -----------------------------------------------
2381 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
2382 eba70f38 2019-08-08 stsp EOF
2383 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
2384 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
2385 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2386 fc414659 2022-04-16 thomas ret=$?
2387 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2388 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2389 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2390 eba70f38 2019-08-08 stsp return 1
2391 eba70f38 2019-08-08 stsp fi
2392 eba70f38 2019-08-08 stsp
2393 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2394 fc414659 2022-04-16 thomas ret=$?
2395 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2396 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2397 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2398 eba70f38 2019-08-08 stsp return 1
2399 eba70f38 2019-08-08 stsp fi
2400 eba70f38 2019-08-08 stsp
2401 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2402 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
2403 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2404 fc414659 2022-04-16 thomas ret=$?
2405 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2406 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2407 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2408 eba70f38 2019-08-08 stsp return 1
2409 eba70f38 2019-08-08 stsp fi
2410 eba70f38 2019-08-08 stsp
2411 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2412 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
2413 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2414 fc414659 2022-04-16 thomas ret=$?
2415 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2416 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2417 eba70f38 2019-08-08 stsp fi
2418 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2419 c631b115 2020-07-23 stsp
2420 c631b115 2020-07-23 stsp }
2421 c631b115 2020-07-23 stsp
2422 f6cae3ed 2020-09-13 naddy test_stage_symlink() {
2423 c631b115 2020-07-23 stsp local testroot=`test_init stage_symlink`
2424 c631b115 2020-07-23 stsp
2425 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2426 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
2427 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2428 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2429 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2430 c631b115 2020-07-23 stsp (cd $testroot/repo && git add .)
2431 c631b115 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2432 c631b115 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
2433 c631b115 2020-07-23 stsp
2434 c631b115 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2435 fc414659 2022-04-16 thomas ret=$?
2436 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2437 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2438 c631b115 2020-07-23 stsp return 1
2439 c631b115 2020-07-23 stsp fi
2440 c631b115 2020-07-23 stsp
2441 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
2442 dd6165e4 2021-09-21 thomas.ad (cd $testroot/wt && ln -sfT gamma epsilon.link)
2443 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
2444 c631b115 2020-07-23 stsp echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
2445 c631b115 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2446 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
2447 c631b115 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2448 c631b115 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
2449 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
2450 c631b115 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
2451 c631b115 2020-07-23 stsp
2452 35213c7c 2020-07-23 stsp (cd $testroot/wt && got stage > $testroot/stdout 2> $testroot/stderr)
2453 fc414659 2022-04-16 thomas ret=$?
2454 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
2455 35213c7c 2020-07-23 stsp echo "got stage succeeded unexpectedly" >&2
2456 4e2bdb0d 2022-06-13 thomas test_done "$testroot" 1
2457 35213c7c 2020-07-23 stsp return 1
2458 35213c7c 2020-07-23 stsp fi
2459 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
2460 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
2461 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
2462 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2463 fc414659 2022-04-16 thomas ret=$?
2464 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2465 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
2466 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
2467 35213c7c 2020-07-23 stsp return 1
2468 35213c7c 2020-07-23 stsp fi
2469 35213c7c 2020-07-23 stsp
2470 35213c7c 2020-07-23 stsp (cd $testroot/wt && got stage -S > $testroot/stdout)
2471 c631b115 2020-07-23 stsp
2472 c631b115 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2473 c631b115 2020-07-23 stsp M alpha.link
2474 c631b115 2020-07-23 stsp A dotgotbar.link
2475 c631b115 2020-07-23 stsp A dotgotfoo.link
2476 c631b115 2020-07-23 stsp M epsilon/beta.link
2477 c631b115 2020-07-23 stsp M epsilon.link
2478 c631b115 2020-07-23 stsp D nonexistent.link
2479 c631b115 2020-07-23 stsp A zeta.link
2480 c631b115 2020-07-23 stsp EOF
2481 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2482 fc414659 2022-04-16 thomas ret=$?
2483 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2484 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2485 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2486 c631b115 2020-07-23 stsp return 1
2487 c631b115 2020-07-23 stsp fi
2488 0aeb8099 2020-07-23 stsp
2489 0aeb8099 2020-07-23 stsp rm $testroot/wt/alpha.link
2490 0aeb8099 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/wt/alpha.link
2491 c631b115 2020-07-23 stsp
2492 c631b115 2020-07-23 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2493 c631b115 2020-07-23 stsp
2494 9b4458b4 2022-06-26 thomas echo "diff -s $testroot/wt" > $testroot/stdout.expected
2495 9b4458b4 2022-06-26 thomas echo "commit - $head_commit" >> $testroot/stdout.expected
2496 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
2497 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2498 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
2499 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2500 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2501 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l alpha.link) | cut -d' ' -f 1 \
2502 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2503 c631b115 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
2504 c631b115 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
2505 c631b115 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2506 c631b115 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
2507 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2508 c631b115 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
2509 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2510 c631b115 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2511 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2512 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l dotgotbar.link) | cut -d' ' -f 1 \
2513 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2514 c631b115 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2515 c631b115 2020-07-23 stsp echo '+++ dotgotbar.link' >> $testroot/stdout.expected
2516 c631b115 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2517 c631b115 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
2518 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2519 c631b115 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2520 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2521 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
2522 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2523 c631b115 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2524 c631b115 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2525 c631b115 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2526 c631b115 2020-07-23 stsp echo '+this is regular file foo' >> $testroot/stdout.expected
2527 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2528 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i epsilon | grep 'beta.link@ -> ../beta$' | \
2529 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2530 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2531 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l epsilon/beta.link) | cut -d' ' -f 1 \
2532 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2533 c631b115 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
2534 c631b115 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
2535 c631b115 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2536 c631b115 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
2537 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2538 c631b115 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
2539 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2540 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2541 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
2542 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2543 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2544 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l epsilon.link) | cut -d' ' -f 1 \
2545 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2546 c631b115 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
2547 c631b115 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
2548 c631b115 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2549 c631b115 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
2550 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2551 c631b115 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
2552 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2553 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2554 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
2555 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2556 c631b115 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2557 c631b115 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
2558 c631b115 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
2559 c631b115 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2560 c631b115 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
2561 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2562 c631b115 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2563 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2564 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
2565 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2566 c631b115 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2567 c631b115 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
2568 c631b115 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2569 c631b115 2020-07-23 stsp echo '+gamma/delta' >> $testroot/stdout.expected
2570 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2571 c631b115 2020-07-23 stsp
2572 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2573 fc414659 2022-04-16 thomas ret=$?
2574 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2575 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2576 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2577 c631b115 2020-07-23 stsp return 1
2578 c631b115 2020-07-23 stsp fi
2579 c631b115 2020-07-23 stsp
2580 c631b115 2020-07-23 stsp (cd $testroot/wt && got commit -m "staged symlink" \
2581 c631b115 2020-07-23 stsp > $testroot/stdout)
2582 fc414659 2022-04-16 thomas ret=$?
2583 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2584 c631b115 2020-07-23 stsp echo "got commit command failed unexpectedly" >&2
2585 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2586 c631b115 2020-07-23 stsp return 1
2587 c631b115 2020-07-23 stsp fi
2588 eba70f38 2019-08-08 stsp
2589 c631b115 2020-07-23 stsp local commit_id=`git_show_head $testroot/repo`
2590 c631b115 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
2591 c631b115 2020-07-23 stsp echo "A dotgotfoo.link" >> $testroot/stdout.expected
2592 c631b115 2020-07-23 stsp echo "A zeta.link" >> $testroot/stdout.expected
2593 c631b115 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
2594 c631b115 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
2595 c631b115 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
2596 c631b115 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
2597 c631b115 2020-07-23 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
2598 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2599 fc414659 2022-04-16 thomas ret=$?
2600 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2601 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2602 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2603 c631b115 2020-07-23 stsp return 1
2604 c631b115 2020-07-23 stsp fi
2605 c631b115 2020-07-23 stsp
2606 c631b115 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id > $testroot/stdout
2607 fc414659 2022-04-16 thomas ret=$?
2608 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2609 c631b115 2020-07-23 stsp echo "got tree command failed unexpectedly" >&2
2610 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2611 c631b115 2020-07-23 stsp return 1
2612 c631b115 2020-07-23 stsp fi
2613 c631b115 2020-07-23 stsp
2614 c631b115 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2615 c631b115 2020-07-23 stsp alpha
2616 c631b115 2020-07-23 stsp alpha.link@ -> beta
2617 c631b115 2020-07-23 stsp beta
2618 c631b115 2020-07-23 stsp dotgotbar.link@ -> .got/bar
2619 c631b115 2020-07-23 stsp dotgotfoo.link
2620 c631b115 2020-07-23 stsp epsilon/
2621 c631b115 2020-07-23 stsp epsilon.link@ -> gamma
2622 c631b115 2020-07-23 stsp gamma/
2623 c631b115 2020-07-23 stsp passwd.link@ -> /etc/passwd
2624 c631b115 2020-07-23 stsp zeta.link@ -> gamma/delta
2625 c631b115 2020-07-23 stsp EOF
2626 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2627 fc414659 2022-04-16 thomas ret=$?
2628 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2629 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2630 c631b115 2020-07-23 stsp return 1
2631 c631b115 2020-07-23 stsp fi
2632 c631b115 2020-07-23 stsp
2633 0aeb8099 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
2634 0aeb8099 2020-07-23 stsp echo "alpha.link is a symlink"
2635 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2636 c631b115 2020-07-23 stsp return 1
2637 c631b115 2020-07-23 stsp fi
2638 c631b115 2020-07-23 stsp
2639 0aeb8099 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/content.expected
2640 0aeb8099 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
2641 0aeb8099 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2642 fc414659 2022-04-16 thomas ret=$?
2643 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2644 0aeb8099 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2645 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2646 c631b115 2020-07-23 stsp return 1
2647 c631b115 2020-07-23 stsp fi
2648 c631b115 2020-07-23 stsp
2649 75f0a0fb 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
2650 75f0a0fb 2020-07-23 stsp echo "dotgotbar.link is not a symlink"
2651 75f0a0fb 2020-07-23 stsp test_done "$testroot" "1"
2652 75f0a0fb 2020-07-23 stsp return 1
2653 75f0a0fb 2020-07-23 stsp fi
2654 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
2655 c631b115 2020-07-23 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
2656 c631b115 2020-07-23 stsp echo "dotgotbar.link is a symlink"
2657 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2658 c631b115 2020-07-23 stsp return 1
2659 c631b115 2020-07-23 stsp fi
2660 0aeb8099 2020-07-23 stsp echo -n ".got/bar" > $testroot/content.expected
2661 c631b115 2020-07-23 stsp cp $testroot/wt/dotgotbar.link $testroot/content
2662 fa3cef63 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2663 fc414659 2022-04-16 thomas ret=$?
2664 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2665 fa3cef63 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2666 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2667 fa3cef63 2020-07-23 stsp return 1
2668 fa3cef63 2020-07-23 stsp fi
2669 fa3cef63 2020-07-23 stsp
2670 fa3cef63 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
2671 fa3cef63 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
2672 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2673 fa3cef63 2020-07-23 stsp return 1
2674 fa3cef63 2020-07-23 stsp fi
2675 fa3cef63 2020-07-23 stsp echo "this is regular file foo" > $testroot/content.expected
2676 fa3cef63 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
2677 fa3cef63 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2678 fc414659 2022-04-16 thomas ret=$?
2679 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2680 fa3cef63 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2681 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2682 fa3cef63 2020-07-23 stsp return 1
2683 fa3cef63 2020-07-23 stsp fi
2684 fa3cef63 2020-07-23 stsp
2685 fa3cef63 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
2686 fa3cef63 2020-07-23 stsp echo "epsilon.link is not a symlink"
2687 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2688 fa3cef63 2020-07-23 stsp return 1
2689 fa3cef63 2020-07-23 stsp fi
2690 fa3cef63 2020-07-23 stsp
2691 fa3cef63 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
2692 fa3cef63 2020-07-23 stsp echo "gamma" > $testroot/stdout.expected
2693 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2694 fc414659 2022-04-16 thomas ret=$?
2695 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2696 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2697 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2698 fa3cef63 2020-07-23 stsp return 1
2699 fa3cef63 2020-07-23 stsp fi
2700 fa3cef63 2020-07-23 stsp
2701 fa3cef63 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2702 fa3cef63 2020-07-23 stsp echo "passwd.link is a symlink"
2703 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2704 fa3cef63 2020-07-23 stsp return 1
2705 fa3cef63 2020-07-23 stsp fi
2706 fa3cef63 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
2707 fa3cef63 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
2708 fa3cef63 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2709 fc414659 2022-04-16 thomas ret=$?
2710 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2711 fa3cef63 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2712 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2713 fa3cef63 2020-07-23 stsp return 1
2714 fa3cef63 2020-07-23 stsp fi
2715 fa3cef63 2020-07-23 stsp
2716 fa3cef63 2020-07-23 stsp if ! [ -h $testroot/wt/zeta.link ]; then
2717 fa3cef63 2020-07-23 stsp echo "zeta.link is not a symlink"
2718 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2719 fa3cef63 2020-07-23 stsp return 1
2720 fa3cef63 2020-07-23 stsp fi
2721 fa3cef63 2020-07-23 stsp
2722 fa3cef63 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
2723 fa3cef63 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
2724 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2725 fc414659 2022-04-16 thomas ret=$?
2726 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2727 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2728 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2729 fa3cef63 2020-07-23 stsp return 1
2730 fa3cef63 2020-07-23 stsp fi
2731 fa3cef63 2020-07-23 stsp
2732 fa3cef63 2020-07-23 stsp test_done "$testroot" "0"
2733 fa3cef63 2020-07-23 stsp }
2734 fa3cef63 2020-07-23 stsp
2735 f6cae3ed 2020-09-13 naddy test_stage_patch_symlink() {
2736 fa3cef63 2020-07-23 stsp local testroot=`test_init stage_patch_symlink`
2737 fa3cef63 2020-07-23 stsp
2738 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2739 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
2740 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2741 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2742 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2743 fa3cef63 2020-07-23 stsp (cd $testroot/repo && git add .)
2744 fa3cef63 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2745 fa3cef63 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
2746 fa3cef63 2020-07-23 stsp
2747 fa3cef63 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2748 fc414659 2022-04-16 thomas ret=$?
2749 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2750 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2751 fa3cef63 2020-07-23 stsp return 1
2752 fa3cef63 2020-07-23 stsp fi
2753 fa3cef63 2020-07-23 stsp
2754 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
2755 dd6165e4 2021-09-21 thomas.ad (cd $testroot/wt && ln -sfT gamma epsilon.link)
2756 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
2757 fa3cef63 2020-07-23 stsp echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
2758 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2759 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
2760 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2761 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
2762 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
2763 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
2764 fa3cef63 2020-07-23 stsp
2765 fa3cef63 2020-07-23 stsp printf "y\nn\ny\nn\ny\ny\ny" > $testroot/patchscript
2766 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2767 fa3cef63 2020-07-23 stsp > $testroot/stdout)
2768 fa3cef63 2020-07-23 stsp
2769 fa3cef63 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2770 fa3cef63 2020-07-23 stsp -----------------------------------------------
2771 fa3cef63 2020-07-23 stsp @@ -1 +1 @@
2772 fa3cef63 2020-07-23 stsp -alpha
2773 fa3cef63 2020-07-23 stsp \ No newline at end of file
2774 fa3cef63 2020-07-23 stsp +beta
2775 fa3cef63 2020-07-23 stsp \ No newline at end of file
2776 fa3cef63 2020-07-23 stsp -----------------------------------------------
2777 fa3cef63 2020-07-23 stsp M alpha.link (change 1 of 1)
2778 fa3cef63 2020-07-23 stsp stage this change? [y/n/q] y
2779 fa3cef63 2020-07-23 stsp A dotgotbar.link
2780 fa3cef63 2020-07-23 stsp stage this addition? [y/n] n
2781 fa3cef63 2020-07-23 stsp A dotgotfoo.link
2782 fa3cef63 2020-07-23 stsp stage this addition? [y/n] y
2783 fa3cef63 2020-07-23 stsp -----------------------------------------------
2784 fa3cef63 2020-07-23 stsp @@ -1 +1 @@
2785 fa3cef63 2020-07-23 stsp -../beta
2786 fa3cef63 2020-07-23 stsp \ No newline at end of file
2787 fa3cef63 2020-07-23 stsp +../gamma/delta
2788 fa3cef63 2020-07-23 stsp \ No newline at end of file
2789 fa3cef63 2020-07-23 stsp -----------------------------------------------
2790 fa3cef63 2020-07-23 stsp M epsilon/beta.link (change 1 of 1)
2791 fa3cef63 2020-07-23 stsp stage this change? [y/n/q] n
2792 fa3cef63 2020-07-23 stsp -----------------------------------------------
2793 fa3cef63 2020-07-23 stsp @@ -1 +1 @@
2794 fa3cef63 2020-07-23 stsp -epsilon
2795 fa3cef63 2020-07-23 stsp \ No newline at end of file
2796 fa3cef63 2020-07-23 stsp +gamma
2797 fa3cef63 2020-07-23 stsp \ No newline at end of file
2798 fa3cef63 2020-07-23 stsp -----------------------------------------------
2799 fa3cef63 2020-07-23 stsp M epsilon.link (change 1 of 1)
2800 fa3cef63 2020-07-23 stsp stage this change? [y/n/q] y
2801 fa3cef63 2020-07-23 stsp D nonexistent.link
2802 fa3cef63 2020-07-23 stsp stage this deletion? [y/n] y
2803 fa3cef63 2020-07-23 stsp A zeta.link
2804 fa3cef63 2020-07-23 stsp stage this addition? [y/n] y
2805 fa3cef63 2020-07-23 stsp EOF
2806 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2807 fc414659 2022-04-16 thomas ret=$?
2808 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2809 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2810 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2811 fa3cef63 2020-07-23 stsp return 1
2812 fa3cef63 2020-07-23 stsp fi
2813 fa3cef63 2020-07-23 stsp
2814 fa3cef63 2020-07-23 stsp rm $testroot/wt/alpha.link
2815 fa3cef63 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/wt/alpha.link
2816 fa3cef63 2020-07-23 stsp
2817 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2818 fa3cef63 2020-07-23 stsp
2819 9b4458b4 2022-06-26 thomas echo "diff -s $testroot/wt" > $testroot/stdout.expected
2820 9b4458b4 2022-06-26 thomas echo "commit - $head_commit" >> $testroot/stdout.expected
2821 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
2822 fa3cef63 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2823 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
2824 fa3cef63 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2825 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2826 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l alpha.link) | cut -d' ' -f 1 \
2827 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2828 fa3cef63 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
2829 fa3cef63 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
2830 fa3cef63 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2831 fa3cef63 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
2832 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2833 fa3cef63 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
2834 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2835 fa3cef63 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2836 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2837 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
2838 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2839 fa3cef63 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2840 fa3cef63 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2841 fa3cef63 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2842 fa3cef63 2020-07-23 stsp echo '+this is regular file foo' >> $testroot/stdout.expected
2843 fa3cef63 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2844 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
2845 fa3cef63 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2846 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2847 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l epsilon.link) | cut -d' ' -f 1 \
2848 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2849 fa3cef63 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
2850 fa3cef63 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
2851 fa3cef63 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2852 fa3cef63 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
2853 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2854 fa3cef63 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
2855 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2856 fa3cef63 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2857 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
2858 fa3cef63 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2859 fa3cef63 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2860 fa3cef63 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
2861 fa3cef63 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
2862 fa3cef63 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2863 fa3cef63 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
2864 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2865 fa3cef63 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2866 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2867 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
2868 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2869 fa3cef63 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2870 fa3cef63 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
2871 fa3cef63 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2872 fa3cef63 2020-07-23 stsp echo '+gamma/delta' >> $testroot/stdout.expected
2873 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2874 fa3cef63 2020-07-23 stsp
2875 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2876 fc414659 2022-04-16 thomas ret=$?
2877 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2878 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2879 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2880 fa3cef63 2020-07-23 stsp return 1
2881 fa3cef63 2020-07-23 stsp fi
2882 fa3cef63 2020-07-23 stsp
2883 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got commit -m "staged symlink" \
2884 fa3cef63 2020-07-23 stsp > $testroot/stdout)
2885 fc414659 2022-04-16 thomas ret=$?
2886 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2887 fa3cef63 2020-07-23 stsp echo "got commit command failed unexpectedly" >&2
2888 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2889 fa3cef63 2020-07-23 stsp return 1
2890 fa3cef63 2020-07-23 stsp fi
2891 fa3cef63 2020-07-23 stsp
2892 fa3cef63 2020-07-23 stsp local commit_id=`git_show_head $testroot/repo`
2893 fa3cef63 2020-07-23 stsp echo "A dotgotfoo.link" > $testroot/stdout.expected
2894 fa3cef63 2020-07-23 stsp echo "A zeta.link" >> $testroot/stdout.expected
2895 fa3cef63 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
2896 fa3cef63 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
2897 fa3cef63 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
2898 fa3cef63 2020-07-23 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
2899 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2900 fc414659 2022-04-16 thomas ret=$?
2901 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2902 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2903 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2904 fa3cef63 2020-07-23 stsp return 1
2905 fa3cef63 2020-07-23 stsp fi
2906 fa3cef63 2020-07-23 stsp
2907 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id > $testroot/stdout
2908 fc414659 2022-04-16 thomas ret=$?
2909 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2910 fa3cef63 2020-07-23 stsp echo "got tree command failed unexpectedly" >&2
2911 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2912 fa3cef63 2020-07-23 stsp return 1
2913 fa3cef63 2020-07-23 stsp fi
2914 fa3cef63 2020-07-23 stsp
2915 fa3cef63 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2916 fa3cef63 2020-07-23 stsp alpha
2917 fa3cef63 2020-07-23 stsp alpha.link@ -> beta
2918 fa3cef63 2020-07-23 stsp beta
2919 fa3cef63 2020-07-23 stsp dotgotfoo.link
2920 fa3cef63 2020-07-23 stsp epsilon/
2921 fa3cef63 2020-07-23 stsp epsilon.link@ -> gamma
2922 fa3cef63 2020-07-23 stsp gamma/
2923 fa3cef63 2020-07-23 stsp passwd.link@ -> /etc/passwd
2924 fa3cef63 2020-07-23 stsp zeta.link@ -> gamma/delta
2925 fa3cef63 2020-07-23 stsp EOF
2926 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2927 fc414659 2022-04-16 thomas ret=$?
2928 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2929 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2930 fa3cef63 2020-07-23 stsp return 1
2931 fa3cef63 2020-07-23 stsp fi
2932 fa3cef63 2020-07-23 stsp
2933 fa3cef63 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
2934 fa3cef63 2020-07-23 stsp echo "alpha.link is a symlink"
2935 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2936 fa3cef63 2020-07-23 stsp return 1
2937 fa3cef63 2020-07-23 stsp fi
2938 fa3cef63 2020-07-23 stsp
2939 fa3cef63 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/content.expected
2940 fa3cef63 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
2941 c631b115 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2942 fc414659 2022-04-16 thomas ret=$?
2943 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2944 c631b115 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2945 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2946 c631b115 2020-07-23 stsp return 1
2947 c631b115 2020-07-23 stsp fi
2948 c631b115 2020-07-23 stsp
2949 fa3cef63 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
2950 fa3cef63 2020-07-23 stsp echo "dotgotbar.link is not a symlink"
2951 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2952 fa3cef63 2020-07-23 stsp return 1
2953 fa3cef63 2020-07-23 stsp fi
2954 fa3cef63 2020-07-23 stsp readlink $testroot/wt/dotgotbar.link > $testroot/stdout
2955 fa3cef63 2020-07-23 stsp echo ".got/bar" > $testroot/stdout.expected
2956 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2957 fc414659 2022-04-16 thomas ret=$?
2958 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2959 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2960 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2961 fa3cef63 2020-07-23 stsp return 1
2962 fa3cef63 2020-07-23 stsp fi
2963 fa3cef63 2020-07-23 stsp
2964 c631b115 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
2965 c631b115 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
2966 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2967 c631b115 2020-07-23 stsp return 1
2968 c631b115 2020-07-23 stsp fi
2969 c631b115 2020-07-23 stsp echo "this is regular file foo" > $testroot/content.expected
2970 c631b115 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
2971 c631b115 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2972 fc414659 2022-04-16 thomas ret=$?
2973 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2974 c631b115 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2975 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2976 c631b115 2020-07-23 stsp return 1
2977 c631b115 2020-07-23 stsp fi
2978 c631b115 2020-07-23 stsp
2979 c631b115 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
2980 c631b115 2020-07-23 stsp echo "epsilon.link is not a symlink"
2981 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2982 c631b115 2020-07-23 stsp return 1
2983 c631b115 2020-07-23 stsp fi
2984 c631b115 2020-07-23 stsp
2985 c631b115 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
2986 c631b115 2020-07-23 stsp echo "gamma" > $testroot/stdout.expected
2987 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2988 fc414659 2022-04-16 thomas ret=$?
2989 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2990 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2991 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2992 c631b115 2020-07-23 stsp return 1
2993 c631b115 2020-07-23 stsp fi
2994 c631b115 2020-07-23 stsp
2995 c631b115 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2996 c631b115 2020-07-23 stsp echo "passwd.link is a symlink"
2997 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2998 c631b115 2020-07-23 stsp return 1
2999 c631b115 2020-07-23 stsp fi
3000 c631b115 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
3001 c631b115 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
3002 c631b115 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
3003 fc414659 2022-04-16 thomas ret=$?
3004 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3005 c631b115 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
3006 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
3007 c631b115 2020-07-23 stsp return 1
3008 c631b115 2020-07-23 stsp fi
3009 c631b115 2020-07-23 stsp
3010 c631b115 2020-07-23 stsp if ! [ -h $testroot/wt/zeta.link ]; then
3011 c631b115 2020-07-23 stsp echo "zeta.link is not a symlink"
3012 c631b115 2020-07-23 stsp test_done "$testroot" "1"
3013 c631b115 2020-07-23 stsp return 1
3014 c631b115 2020-07-23 stsp fi
3015 c631b115 2020-07-23 stsp
3016 c631b115 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
3017 c631b115 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
3018 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
3019 fc414659 2022-04-16 thomas ret=$?
3020 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3021 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
3022 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
3023 c631b115 2020-07-23 stsp return 1
3024 c631b115 2020-07-23 stsp fi
3025 c631b115 2020-07-23 stsp
3026 c631b115 2020-07-23 stsp test_done "$testroot" "0"
3027 eba70f38 2019-08-08 stsp }
3028 eba70f38 2019-08-08 stsp
3029 7fb414ae 2020-08-08 stsp test_parseargs "$@"
3030 fccbfb98 2019-08-03 stsp run_test test_stage_basic
3031 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
3032 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
3033 8564cb21 2019-08-08 stsp run_test test_stage_nonexistent
3034 a4f692bb 2019-08-04 stsp run_test test_stage_list
3035 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
3036 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
3037 d3e7c587 2019-08-03 stsp run_test test_double_stage
3038 c363b2c1 2019-08-03 stsp run_test test_stage_status
3039 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
3040 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
3041 24278f30 2019-08-03 stsp run_test test_stage_revert
3042 408b4ebc 2019-08-03 stsp run_test test_stage_diff
3043 b9622844 2019-08-03 stsp run_test test_stage_histedit
3044 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
3045 a76c42e6 2019-08-03 stsp run_test test_stage_update
3046 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
3047 0f1cfa7f 2019-08-08 stsp run_test test_stage_commit_out_of_date
3048 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
3049 dc424a06 2019-08-07 stsp run_test test_stage_patch
3050 af5a81b2 2019-08-08 stsp run_test test_stage_patch_twice
3051 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
3052 e70a841e 2019-08-08 stsp run_test test_stage_patch_added_twice
3053 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
3054 e70a841e 2019-08-08 stsp run_test test_stage_patch_removed_twice
3055 f289c82c 2022-06-13 thomas run_test test_stage_patch_reversed
3056 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
3057 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script
3058 c631b115 2020-07-23 stsp run_test test_stage_symlink
3059 fa3cef63 2020-07-23 stsp run_test test_stage_patch_symlink