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