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 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
937 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
938 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
939 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
940 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
941 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
942 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
943 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
944 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
945 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
946 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
947 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
948 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
949 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
950 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
951 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
952 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
953 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
954 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
955 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
956 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
957 98eaaa12 2019-08-03 stsp
958 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
959 49c543a6 2022-03-31 naddy ret=$?
960 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
961 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
962 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
963 98eaaa12 2019-08-03 stsp return 1
964 98eaaa12 2019-08-03 stsp fi
965 98eaaa12 2019-08-03 stsp
966 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
967 98eaaa12 2019-08-03 stsp
968 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
969 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
970 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
971 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
972 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
973 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
974 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
975 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
976 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
977 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
978 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
979 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
980 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
981 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
982 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
983 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
984 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
985 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
986 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
987 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
988 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
989 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
990 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
991 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
992 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
993 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
994 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
995 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
996 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
997 408b4ebc 2019-08-03 stsp
998 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
999 49c543a6 2022-03-31 naddy ret=$?
1000 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1001 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1002 24278f30 2019-08-03 stsp fi
1003 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
1004 408b4ebc 2019-08-03 stsp
1005 24278f30 2019-08-03 stsp }
1006 b9622844 2019-08-03 stsp
1007 f6cae3ed 2020-09-13 naddy test_stage_histedit() {
1008 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
1009 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
1010 b9622844 2019-08-03 stsp
1011 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1012 49c543a6 2022-03-31 naddy ret=$?
1013 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1014 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1015 b9622844 2019-08-03 stsp return 1
1016 b9622844 2019-08-03 stsp fi
1017 b9622844 2019-08-03 stsp
1018 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1019 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1020 b9622844 2019-08-03 stsp
1021 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
1022 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1023 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
1024 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1025 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
1026 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
1027 24278f30 2019-08-03 stsp
1028 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1029 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1030 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
1031 b9622844 2019-08-03 stsp
1032 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
1033 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1034 b9622844 2019-08-03 stsp
1035 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1036 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1037 49c543a6 2022-03-31 naddy ret=$?
1038 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1039 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
1040 b9622844 2019-08-03 stsp test_done "$testroot" "1"
1041 b9622844 2019-08-03 stsp return 1
1042 b9622844 2019-08-03 stsp fi
1043 b9622844 2019-08-03 stsp
1044 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
1045 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1046 b9622844 2019-08-03 stsp
1047 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1048 49c543a6 2022-03-31 naddy ret=$?
1049 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1050 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1051 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1052 b9622844 2019-08-03 stsp return 1
1053 b9622844 2019-08-03 stsp fi
1054 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1055 49c543a6 2022-03-31 naddy ret=$?
1056 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1057 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1058 b9622844 2019-08-03 stsp fi
1059 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1060 243d7cf1 2019-08-03 stsp
1061 243d7cf1 2019-08-03 stsp }
1062 243d7cf1 2019-08-03 stsp
1063 f6cae3ed 2020-09-13 naddy test_stage_rebase() {
1064 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
1065 243d7cf1 2019-08-03 stsp
1066 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1067 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1068 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1069 243d7cf1 2019-08-03 stsp
1070 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1071 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1072 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1073 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1074 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1075 243d7cf1 2019-08-03 stsp
1076 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1077 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
1078 243d7cf1 2019-08-03 stsp
1079 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
1080 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1081 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1082 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
1083 243d7cf1 2019-08-03 stsp
1084 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1085 49c543a6 2022-03-31 naddy ret=$?
1086 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1087 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1088 243d7cf1 2019-08-03 stsp return 1
1089 243d7cf1 2019-08-03 stsp fi
1090 243d7cf1 2019-08-03 stsp
1091 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1092 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1093 b9622844 2019-08-03 stsp
1094 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
1095 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1096 49c543a6 2022-03-31 naddy ret=$?
1097 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1098 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
1099 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
1100 243d7cf1 2019-08-03 stsp return 1
1101 243d7cf1 2019-08-03 stsp fi
1102 243d7cf1 2019-08-03 stsp
1103 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
1104 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1105 243d7cf1 2019-08-03 stsp
1106 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1107 49c543a6 2022-03-31 naddy ret=$?
1108 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1109 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1110 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1111 243d7cf1 2019-08-03 stsp return 1
1112 243d7cf1 2019-08-03 stsp fi
1113 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1114 49c543a6 2022-03-31 naddy ret=$?
1115 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1116 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1117 243d7cf1 2019-08-03 stsp fi
1118 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1119 b9622844 2019-08-03 stsp }
1120 b9622844 2019-08-03 stsp
1121 f6cae3ed 2020-09-13 naddy test_stage_update() {
1122 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1123 a76c42e6 2019-08-03 stsp
1124 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1125 49c543a6 2022-03-31 naddy ret=$?
1126 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1127 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1128 a76c42e6 2019-08-03 stsp return 1
1129 a76c42e6 2019-08-03 stsp fi
1130 243d7cf1 2019-08-03 stsp
1131 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1132 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1133 a76c42e6 2019-08-03 stsp
1134 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1135 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1136 a76c42e6 2019-08-03 stsp
1137 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1138 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1139 49c543a6 2022-03-31 naddy ret=$?
1140 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1141 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1142 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1143 a76c42e6 2019-08-03 stsp return 1
1144 a76c42e6 2019-08-03 stsp fi
1145 a76c42e6 2019-08-03 stsp
1146 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1147 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1148 a76c42e6 2019-08-03 stsp
1149 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1150 49c543a6 2022-03-31 naddy ret=$?
1151 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1152 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1153 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1154 a76c42e6 2019-08-03 stsp return 1
1155 a76c42e6 2019-08-03 stsp fi
1156 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1157 49c543a6 2022-03-31 naddy ret=$?
1158 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1159 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1160 a76c42e6 2019-08-03 stsp fi
1161 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1162 a76c42e6 2019-08-03 stsp }
1163 f0b75401 2019-08-03 stsp
1164 f6cae3ed 2020-09-13 naddy test_stage_commit_non_staged() {
1165 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1166 f0b75401 2019-08-03 stsp
1167 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1168 49c543a6 2022-03-31 naddy ret=$?
1169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1170 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1171 f0b75401 2019-08-03 stsp return 1
1172 f0b75401 2019-08-03 stsp fi
1173 f0b75401 2019-08-03 stsp
1174 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1175 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1176 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1177 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1178 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1179 a76c42e6 2019-08-03 stsp
1180 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1181 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1182 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1183 49c543a6 2022-03-31 naddy ret=$?
1184 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1185 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1186 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1187 f0b75401 2019-08-03 stsp return 1
1188 f0b75401 2019-08-03 stsp fi
1189 f0b75401 2019-08-03 stsp
1190 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1191 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1192 f0b75401 2019-08-03 stsp
1193 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1194 49c543a6 2022-03-31 naddy ret=$?
1195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1196 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1197 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1198 5f8a88c6 2019-08-03 stsp return 1
1199 5f8a88c6 2019-08-03 stsp fi
1200 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1201 49c543a6 2022-03-31 naddy ret=$?
1202 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1203 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1204 5f8a88c6 2019-08-03 stsp fi
1205 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1206 5f8a88c6 2019-08-03 stsp }
1207 0f1cfa7f 2019-08-08 stsp
1208 f6cae3ed 2020-09-13 naddy test_stage_commit_out_of_date() {
1209 0f1cfa7f 2019-08-08 stsp local testroot=`test_init stage_commit_out_of_date`
1210 0f1cfa7f 2019-08-08 stsp
1211 0f1cfa7f 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1212 49c543a6 2022-03-31 naddy ret=$?
1213 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1214 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1215 0f1cfa7f 2019-08-08 stsp return 1
1216 0f1cfa7f 2019-08-08 stsp fi
1217 0f1cfa7f 2019-08-08 stsp
1218 0f1cfa7f 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
1219 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
1220 0f1cfa7f 2019-08-08 stsp echo "new file" > $testroot/wt/foo
1221 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
1222 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1223 0f1cfa7f 2019-08-08 stsp
1224 0f1cfa7f 2019-08-08 stsp echo "changed file" > $testroot/repo/alpha
1225 0f1cfa7f 2019-08-08 stsp git_commit $testroot/repo -m "changed alpha in repo"
1226 0f1cfa7f 2019-08-08 stsp
1227 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1228 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1229 49c543a6 2022-03-31 naddy ret=$?
1230 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1231 0f1cfa7f 2019-08-08 stsp echo "got commit command succeeded unexpectedly" >&2
1232 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "1"
1233 0f1cfa7f 2019-08-08 stsp return 1
1234 0f1cfa7f 2019-08-08 stsp fi
1235 0f1cfa7f 2019-08-08 stsp
1236 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1237 0f1cfa7f 2019-08-08 stsp echo -n "got: work tree must be updated before these changes " \
1238 0f1cfa7f 2019-08-08 stsp > $testroot/stderr.expected
1239 0f1cfa7f 2019-08-08 stsp echo "can be committed" >> $testroot/stderr.expected
1240 5f8a88c6 2019-08-03 stsp
1241 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1242 49c543a6 2022-03-31 naddy ret=$?
1243 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1244 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1245 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1246 0f1cfa7f 2019-08-08 stsp return 1
1247 0f1cfa7f 2019-08-08 stsp fi
1248 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1249 49c543a6 2022-03-31 naddy ret=$?
1250 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1251 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1252 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1253 0f1cfa7f 2019-08-08 stsp return 1
1254 0f1cfa7f 2019-08-08 stsp fi
1255 0f1cfa7f 2019-08-08 stsp
1256 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout \
1257 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1258 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1259 0f1cfa7f 2019-08-08 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1260 0f1cfa7f 2019-08-08 stsp
1261 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1262 49c543a6 2022-03-31 naddy ret=$?
1263 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1264 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1265 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1266 0f1cfa7f 2019-08-08 stsp return 1
1267 0f1cfa7f 2019-08-08 stsp fi
1268 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1269 49c543a6 2022-03-31 naddy ret=$?
1270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1271 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1272 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1273 0f1cfa7f 2019-08-08 stsp return 1
1274 0f1cfa7f 2019-08-08 stsp fi
1275 0f1cfa7f 2019-08-08 stsp
1276 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got unstage > /dev/null)
1277 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
1278 49c543a6 2022-03-31 naddy ret=$?
1279 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1280 0f1cfa7f 2019-08-08 stsp echo "got update command failed unexpectedly" >&2
1281 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1282 0f1cfa7f 2019-08-08 stsp return 1
1283 0f1cfa7f 2019-08-08 stsp fi
1284 0f1cfa7f 2019-08-08 stsp
1285 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1286 0f1cfa7f 2019-08-08 stsp echo "C alpha" > $testroot/stdout.expected
1287 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1288 0f1cfa7f 2019-08-08 stsp echo "A foo" >> $testroot/stdout.expected
1289 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1290 49c543a6 2022-03-31 naddy ret=$?
1291 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1292 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1293 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1294 0f1cfa7f 2019-08-08 stsp return 1
1295 0f1cfa7f 2019-08-08 stsp fi
1296 0f1cfa7f 2019-08-08 stsp
1297 0f1cfa7f 2019-08-08 stsp # resolve conflict
1298 0f1cfa7f 2019-08-08 stsp echo "resolved file" > $testroot/wt/alpha
1299 0f1cfa7f 2019-08-08 stsp
1300 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
1301 0f1cfa7f 2019-08-08 stsp
1302 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1303 49c543a6 2022-03-31 naddy ret=$?
1304 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1305 0f1cfa7f 2019-08-08 stsp echo "got commit command failed unexpectedly" >&2
1306 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1307 0f1cfa7f 2019-08-08 stsp return 1
1308 0f1cfa7f 2019-08-08 stsp fi
1309 0f1cfa7f 2019-08-08 stsp
1310 0f1cfa7f 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1311 0f1cfa7f 2019-08-08 stsp echo "A foo" > $testroot/stdout.expected
1312 0f1cfa7f 2019-08-08 stsp echo "M alpha" >> $testroot/stdout.expected
1313 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1314 0f1cfa7f 2019-08-08 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1315 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1316 49c543a6 2022-03-31 naddy ret=$?
1317 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1318 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1319 0f1cfa7f 2019-08-08 stsp fi
1320 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1321 0f1cfa7f 2019-08-08 stsp
1322 0f1cfa7f 2019-08-08 stsp }
1323 0f1cfa7f 2019-08-08 stsp
1324 f6cae3ed 2020-09-13 naddy test_stage_commit() {
1325 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1326 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1327 5f8a88c6 2019-08-03 stsp
1328 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1329 49c543a6 2022-03-31 naddy ret=$?
1330 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1331 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1332 5f8a88c6 2019-08-03 stsp return 1
1333 5f8a88c6 2019-08-03 stsp fi
1334 5f8a88c6 2019-08-03 stsp
1335 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1336 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1337 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1338 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1339 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1340 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1341 5f8a88c6 2019-08-03 stsp
1342 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1343 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1344 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1345 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1346 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1347 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1348 5f8a88c6 2019-08-03 stsp
1349 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1350 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1351 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1352 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1353 5f8a88c6 2019-08-03 stsp
1354 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1355 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1356 49c543a6 2022-03-31 naddy ret=$?
1357 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1358 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1359 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1360 5f8a88c6 2019-08-03 stsp return 1
1361 5f8a88c6 2019-08-03 stsp fi
1362 5f8a88c6 2019-08-03 stsp
1363 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1364 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1365 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1366 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1367 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1368 5f8a88c6 2019-08-03 stsp
1369 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1370 49c543a6 2022-03-31 naddy ret=$?
1371 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1372 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1373 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1374 f0b75401 2019-08-03 stsp return 1
1375 f0b75401 2019-08-03 stsp fi
1376 5f8a88c6 2019-08-03 stsp
1377 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1378 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1379 5f8a88c6 2019-08-03 stsp
1380 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1381 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1382 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1383 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1384 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1385 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1386 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1387 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1388 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1389 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1390 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1391 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1392 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1393 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1394 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1395 46f68b20 2019-10-19 stsp | grep 'beta$' | cut -d' ' -f 1 | tr -d '\n' \
1396 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1397 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
1398 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1399 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1400 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1401 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1402 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1403 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1404 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1405 46f68b20 2019-10-19 stsp cat $testroot/blob_id_foo | tr -d '\n' >> $testroot/stdout.expected
1406 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
1407 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1408 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1409 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1410 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1411 5f8a88c6 2019-08-03 stsp
1412 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1413 49c543a6 2022-03-31 naddy ret=$?
1414 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1415 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1416 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1417 5f8a88c6 2019-08-03 stsp return 1
1418 f0b75401 2019-08-03 stsp fi
1419 5f8a88c6 2019-08-03 stsp
1420 72fd46fa 2019-09-06 stsp echo 'M alpha' > $testroot/stdout.expected
1421 72fd46fa 2019-09-06 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
1422 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1423 72fd46fa 2019-09-06 stsp echo 'M foo' >> $testroot/stdout.expected
1424 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1425 5f8a88c6 2019-08-03 stsp
1426 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1427 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1428 49c543a6 2022-03-31 naddy ret=$?
1429 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1430 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1431 5f8a88c6 2019-08-03 stsp fi
1432 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1433 f0b75401 2019-08-03 stsp }
1434 dc424a06 2019-08-07 stsp
1435 f6cae3ed 2020-09-13 naddy test_stage_patch() {
1436 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1437 dc424a06 2019-08-07 stsp
1438 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1439 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1440 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1441 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1442 dc424a06 2019-08-07 stsp
1443 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1444 49c543a6 2022-03-31 naddy ret=$?
1445 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1446 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1447 dc424a06 2019-08-07 stsp return 1
1448 dc424a06 2019-08-07 stsp fi
1449 dc424a06 2019-08-07 stsp
1450 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1451 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1452 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1453 dc424a06 2019-08-07 stsp
1454 dc424a06 2019-08-07 stsp # don't stage any hunks
1455 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1456 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1457 7b5dc508 2019-10-28 stsp numbers > $testroot/stdout 2> $testroot/stderr)
1458 49c543a6 2022-03-31 naddy ret=$?
1459 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1460 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
1461 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1462 dc424a06 2019-08-07 stsp return 1
1463 dc424a06 2019-08-07 stsp fi
1464 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1465 dc424a06 2019-08-07 stsp -----------------------------------------------
1466 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1467 dc424a06 2019-08-07 stsp 1
1468 dc424a06 2019-08-07 stsp -2
1469 dc424a06 2019-08-07 stsp +a
1470 dc424a06 2019-08-07 stsp 3
1471 dc424a06 2019-08-07 stsp 4
1472 dc424a06 2019-08-07 stsp 5
1473 dc424a06 2019-08-07 stsp -----------------------------------------------
1474 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1475 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1476 dc424a06 2019-08-07 stsp -----------------------------------------------
1477 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1478 dc424a06 2019-08-07 stsp 4
1479 dc424a06 2019-08-07 stsp 5
1480 dc424a06 2019-08-07 stsp 6
1481 dc424a06 2019-08-07 stsp -7
1482 dc424a06 2019-08-07 stsp +b
1483 dc424a06 2019-08-07 stsp 8
1484 dc424a06 2019-08-07 stsp 9
1485 dc424a06 2019-08-07 stsp 10
1486 dc424a06 2019-08-07 stsp -----------------------------------------------
1487 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1488 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1489 dc424a06 2019-08-07 stsp -----------------------------------------------
1490 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1491 dc424a06 2019-08-07 stsp 13
1492 dc424a06 2019-08-07 stsp 14
1493 dc424a06 2019-08-07 stsp 15
1494 dc424a06 2019-08-07 stsp -16
1495 dc424a06 2019-08-07 stsp +c
1496 dc424a06 2019-08-07 stsp -----------------------------------------------
1497 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1498 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1499 dc424a06 2019-08-07 stsp EOF
1500 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1501 49c543a6 2022-03-31 naddy ret=$?
1502 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1503 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1504 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1505 dc424a06 2019-08-07 stsp return 1
1506 dc424a06 2019-08-07 stsp fi
1507 f0b75401 2019-08-03 stsp
1508 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
1509 7b5dc508 2019-10-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1510 49c543a6 2022-03-31 naddy ret=$?
1511 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1512 7b5dc508 2019-10-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
1513 7b5dc508 2019-10-28 stsp test_done "$testroot" "$ret"
1514 7b5dc508 2019-10-28 stsp return 1
1515 7b5dc508 2019-10-28 stsp fi
1516 7b5dc508 2019-10-28 stsp
1517 7b5dc508 2019-10-28 stsp
1518 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1519 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1520 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1521 49c543a6 2022-03-31 naddy ret=$?
1522 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1523 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1524 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1525 dc424a06 2019-08-07 stsp return 1
1526 dc424a06 2019-08-07 stsp fi
1527 dc424a06 2019-08-07 stsp
1528 dc424a06 2019-08-07 stsp # stage middle hunk
1529 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1530 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1531 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1532 dc424a06 2019-08-07 stsp
1533 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1534 dc424a06 2019-08-07 stsp -----------------------------------------------
1535 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1536 dc424a06 2019-08-07 stsp 1
1537 dc424a06 2019-08-07 stsp -2
1538 dc424a06 2019-08-07 stsp +a
1539 dc424a06 2019-08-07 stsp 3
1540 dc424a06 2019-08-07 stsp 4
1541 dc424a06 2019-08-07 stsp 5
1542 dc424a06 2019-08-07 stsp -----------------------------------------------
1543 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1544 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1545 dc424a06 2019-08-07 stsp -----------------------------------------------
1546 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1547 dc424a06 2019-08-07 stsp 4
1548 dc424a06 2019-08-07 stsp 5
1549 dc424a06 2019-08-07 stsp 6
1550 dc424a06 2019-08-07 stsp -7
1551 dc424a06 2019-08-07 stsp +b
1552 dc424a06 2019-08-07 stsp 8
1553 dc424a06 2019-08-07 stsp 9
1554 dc424a06 2019-08-07 stsp 10
1555 dc424a06 2019-08-07 stsp -----------------------------------------------
1556 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1557 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1558 dc424a06 2019-08-07 stsp -----------------------------------------------
1559 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1560 dc424a06 2019-08-07 stsp 13
1561 dc424a06 2019-08-07 stsp 14
1562 dc424a06 2019-08-07 stsp 15
1563 dc424a06 2019-08-07 stsp -16
1564 dc424a06 2019-08-07 stsp +c
1565 dc424a06 2019-08-07 stsp -----------------------------------------------
1566 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1567 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1568 dc424a06 2019-08-07 stsp EOF
1569 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1570 49c543a6 2022-03-31 naddy ret=$?
1571 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1572 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1573 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1574 dc424a06 2019-08-07 stsp return 1
1575 dc424a06 2019-08-07 stsp fi
1576 dc424a06 2019-08-07 stsp
1577 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1578 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1579 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1580 49c543a6 2022-03-31 naddy ret=$?
1581 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1582 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1583 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1584 dc424a06 2019-08-07 stsp return 1
1585 dc424a06 2019-08-07 stsp fi
1586 dc424a06 2019-08-07 stsp
1587 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1588 dc424a06 2019-08-07 stsp
1589 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1590 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1591 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1592 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1593 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1594 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1595 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1596 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1597 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1598 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1599 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1600 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1601 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1602 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1603 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1604 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1605 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1606 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1607 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1608 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1609 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1610 49c543a6 2022-03-31 naddy ret=$?
1611 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1612 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1613 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1614 dc424a06 2019-08-07 stsp return 1
1615 dc424a06 2019-08-07 stsp fi
1616 dc424a06 2019-08-07 stsp
1617 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1618 49c543a6 2022-03-31 naddy ret=$?
1619 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1620 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1621 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1622 dc424a06 2019-08-07 stsp return 1
1623 dc424a06 2019-08-07 stsp fi
1624 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1625 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1626 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1627 49c543a6 2022-03-31 naddy ret=$?
1628 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1629 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1630 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1631 dc424a06 2019-08-07 stsp return 1
1632 dc424a06 2019-08-07 stsp fi
1633 dc424a06 2019-08-07 stsp
1634 dc424a06 2019-08-07 stsp # stage last hunk
1635 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1636 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1637 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1638 dc424a06 2019-08-07 stsp
1639 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1640 dc424a06 2019-08-07 stsp -----------------------------------------------
1641 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1642 dc424a06 2019-08-07 stsp 1
1643 dc424a06 2019-08-07 stsp -2
1644 dc424a06 2019-08-07 stsp +a
1645 dc424a06 2019-08-07 stsp 3
1646 dc424a06 2019-08-07 stsp 4
1647 dc424a06 2019-08-07 stsp 5
1648 dc424a06 2019-08-07 stsp -----------------------------------------------
1649 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1650 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1651 dc424a06 2019-08-07 stsp -----------------------------------------------
1652 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1653 dc424a06 2019-08-07 stsp 4
1654 dc424a06 2019-08-07 stsp 5
1655 dc424a06 2019-08-07 stsp 6
1656 dc424a06 2019-08-07 stsp -7
1657 dc424a06 2019-08-07 stsp +b
1658 dc424a06 2019-08-07 stsp 8
1659 dc424a06 2019-08-07 stsp 9
1660 dc424a06 2019-08-07 stsp 10
1661 dc424a06 2019-08-07 stsp -----------------------------------------------
1662 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1663 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1664 dc424a06 2019-08-07 stsp -----------------------------------------------
1665 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1666 dc424a06 2019-08-07 stsp 13
1667 dc424a06 2019-08-07 stsp 14
1668 dc424a06 2019-08-07 stsp 15
1669 dc424a06 2019-08-07 stsp -16
1670 dc424a06 2019-08-07 stsp +c
1671 dc424a06 2019-08-07 stsp -----------------------------------------------
1672 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1673 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1674 dc424a06 2019-08-07 stsp EOF
1675 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1676 49c543a6 2022-03-31 naddy ret=$?
1677 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1678 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1679 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1680 dc424a06 2019-08-07 stsp return 1
1681 dc424a06 2019-08-07 stsp fi
1682 dc424a06 2019-08-07 stsp
1683 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1684 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1685 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1686 49c543a6 2022-03-31 naddy ret=$?
1687 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1688 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1689 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1690 dc424a06 2019-08-07 stsp return 1
1691 dc424a06 2019-08-07 stsp fi
1692 dc424a06 2019-08-07 stsp
1693 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1694 dc424a06 2019-08-07 stsp
1695 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1696 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1697 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1698 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1699 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1700 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1701 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1702 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1703 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1704 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1705 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1706 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1707 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1708 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1709 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1710 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1711 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1712 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1713 49c543a6 2022-03-31 naddy ret=$?
1714 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1715 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1716 af5a81b2 2019-08-08 stsp fi
1717 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1718 af5a81b2 2019-08-08 stsp }
1719 af5a81b2 2019-08-08 stsp
1720 f6cae3ed 2020-09-13 naddy test_stage_patch_twice() {
1721 af5a81b2 2019-08-08 stsp local testroot=`test_init stage_patch_twice`
1722 af5a81b2 2019-08-08 stsp
1723 af5a81b2 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1724 af5a81b2 2019-08-08 stsp (cd $testroot/repo && git add numbers)
1725 af5a81b2 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
1726 af5a81b2 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1727 af5a81b2 2019-08-08 stsp
1728 af5a81b2 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1729 49c543a6 2022-03-31 naddy ret=$?
1730 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1731 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1732 af5a81b2 2019-08-08 stsp return 1
1733 af5a81b2 2019-08-08 stsp fi
1734 af5a81b2 2019-08-08 stsp
1735 af5a81b2 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1736 af5a81b2 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1737 af5a81b2 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1738 af5a81b2 2019-08-08 stsp
1739 af5a81b2 2019-08-08 stsp # stage middle hunk
1740 af5a81b2 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
1741 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1742 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1743 af5a81b2 2019-08-08 stsp
1744 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1745 af5a81b2 2019-08-08 stsp -----------------------------------------------
1746 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1747 af5a81b2 2019-08-08 stsp 1
1748 af5a81b2 2019-08-08 stsp -2
1749 af5a81b2 2019-08-08 stsp +a
1750 af5a81b2 2019-08-08 stsp 3
1751 af5a81b2 2019-08-08 stsp 4
1752 af5a81b2 2019-08-08 stsp 5
1753 af5a81b2 2019-08-08 stsp -----------------------------------------------
1754 af5a81b2 2019-08-08 stsp M numbers (change 1 of 3)
1755 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1756 af5a81b2 2019-08-08 stsp -----------------------------------------------
1757 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1758 af5a81b2 2019-08-08 stsp 4
1759 af5a81b2 2019-08-08 stsp 5
1760 af5a81b2 2019-08-08 stsp 6
1761 af5a81b2 2019-08-08 stsp -7
1762 af5a81b2 2019-08-08 stsp +b
1763 af5a81b2 2019-08-08 stsp 8
1764 af5a81b2 2019-08-08 stsp 9
1765 af5a81b2 2019-08-08 stsp 10
1766 af5a81b2 2019-08-08 stsp -----------------------------------------------
1767 af5a81b2 2019-08-08 stsp M numbers (change 2 of 3)
1768 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1769 af5a81b2 2019-08-08 stsp -----------------------------------------------
1770 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1771 af5a81b2 2019-08-08 stsp 13
1772 af5a81b2 2019-08-08 stsp 14
1773 af5a81b2 2019-08-08 stsp 15
1774 af5a81b2 2019-08-08 stsp -16
1775 af5a81b2 2019-08-08 stsp +c
1776 af5a81b2 2019-08-08 stsp -----------------------------------------------
1777 af5a81b2 2019-08-08 stsp M numbers (change 3 of 3)
1778 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1779 af5a81b2 2019-08-08 stsp EOF
1780 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1781 49c543a6 2022-03-31 naddy ret=$?
1782 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1783 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1784 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1785 af5a81b2 2019-08-08 stsp return 1
1786 af5a81b2 2019-08-08 stsp fi
1787 af5a81b2 2019-08-08 stsp
1788 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1789 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1790 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1791 49c543a6 2022-03-31 naddy ret=$?
1792 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1793 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1794 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1795 af5a81b2 2019-08-08 stsp return 1
1796 af5a81b2 2019-08-08 stsp fi
1797 af5a81b2 2019-08-08 stsp
1798 af5a81b2 2019-08-08 stsp # stage last hunk
1799 af5a81b2 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
1800 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1801 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1802 af5a81b2 2019-08-08 stsp
1803 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1804 af5a81b2 2019-08-08 stsp -----------------------------------------------
1805 fe621944 2020-11-10 stsp @@ -1,5 +1,5 @@
1806 af5a81b2 2019-08-08 stsp 1
1807 af5a81b2 2019-08-08 stsp -2
1808 af5a81b2 2019-08-08 stsp +a
1809 af5a81b2 2019-08-08 stsp 3
1810 af5a81b2 2019-08-08 stsp 4
1811 af5a81b2 2019-08-08 stsp 5
1812 af5a81b2 2019-08-08 stsp -----------------------------------------------
1813 af5a81b2 2019-08-08 stsp M numbers (change 1 of 2)
1814 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1815 af5a81b2 2019-08-08 stsp -----------------------------------------------
1816 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@ b
1817 af5a81b2 2019-08-08 stsp 13
1818 af5a81b2 2019-08-08 stsp 14
1819 af5a81b2 2019-08-08 stsp 15
1820 af5a81b2 2019-08-08 stsp -16
1821 af5a81b2 2019-08-08 stsp +c
1822 af5a81b2 2019-08-08 stsp -----------------------------------------------
1823 af5a81b2 2019-08-08 stsp M numbers (change 2 of 2)
1824 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1825 af5a81b2 2019-08-08 stsp EOF
1826 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1827 49c543a6 2022-03-31 naddy ret=$?
1828 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1829 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1830 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1831 af5a81b2 2019-08-08 stsp return 1
1832 af5a81b2 2019-08-08 stsp fi
1833 af5a81b2 2019-08-08 stsp
1834 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1835 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1836 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1837 49c543a6 2022-03-31 naddy ret=$?
1838 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1839 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1840 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1841 af5a81b2 2019-08-08 stsp return 1
1842 af5a81b2 2019-08-08 stsp fi
1843 af5a81b2 2019-08-08 stsp
1844 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1845 af5a81b2 2019-08-08 stsp
1846 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1847 af5a81b2 2019-08-08 stsp > $testroot/stdout.expected
1848 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1849 af5a81b2 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
1850 af5a81b2 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1851 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1852 af5a81b2 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1853 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1854 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1855 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1856 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1857 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1858 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1859 af5a81b2 2019-08-08 stsp 4
1860 af5a81b2 2019-08-08 stsp 5
1861 af5a81b2 2019-08-08 stsp 6
1862 af5a81b2 2019-08-08 stsp -7
1863 af5a81b2 2019-08-08 stsp +b
1864 af5a81b2 2019-08-08 stsp 8
1865 af5a81b2 2019-08-08 stsp 9
1866 af5a81b2 2019-08-08 stsp 10
1867 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1868 af5a81b2 2019-08-08 stsp 13
1869 af5a81b2 2019-08-08 stsp 14
1870 af5a81b2 2019-08-08 stsp 15
1871 af5a81b2 2019-08-08 stsp -16
1872 af5a81b2 2019-08-08 stsp +c
1873 af5a81b2 2019-08-08 stsp EOF
1874 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1875 49c543a6 2022-03-31 naddy ret=$?
1876 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1877 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1878 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1879 af5a81b2 2019-08-08 stsp return 1
1880 af5a81b2 2019-08-08 stsp fi
1881 af5a81b2 2019-08-08 stsp
1882 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1883 af5a81b2 2019-08-08 stsp
1884 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
1885 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1886 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
1887 af5a81b2 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
1888 af5a81b2 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
1889 af5a81b2 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
1890 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1891 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1892 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1893 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1894 af5a81b2 2019-08-08 stsp 1
1895 af5a81b2 2019-08-08 stsp -2
1896 af5a81b2 2019-08-08 stsp +a
1897 af5a81b2 2019-08-08 stsp 3
1898 af5a81b2 2019-08-08 stsp 4
1899 af5a81b2 2019-08-08 stsp 5
1900 af5a81b2 2019-08-08 stsp EOF
1901 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1902 49c543a6 2022-03-31 naddy ret=$?
1903 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1904 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1905 dc424a06 2019-08-07 stsp fi
1906 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1907 dc424a06 2019-08-07 stsp }
1908 dc424a06 2019-08-07 stsp
1909 f6cae3ed 2020-09-13 naddy test_stage_patch_added() {
1910 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1911 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1912 dc424a06 2019-08-07 stsp
1913 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1914 49c543a6 2022-03-31 naddy ret=$?
1915 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1916 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1917 dc424a06 2019-08-07 stsp return 1
1918 dc424a06 2019-08-07 stsp fi
1919 dc424a06 2019-08-07 stsp
1920 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1921 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1922 dc424a06 2019-08-07 stsp
1923 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1924 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1925 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1926 dc424a06 2019-08-07 stsp
1927 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1928 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1929 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1930 49c543a6 2022-03-31 naddy ret=$?
1931 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1932 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1933 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1934 dc424a06 2019-08-07 stsp return 1
1935 dc424a06 2019-08-07 stsp fi
1936 dc424a06 2019-08-07 stsp
1937 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1938 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $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 diff -s > $testroot/stdout)
1948 dc424a06 2019-08-07 stsp
1949 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1950 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1951 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1952 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1953 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1954 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1955 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1956 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1957 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1958 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1959 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1960 49c543a6 2022-03-31 naddy ret=$?
1961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1962 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1963 e70a841e 2019-08-08 stsp fi
1964 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1965 e70a841e 2019-08-08 stsp }
1966 e70a841e 2019-08-08 stsp
1967 f6cae3ed 2020-09-13 naddy test_stage_patch_added_twice() {
1968 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_added_twice`
1969 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1970 e70a841e 2019-08-08 stsp
1971 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1972 49c543a6 2022-03-31 naddy ret=$?
1973 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1974 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1975 e70a841e 2019-08-08 stsp return 1
1976 e70a841e 2019-08-08 stsp fi
1977 e70a841e 2019-08-08 stsp
1978 e70a841e 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
1979 e70a841e 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1980 e70a841e 2019-08-08 stsp
1981 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1982 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1983 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout)
1984 e70a841e 2019-08-08 stsp
1985 e70a841e 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
1986 e70a841e 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1987 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1988 49c543a6 2022-03-31 naddy ret=$?
1989 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1990 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1991 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1992 e70a841e 2019-08-08 stsp return 1
1993 e70a841e 2019-08-08 stsp fi
1994 e70a841e 2019-08-08 stsp
1995 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1996 e70a841e 2019-08-08 stsp echo " A epsilon/new" > $testroot/stdout.expected
1997 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1998 49c543a6 2022-03-31 naddy ret=$?
1999 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2000 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2001 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2002 e70a841e 2019-08-08 stsp return 1
2003 dc424a06 2019-08-07 stsp fi
2004 e70a841e 2019-08-08 stsp
2005 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2006 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout 2> $testroot/stderr)
2007 49c543a6 2022-03-31 naddy ret=$?
2008 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
2009 e70a841e 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2010 e70a841e 2019-08-08 stsp test_done "$testroot" "1"
2011 e70a841e 2019-08-08 stsp return 1
2012 e70a841e 2019-08-08 stsp fi
2013 e70a841e 2019-08-08 stsp
2014 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
2015 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2016 49c543a6 2022-03-31 naddy ret=$?
2017 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2018 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2019 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2020 e70a841e 2019-08-08 stsp return 1
2021 e70a841e 2019-08-08 stsp fi
2022 e70a841e 2019-08-08 stsp
2023 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2024 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2025 49c543a6 2022-03-31 naddy ret=$?
2026 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2027 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2028 e70a841e 2019-08-08 stsp fi
2029 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2030 dc424a06 2019-08-07 stsp }
2031 dc424a06 2019-08-07 stsp
2032 f6cae3ed 2020-09-13 naddy test_stage_patch_removed() {
2033 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
2034 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2035 dc424a06 2019-08-07 stsp
2036 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2037 49c543a6 2022-03-31 naddy ret=$?
2038 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2039 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2040 dc424a06 2019-08-07 stsp return 1
2041 dc424a06 2019-08-07 stsp fi
2042 dc424a06 2019-08-07 stsp
2043 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
2044 dc424a06 2019-08-07 stsp
2045 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
2046 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2047 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
2048 dc424a06 2019-08-07 stsp
2049 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
2050 dc424a06 2019-08-07 stsp
2051 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
2052 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2053 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2054 49c543a6 2022-03-31 naddy ret=$?
2055 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2056 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2057 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2058 dc424a06 2019-08-07 stsp return 1
2059 dc424a06 2019-08-07 stsp fi
2060 dc424a06 2019-08-07 stsp
2061 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2062 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
2063 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2064 49c543a6 2022-03-31 naddy ret=$?
2065 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2066 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2067 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2068 dc424a06 2019-08-07 stsp return 1
2069 dc424a06 2019-08-07 stsp fi
2070 dc424a06 2019-08-07 stsp
2071 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2072 dc424a06 2019-08-07 stsp
2073 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2074 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
2075 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2076 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
2077 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
2078 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2079 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
2080 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
2081 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
2082 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
2083 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2084 49c543a6 2022-03-31 naddy ret=$?
2085 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2086 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2087 dc424a06 2019-08-07 stsp fi
2088 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2089 dc424a06 2019-08-07 stsp }
2090 b353a198 2019-08-07 stsp
2091 f6cae3ed 2020-09-13 naddy test_stage_patch_removed_twice() {
2092 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_removed_twice`
2093 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2094 e70a841e 2019-08-08 stsp
2095 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2096 49c543a6 2022-03-31 naddy ret=$?
2097 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2098 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2099 e70a841e 2019-08-08 stsp return 1
2100 e70a841e 2019-08-08 stsp fi
2101 e70a841e 2019-08-08 stsp
2102 e70a841e 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
2103 e70a841e 2019-08-08 stsp
2104 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2105 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2106 e70a841e 2019-08-08 stsp beta > $testroot/stdout)
2107 e70a841e 2019-08-08 stsp
2108 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2109 e70a841e 2019-08-08 stsp
2110 e70a841e 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
2111 e70a841e 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2112 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2113 49c543a6 2022-03-31 naddy ret=$?
2114 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2115 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2116 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2117 e70a841e 2019-08-08 stsp return 1
2118 e70a841e 2019-08-08 stsp fi
2119 e70a841e 2019-08-08 stsp
2120 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2121 e70a841e 2019-08-08 stsp echo " D beta" > $testroot/stdout.expected
2122 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2123 49c543a6 2022-03-31 naddy ret=$?
2124 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2125 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2126 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2127 e70a841e 2019-08-08 stsp return 1
2128 e70a841e 2019-08-08 stsp fi
2129 e70a841e 2019-08-08 stsp
2130 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p beta \
2131 e70a841e 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2132 49c543a6 2022-03-31 naddy ret=$?
2133 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
2134 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
2135 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2136 e70a841e 2019-08-08 stsp return 1
2137 e70a841e 2019-08-08 stsp fi
2138 e70a841e 2019-08-08 stsp
2139 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
2140 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2141 49c543a6 2022-03-31 naddy ret=$?
2142 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2143 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2144 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2145 e70a841e 2019-08-08 stsp return 1
2146 e70a841e 2019-08-08 stsp fi
2147 e70a841e 2019-08-08 stsp
2148 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2149 9fdde394 2022-06-04 op cmp -s $testroot/stdout.expected $testroot/stdout
2150 9fdde394 2022-06-04 op ret=$?
2151 9fdde394 2022-06-04 op if [ $ret -ne 0 ]; then
2152 9fdde394 2022-06-04 op diff -u $testroot/stdout.expected $testroot/stdout
2153 9fdde394 2022-06-04 op fi
2154 9fdde394 2022-06-04 op test_done "$testroot" "$ret"
2155 9fdde394 2022-06-04 op }
2156 9fdde394 2022-06-04 op
2157 9fdde394 2022-06-04 op test_stage_patch_reversed() {
2158 9fdde394 2022-06-04 op local testroot=`test_init stage_patch_reversed`
2159 9fdde394 2022-06-04 op
2160 9fdde394 2022-06-04 op got checkout $testroot/repo $testroot/wt > /dev/null
2161 9fdde394 2022-06-04 op ret=$?
2162 9fdde394 2022-06-04 op if [ $ret -ne 0 ]; then
2163 9fdde394 2022-06-04 op test_done "$testroot" "$ret"
2164 9fdde394 2022-06-04 op return 1
2165 9fdde394 2022-06-04 op fi
2166 9fdde394 2022-06-04 op
2167 9fdde394 2022-06-04 op echo 'ALPHA' > $testroot/wt/alpha
2168 9fdde394 2022-06-04 op (cd $testroot/wt && got stage alpha > $testroot/stdout)
2169 9fdde394 2022-06-04 op ret=$?
2170 9fdde394 2022-06-04 op if [ $ret -ne 0 ]; then
2171 9fdde394 2022-06-04 op test_done "$testroot" "$ret"
2172 9fdde394 2022-06-04 op return 1
2173 9fdde394 2022-06-04 op fi
2174 9fdde394 2022-06-04 op
2175 9fdde394 2022-06-04 op echo ' M alpha' > $testroot/stdout.expected
2176 9fdde394 2022-06-04 op cmp -s $testroot/stdout.expected $testroot/stdout
2177 9fdde394 2022-06-04 op ret=$?
2178 9fdde394 2022-06-04 op if [ $ret -ne 0 ]; then
2179 9fdde394 2022-06-04 op diff -u $testroot/stdout.expected $testroot/stdout
2180 9fdde394 2022-06-04 op test_done "$testroot" "$ret"
2181 9fdde394 2022-06-04 op return 1
2182 9fdde394 2022-06-04 op fi
2183 9fdde394 2022-06-04 op
2184 9fdde394 2022-06-04 op echo 'alpha' > $testroot/wt/alpha
2185 9fdde394 2022-06-04 op (cd $testroot/wt && got stage alpha > $testroot/stdout)
2186 9fdde394 2022-06-04 op ret=$?
2187 9fdde394 2022-06-04 op if [ $ret -ne 0 ]; then
2188 9fdde394 2022-06-04 op test_done "$testroot" "$ret"
2189 9fdde394 2022-06-04 op return 1
2190 9fdde394 2022-06-04 op fi
2191 9fdde394 2022-06-04 op
2192 9fdde394 2022-06-04 op echo ' M alpha' > $testroot/stdout.expected
2193 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2194 49c543a6 2022-03-31 naddy ret=$?
2195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2196 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2197 9fdde394 2022-06-04 op test_done "$testroot" "$ret"
2198 9fdde394 2022-06-04 op return 1
2199 9fdde394 2022-06-04 op fi
2200 9fdde394 2022-06-04 op
2201 9fdde394 2022-06-04 op (cd $testroot/wt && got status > $testroot/stdout)
2202 9fdde394 2022-06-04 op cmp -s /dev/null $testroot/stdout
2203 9fdde394 2022-06-04 op ret=$?
2204 9fdde394 2022-06-04 op if [ $ret -ne 0 ]; then
2205 9fdde394 2022-06-04 op diff -u /dev/null $testroot/stdout
2206 e70a841e 2019-08-08 stsp fi
2207 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2208 e70a841e 2019-08-08 stsp }
2209 e70a841e 2019-08-08 stsp
2210 f6cae3ed 2020-09-13 naddy test_stage_patch_quit() {
2211 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
2212 b353a198 2019-08-07 stsp
2213 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
2214 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2215 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2216 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2217 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2218 b353a198 2019-08-07 stsp
2219 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2220 49c543a6 2022-03-31 naddy ret=$?
2221 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2222 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2223 b353a198 2019-08-07 stsp return 1
2224 b353a198 2019-08-07 stsp fi
2225 dc424a06 2019-08-07 stsp
2226 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2227 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2228 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2229 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
2230 b353a198 2019-08-07 stsp
2231 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
2232 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
2233 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
2234 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2235 2db2652d 2019-08-07 stsp > $testroot/stdout)
2236 49c543a6 2022-03-31 naddy ret=$?
2237 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2238 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
2239 b353a198 2019-08-07 stsp test_done "$testroot" "1"
2240 b353a198 2019-08-07 stsp return 1
2241 b353a198 2019-08-07 stsp fi
2242 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
2243 b353a198 2019-08-07 stsp -----------------------------------------------
2244 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
2245 b353a198 2019-08-07 stsp 1
2246 b353a198 2019-08-07 stsp -2
2247 b353a198 2019-08-07 stsp +a
2248 b353a198 2019-08-07 stsp 3
2249 b353a198 2019-08-07 stsp 4
2250 b353a198 2019-08-07 stsp 5
2251 b353a198 2019-08-07 stsp -----------------------------------------------
2252 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
2253 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
2254 b353a198 2019-08-07 stsp -----------------------------------------------
2255 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
2256 b353a198 2019-08-07 stsp 4
2257 b353a198 2019-08-07 stsp 5
2258 b353a198 2019-08-07 stsp 6
2259 b353a198 2019-08-07 stsp -7
2260 b353a198 2019-08-07 stsp +b
2261 b353a198 2019-08-07 stsp 8
2262 b353a198 2019-08-07 stsp 9
2263 b353a198 2019-08-07 stsp 10
2264 b353a198 2019-08-07 stsp -----------------------------------------------
2265 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
2266 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
2267 88f33a19 2019-08-08 stsp D zzz
2268 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
2269 b353a198 2019-08-07 stsp EOF
2270 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2271 49c543a6 2022-03-31 naddy ret=$?
2272 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2273 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2274 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2275 b353a198 2019-08-07 stsp return 1
2276 b353a198 2019-08-07 stsp fi
2277 b353a198 2019-08-07 stsp
2278 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2279 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
2280 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
2281 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2282 49c543a6 2022-03-31 naddy ret=$?
2283 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2284 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2285 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2286 b353a198 2019-08-07 stsp return 1
2287 b353a198 2019-08-07 stsp fi
2288 b353a198 2019-08-07 stsp
2289 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2290 b353a198 2019-08-07 stsp
2291 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2292 b353a198 2019-08-07 stsp > $testroot/stdout.expected
2293 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2294 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
2295 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
2296 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2297 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2298 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
2299 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2300 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
2301 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
2302 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
2303 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
2304 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
2305 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
2306 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
2307 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
2308 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
2309 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2310 49c543a6 2022-03-31 naddy ret=$?
2311 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2312 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2313 b353a198 2019-08-07 stsp fi
2314 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2315 b353a198 2019-08-07 stsp
2316 b353a198 2019-08-07 stsp }
2317 b353a198 2019-08-07 stsp
2318 f6cae3ed 2020-09-13 naddy test_stage_patch_incomplete_script() {
2319 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
2320 eba70f38 2019-08-08 stsp
2321 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
2322 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2323 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2324 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2325 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2326 eba70f38 2019-08-08 stsp
2327 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2328 49c543a6 2022-03-31 naddy ret=$?
2329 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2330 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2331 eba70f38 2019-08-08 stsp return 1
2332 eba70f38 2019-08-08 stsp fi
2333 eba70f38 2019-08-08 stsp
2334 eba70f38 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2335 eba70f38 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2336 eba70f38 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2337 eba70f38 2019-08-08 stsp
2338 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
2339 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2340 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2341 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2342 49c543a6 2022-03-31 naddy ret=$?
2343 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
2344 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2345 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
2346 eba70f38 2019-08-08 stsp return 1
2347 eba70f38 2019-08-08 stsp fi
2348 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
2349 eba70f38 2019-08-08 stsp -----------------------------------------------
2350 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
2351 eba70f38 2019-08-08 stsp 1
2352 eba70f38 2019-08-08 stsp -2
2353 eba70f38 2019-08-08 stsp +a
2354 eba70f38 2019-08-08 stsp 3
2355 eba70f38 2019-08-08 stsp 4
2356 eba70f38 2019-08-08 stsp 5
2357 eba70f38 2019-08-08 stsp -----------------------------------------------
2358 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
2359 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
2360 eba70f38 2019-08-08 stsp -----------------------------------------------
2361 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
2362 eba70f38 2019-08-08 stsp 4
2363 eba70f38 2019-08-08 stsp 5
2364 eba70f38 2019-08-08 stsp 6
2365 eba70f38 2019-08-08 stsp -7
2366 eba70f38 2019-08-08 stsp +b
2367 eba70f38 2019-08-08 stsp 8
2368 eba70f38 2019-08-08 stsp 9
2369 eba70f38 2019-08-08 stsp 10
2370 eba70f38 2019-08-08 stsp -----------------------------------------------
2371 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
2372 eba70f38 2019-08-08 stsp EOF
2373 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
2374 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
2375 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2376 49c543a6 2022-03-31 naddy ret=$?
2377 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2378 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2379 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2380 eba70f38 2019-08-08 stsp return 1
2381 eba70f38 2019-08-08 stsp fi
2382 eba70f38 2019-08-08 stsp
2383 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2384 49c543a6 2022-03-31 naddy ret=$?
2385 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2386 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2387 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2388 eba70f38 2019-08-08 stsp return 1
2389 eba70f38 2019-08-08 stsp fi
2390 eba70f38 2019-08-08 stsp
2391 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2392 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
2393 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2394 49c543a6 2022-03-31 naddy ret=$?
2395 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2396 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2397 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2398 eba70f38 2019-08-08 stsp return 1
2399 eba70f38 2019-08-08 stsp fi
2400 eba70f38 2019-08-08 stsp
2401 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2402 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
2403 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2404 49c543a6 2022-03-31 naddy ret=$?
2405 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2406 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2407 eba70f38 2019-08-08 stsp fi
2408 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2409 c631b115 2020-07-23 stsp
2410 c631b115 2020-07-23 stsp }
2411 c631b115 2020-07-23 stsp
2412 f6cae3ed 2020-09-13 naddy test_stage_symlink() {
2413 c631b115 2020-07-23 stsp local testroot=`test_init stage_symlink`
2414 c631b115 2020-07-23 stsp
2415 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2416 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
2417 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2418 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2419 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2420 c631b115 2020-07-23 stsp (cd $testroot/repo && git add .)
2421 c631b115 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2422 c631b115 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
2423 c631b115 2020-07-23 stsp
2424 c631b115 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2425 49c543a6 2022-03-31 naddy ret=$?
2426 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2427 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2428 c631b115 2020-07-23 stsp return 1
2429 c631b115 2020-07-23 stsp fi
2430 c631b115 2020-07-23 stsp
2431 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
2432 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
2433 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
2434 c631b115 2020-07-23 stsp echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
2435 c631b115 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2436 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
2437 c631b115 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2438 c631b115 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
2439 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
2440 c631b115 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
2441 c631b115 2020-07-23 stsp
2442 35213c7c 2020-07-23 stsp (cd $testroot/wt && got stage > $testroot/stdout 2> $testroot/stderr)
2443 49c543a6 2022-03-31 naddy ret=$?
2444 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
2445 35213c7c 2020-07-23 stsp echo "got stage succeeded unexpectedly" >&2
2446 a19f439c 2022-06-03 op test_done "$testroot" 1
2447 35213c7c 2020-07-23 stsp return 1
2448 35213c7c 2020-07-23 stsp fi
2449 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
2450 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
2451 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
2452 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2453 49c543a6 2022-03-31 naddy ret=$?
2454 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2455 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
2456 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
2457 35213c7c 2020-07-23 stsp return 1
2458 35213c7c 2020-07-23 stsp fi
2459 35213c7c 2020-07-23 stsp
2460 35213c7c 2020-07-23 stsp (cd $testroot/wt && got stage -S > $testroot/stdout)
2461 c631b115 2020-07-23 stsp
2462 c631b115 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2463 c631b115 2020-07-23 stsp M alpha.link
2464 c631b115 2020-07-23 stsp A dotgotbar.link
2465 c631b115 2020-07-23 stsp A dotgotfoo.link
2466 c631b115 2020-07-23 stsp M epsilon/beta.link
2467 c631b115 2020-07-23 stsp M epsilon.link
2468 c631b115 2020-07-23 stsp D nonexistent.link
2469 c631b115 2020-07-23 stsp A zeta.link
2470 c631b115 2020-07-23 stsp EOF
2471 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2472 49c543a6 2022-03-31 naddy ret=$?
2473 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2474 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2475 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2476 c631b115 2020-07-23 stsp return 1
2477 c631b115 2020-07-23 stsp fi
2478 0aeb8099 2020-07-23 stsp
2479 0aeb8099 2020-07-23 stsp rm $testroot/wt/alpha.link
2480 0aeb8099 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/wt/alpha.link
2481 c631b115 2020-07-23 stsp
2482 c631b115 2020-07-23 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2483 c631b115 2020-07-23 stsp
2484 c631b115 2020-07-23 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
2485 c631b115 2020-07-23 stsp > $testroot/stdout.expected
2486 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2487 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
2488 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2489 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2490 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l alpha.link) | cut -d' ' -f 1 \
2491 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2492 c631b115 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
2493 c631b115 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
2494 c631b115 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2495 c631b115 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
2496 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2497 c631b115 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
2498 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2499 c631b115 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2500 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2501 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l dotgotbar.link) | cut -d' ' -f 1 \
2502 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2503 c631b115 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2504 c631b115 2020-07-23 stsp echo '+++ dotgotbar.link' >> $testroot/stdout.expected
2505 c631b115 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2506 c631b115 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
2507 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2508 c631b115 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2509 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2510 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
2511 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2512 c631b115 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2513 c631b115 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2514 c631b115 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2515 c631b115 2020-07-23 stsp echo '+this is regular file foo' >> $testroot/stdout.expected
2516 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2517 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i epsilon | grep 'beta.link@ -> ../beta$' | \
2518 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2519 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2520 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l epsilon/beta.link) | cut -d' ' -f 1 \
2521 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2522 c631b115 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
2523 c631b115 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
2524 c631b115 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2525 c631b115 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
2526 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2527 c631b115 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
2528 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2529 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2530 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
2531 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2532 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2533 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l epsilon.link) | cut -d' ' -f 1 \
2534 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2535 c631b115 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
2536 c631b115 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
2537 c631b115 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2538 c631b115 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
2539 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2540 c631b115 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
2541 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2542 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2543 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
2544 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2545 c631b115 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2546 c631b115 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
2547 c631b115 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
2548 c631b115 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2549 c631b115 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
2550 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2551 c631b115 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2552 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2553 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
2554 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2555 c631b115 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2556 c631b115 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
2557 c631b115 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2558 c631b115 2020-07-23 stsp echo '+gamma/delta' >> $testroot/stdout.expected
2559 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2560 c631b115 2020-07-23 stsp
2561 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2562 49c543a6 2022-03-31 naddy ret=$?
2563 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2564 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2565 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2566 c631b115 2020-07-23 stsp return 1
2567 c631b115 2020-07-23 stsp fi
2568 c631b115 2020-07-23 stsp
2569 c631b115 2020-07-23 stsp (cd $testroot/wt && got commit -m "staged symlink" \
2570 c631b115 2020-07-23 stsp > $testroot/stdout)
2571 49c543a6 2022-03-31 naddy ret=$?
2572 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2573 c631b115 2020-07-23 stsp echo "got commit command failed unexpectedly" >&2
2574 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2575 c631b115 2020-07-23 stsp return 1
2576 c631b115 2020-07-23 stsp fi
2577 eba70f38 2019-08-08 stsp
2578 c631b115 2020-07-23 stsp local commit_id=`git_show_head $testroot/repo`
2579 c631b115 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
2580 c631b115 2020-07-23 stsp echo "A dotgotfoo.link" >> $testroot/stdout.expected
2581 c631b115 2020-07-23 stsp echo "A zeta.link" >> $testroot/stdout.expected
2582 c631b115 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
2583 c631b115 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
2584 c631b115 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
2585 c631b115 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
2586 c631b115 2020-07-23 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
2587 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2588 49c543a6 2022-03-31 naddy ret=$?
2589 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2590 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2591 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2592 c631b115 2020-07-23 stsp return 1
2593 c631b115 2020-07-23 stsp fi
2594 c631b115 2020-07-23 stsp
2595 c631b115 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id > $testroot/stdout
2596 49c543a6 2022-03-31 naddy ret=$?
2597 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2598 c631b115 2020-07-23 stsp echo "got tree command failed unexpectedly" >&2
2599 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2600 c631b115 2020-07-23 stsp return 1
2601 c631b115 2020-07-23 stsp fi
2602 c631b115 2020-07-23 stsp
2603 c631b115 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2604 c631b115 2020-07-23 stsp alpha
2605 c631b115 2020-07-23 stsp alpha.link@ -> beta
2606 c631b115 2020-07-23 stsp beta
2607 c631b115 2020-07-23 stsp dotgotbar.link@ -> .got/bar
2608 c631b115 2020-07-23 stsp dotgotfoo.link
2609 c631b115 2020-07-23 stsp epsilon/
2610 c631b115 2020-07-23 stsp epsilon.link@ -> gamma
2611 c631b115 2020-07-23 stsp gamma/
2612 c631b115 2020-07-23 stsp passwd.link@ -> /etc/passwd
2613 c631b115 2020-07-23 stsp zeta.link@ -> gamma/delta
2614 c631b115 2020-07-23 stsp EOF
2615 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2616 49c543a6 2022-03-31 naddy ret=$?
2617 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2618 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2619 c631b115 2020-07-23 stsp return 1
2620 c631b115 2020-07-23 stsp fi
2621 c631b115 2020-07-23 stsp
2622 0aeb8099 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
2623 0aeb8099 2020-07-23 stsp echo "alpha.link is a symlink"
2624 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2625 c631b115 2020-07-23 stsp return 1
2626 c631b115 2020-07-23 stsp fi
2627 c631b115 2020-07-23 stsp
2628 0aeb8099 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/content.expected
2629 0aeb8099 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
2630 0aeb8099 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2631 49c543a6 2022-03-31 naddy ret=$?
2632 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2633 0aeb8099 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2634 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2635 c631b115 2020-07-23 stsp return 1
2636 c631b115 2020-07-23 stsp fi
2637 c631b115 2020-07-23 stsp
2638 75f0a0fb 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
2639 75f0a0fb 2020-07-23 stsp echo "dotgotbar.link is not a symlink"
2640 75f0a0fb 2020-07-23 stsp test_done "$testroot" "1"
2641 75f0a0fb 2020-07-23 stsp return 1
2642 75f0a0fb 2020-07-23 stsp fi
2643 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
2644 c631b115 2020-07-23 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
2645 c631b115 2020-07-23 stsp echo "dotgotbar.link is a symlink"
2646 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2647 c631b115 2020-07-23 stsp return 1
2648 c631b115 2020-07-23 stsp fi
2649 0aeb8099 2020-07-23 stsp echo -n ".got/bar" > $testroot/content.expected
2650 c631b115 2020-07-23 stsp cp $testroot/wt/dotgotbar.link $testroot/content
2651 fa3cef63 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2652 49c543a6 2022-03-31 naddy ret=$?
2653 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2654 fa3cef63 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2655 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2656 fa3cef63 2020-07-23 stsp return 1
2657 fa3cef63 2020-07-23 stsp fi
2658 fa3cef63 2020-07-23 stsp
2659 fa3cef63 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
2660 fa3cef63 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
2661 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2662 fa3cef63 2020-07-23 stsp return 1
2663 fa3cef63 2020-07-23 stsp fi
2664 fa3cef63 2020-07-23 stsp echo "this is regular file foo" > $testroot/content.expected
2665 fa3cef63 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
2666 fa3cef63 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2667 49c543a6 2022-03-31 naddy ret=$?
2668 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2669 fa3cef63 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2670 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2671 fa3cef63 2020-07-23 stsp return 1
2672 fa3cef63 2020-07-23 stsp fi
2673 fa3cef63 2020-07-23 stsp
2674 fa3cef63 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
2675 fa3cef63 2020-07-23 stsp echo "epsilon.link is not a symlink"
2676 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2677 fa3cef63 2020-07-23 stsp return 1
2678 fa3cef63 2020-07-23 stsp fi
2679 fa3cef63 2020-07-23 stsp
2680 fa3cef63 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
2681 fa3cef63 2020-07-23 stsp echo "gamma" > $testroot/stdout.expected
2682 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2683 49c543a6 2022-03-31 naddy ret=$?
2684 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2685 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2686 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2687 fa3cef63 2020-07-23 stsp return 1
2688 fa3cef63 2020-07-23 stsp fi
2689 fa3cef63 2020-07-23 stsp
2690 fa3cef63 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2691 fa3cef63 2020-07-23 stsp echo "passwd.link is a symlink"
2692 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2693 fa3cef63 2020-07-23 stsp return 1
2694 fa3cef63 2020-07-23 stsp fi
2695 fa3cef63 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
2696 fa3cef63 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
2697 fa3cef63 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2698 49c543a6 2022-03-31 naddy ret=$?
2699 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2700 fa3cef63 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2701 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2702 fa3cef63 2020-07-23 stsp return 1
2703 fa3cef63 2020-07-23 stsp fi
2704 fa3cef63 2020-07-23 stsp
2705 fa3cef63 2020-07-23 stsp if ! [ -h $testroot/wt/zeta.link ]; then
2706 fa3cef63 2020-07-23 stsp echo "zeta.link is not a symlink"
2707 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2708 fa3cef63 2020-07-23 stsp return 1
2709 fa3cef63 2020-07-23 stsp fi
2710 fa3cef63 2020-07-23 stsp
2711 fa3cef63 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
2712 fa3cef63 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
2713 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2714 49c543a6 2022-03-31 naddy ret=$?
2715 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2716 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2717 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2718 fa3cef63 2020-07-23 stsp return 1
2719 fa3cef63 2020-07-23 stsp fi
2720 fa3cef63 2020-07-23 stsp
2721 fa3cef63 2020-07-23 stsp test_done "$testroot" "0"
2722 fa3cef63 2020-07-23 stsp }
2723 fa3cef63 2020-07-23 stsp
2724 f6cae3ed 2020-09-13 naddy test_stage_patch_symlink() {
2725 fa3cef63 2020-07-23 stsp local testroot=`test_init stage_patch_symlink`
2726 fa3cef63 2020-07-23 stsp
2727 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2728 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
2729 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2730 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2731 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2732 fa3cef63 2020-07-23 stsp (cd $testroot/repo && git add .)
2733 fa3cef63 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2734 fa3cef63 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
2735 fa3cef63 2020-07-23 stsp
2736 fa3cef63 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2737 49c543a6 2022-03-31 naddy ret=$?
2738 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2739 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2740 fa3cef63 2020-07-23 stsp return 1
2741 fa3cef63 2020-07-23 stsp fi
2742 fa3cef63 2020-07-23 stsp
2743 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
2744 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
2745 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
2746 fa3cef63 2020-07-23 stsp echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
2747 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2748 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
2749 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2750 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
2751 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
2752 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
2753 fa3cef63 2020-07-23 stsp
2754 fa3cef63 2020-07-23 stsp printf "y\nn\ny\nn\ny\ny\ny" > $testroot/patchscript
2755 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2756 fa3cef63 2020-07-23 stsp > $testroot/stdout)
2757 fa3cef63 2020-07-23 stsp
2758 fa3cef63 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2759 fa3cef63 2020-07-23 stsp -----------------------------------------------
2760 fa3cef63 2020-07-23 stsp @@ -1 +1 @@
2761 fa3cef63 2020-07-23 stsp -alpha
2762 fa3cef63 2020-07-23 stsp \ No newline at end of file
2763 fa3cef63 2020-07-23 stsp +beta
2764 fa3cef63 2020-07-23 stsp \ No newline at end of file
2765 fa3cef63 2020-07-23 stsp -----------------------------------------------
2766 fa3cef63 2020-07-23 stsp M alpha.link (change 1 of 1)
2767 fa3cef63 2020-07-23 stsp stage this change? [y/n/q] y
2768 fa3cef63 2020-07-23 stsp A dotgotbar.link
2769 fa3cef63 2020-07-23 stsp stage this addition? [y/n] n
2770 fa3cef63 2020-07-23 stsp A dotgotfoo.link
2771 fa3cef63 2020-07-23 stsp stage this addition? [y/n] y
2772 fa3cef63 2020-07-23 stsp -----------------------------------------------
2773 fa3cef63 2020-07-23 stsp @@ -1 +1 @@
2774 fa3cef63 2020-07-23 stsp -../beta
2775 fa3cef63 2020-07-23 stsp \ No newline at end of file
2776 fa3cef63 2020-07-23 stsp +../gamma/delta
2777 fa3cef63 2020-07-23 stsp \ No newline at end of file
2778 fa3cef63 2020-07-23 stsp -----------------------------------------------
2779 fa3cef63 2020-07-23 stsp M epsilon/beta.link (change 1 of 1)
2780 fa3cef63 2020-07-23 stsp stage this change? [y/n/q] n
2781 fa3cef63 2020-07-23 stsp -----------------------------------------------
2782 fa3cef63 2020-07-23 stsp @@ -1 +1 @@
2783 fa3cef63 2020-07-23 stsp -epsilon
2784 fa3cef63 2020-07-23 stsp \ No newline at end of file
2785 fa3cef63 2020-07-23 stsp +gamma
2786 fa3cef63 2020-07-23 stsp \ No newline at end of file
2787 fa3cef63 2020-07-23 stsp -----------------------------------------------
2788 fa3cef63 2020-07-23 stsp M epsilon.link (change 1 of 1)
2789 fa3cef63 2020-07-23 stsp stage this change? [y/n/q] y
2790 fa3cef63 2020-07-23 stsp D nonexistent.link
2791 fa3cef63 2020-07-23 stsp stage this deletion? [y/n] y
2792 fa3cef63 2020-07-23 stsp A zeta.link
2793 fa3cef63 2020-07-23 stsp stage this addition? [y/n] y
2794 fa3cef63 2020-07-23 stsp EOF
2795 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2796 49c543a6 2022-03-31 naddy ret=$?
2797 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2798 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2799 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2800 fa3cef63 2020-07-23 stsp return 1
2801 fa3cef63 2020-07-23 stsp fi
2802 fa3cef63 2020-07-23 stsp
2803 fa3cef63 2020-07-23 stsp rm $testroot/wt/alpha.link
2804 fa3cef63 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/wt/alpha.link
2805 fa3cef63 2020-07-23 stsp
2806 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2807 fa3cef63 2020-07-23 stsp
2808 fa3cef63 2020-07-23 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
2809 fa3cef63 2020-07-23 stsp > $testroot/stdout.expected
2810 fa3cef63 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2811 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
2812 fa3cef63 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2813 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2814 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l alpha.link) | cut -d' ' -f 1 \
2815 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2816 fa3cef63 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
2817 fa3cef63 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
2818 fa3cef63 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2819 fa3cef63 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
2820 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2821 fa3cef63 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
2822 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2823 fa3cef63 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2824 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2825 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
2826 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2827 fa3cef63 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2828 fa3cef63 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2829 fa3cef63 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2830 fa3cef63 2020-07-23 stsp echo '+this is regular file foo' >> $testroot/stdout.expected
2831 fa3cef63 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2832 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
2833 fa3cef63 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2834 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2835 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l epsilon.link) | cut -d' ' -f 1 \
2836 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2837 fa3cef63 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
2838 fa3cef63 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
2839 fa3cef63 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2840 fa3cef63 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
2841 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2842 fa3cef63 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
2843 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2844 fa3cef63 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2845 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
2846 fa3cef63 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2847 fa3cef63 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2848 fa3cef63 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
2849 fa3cef63 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
2850 fa3cef63 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2851 fa3cef63 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
2852 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2853 fa3cef63 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2854 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2855 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
2856 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2857 fa3cef63 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2858 fa3cef63 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
2859 fa3cef63 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2860 fa3cef63 2020-07-23 stsp echo '+gamma/delta' >> $testroot/stdout.expected
2861 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2862 fa3cef63 2020-07-23 stsp
2863 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2864 49c543a6 2022-03-31 naddy ret=$?
2865 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2866 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2867 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2868 fa3cef63 2020-07-23 stsp return 1
2869 fa3cef63 2020-07-23 stsp fi
2870 fa3cef63 2020-07-23 stsp
2871 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got commit -m "staged symlink" \
2872 fa3cef63 2020-07-23 stsp > $testroot/stdout)
2873 49c543a6 2022-03-31 naddy ret=$?
2874 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2875 fa3cef63 2020-07-23 stsp echo "got commit command failed unexpectedly" >&2
2876 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2877 fa3cef63 2020-07-23 stsp return 1
2878 fa3cef63 2020-07-23 stsp fi
2879 fa3cef63 2020-07-23 stsp
2880 fa3cef63 2020-07-23 stsp local commit_id=`git_show_head $testroot/repo`
2881 fa3cef63 2020-07-23 stsp echo "A dotgotfoo.link" > $testroot/stdout.expected
2882 fa3cef63 2020-07-23 stsp echo "A zeta.link" >> $testroot/stdout.expected
2883 fa3cef63 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
2884 fa3cef63 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
2885 fa3cef63 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
2886 fa3cef63 2020-07-23 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
2887 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $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 diff -u $testroot/stdout.expected $testroot/stdout
2891 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
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 got tree -r $testroot/repo -c $commit_id > $testroot/stdout
2896 49c543a6 2022-03-31 naddy ret=$?
2897 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2898 fa3cef63 2020-07-23 stsp echo "got tree command failed unexpectedly" >&2
2899 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2900 fa3cef63 2020-07-23 stsp return 1
2901 fa3cef63 2020-07-23 stsp fi
2902 fa3cef63 2020-07-23 stsp
2903 fa3cef63 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2904 fa3cef63 2020-07-23 stsp alpha
2905 fa3cef63 2020-07-23 stsp alpha.link@ -> beta
2906 fa3cef63 2020-07-23 stsp beta
2907 fa3cef63 2020-07-23 stsp dotgotfoo.link
2908 fa3cef63 2020-07-23 stsp epsilon/
2909 fa3cef63 2020-07-23 stsp epsilon.link@ -> gamma
2910 fa3cef63 2020-07-23 stsp gamma/
2911 fa3cef63 2020-07-23 stsp passwd.link@ -> /etc/passwd
2912 fa3cef63 2020-07-23 stsp zeta.link@ -> gamma/delta
2913 fa3cef63 2020-07-23 stsp EOF
2914 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2915 49c543a6 2022-03-31 naddy ret=$?
2916 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2917 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2918 fa3cef63 2020-07-23 stsp return 1
2919 fa3cef63 2020-07-23 stsp fi
2920 fa3cef63 2020-07-23 stsp
2921 fa3cef63 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
2922 fa3cef63 2020-07-23 stsp echo "alpha.link is a symlink"
2923 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2924 fa3cef63 2020-07-23 stsp return 1
2925 fa3cef63 2020-07-23 stsp fi
2926 fa3cef63 2020-07-23 stsp
2927 fa3cef63 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/content.expected
2928 fa3cef63 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
2929 c631b115 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2930 49c543a6 2022-03-31 naddy ret=$?
2931 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2932 c631b115 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2933 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2934 c631b115 2020-07-23 stsp return 1
2935 c631b115 2020-07-23 stsp fi
2936 c631b115 2020-07-23 stsp
2937 fa3cef63 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
2938 fa3cef63 2020-07-23 stsp echo "dotgotbar.link is not a symlink"
2939 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2940 fa3cef63 2020-07-23 stsp return 1
2941 fa3cef63 2020-07-23 stsp fi
2942 fa3cef63 2020-07-23 stsp readlink $testroot/wt/dotgotbar.link > $testroot/stdout
2943 fa3cef63 2020-07-23 stsp echo ".got/bar" > $testroot/stdout.expected
2944 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2945 49c543a6 2022-03-31 naddy ret=$?
2946 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2947 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2948 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2949 fa3cef63 2020-07-23 stsp return 1
2950 fa3cef63 2020-07-23 stsp fi
2951 fa3cef63 2020-07-23 stsp
2952 c631b115 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
2953 c631b115 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
2954 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2955 c631b115 2020-07-23 stsp return 1
2956 c631b115 2020-07-23 stsp fi
2957 c631b115 2020-07-23 stsp echo "this is regular file foo" > $testroot/content.expected
2958 c631b115 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
2959 c631b115 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2960 49c543a6 2022-03-31 naddy ret=$?
2961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2962 c631b115 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2963 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2964 c631b115 2020-07-23 stsp return 1
2965 c631b115 2020-07-23 stsp fi
2966 c631b115 2020-07-23 stsp
2967 c631b115 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
2968 c631b115 2020-07-23 stsp echo "epsilon.link is not 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
2973 c631b115 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
2974 c631b115 2020-07-23 stsp echo "gamma" > $testroot/stdout.expected
2975 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2976 49c543a6 2022-03-31 naddy ret=$?
2977 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2978 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2979 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2980 c631b115 2020-07-23 stsp return 1
2981 c631b115 2020-07-23 stsp fi
2982 c631b115 2020-07-23 stsp
2983 c631b115 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2984 c631b115 2020-07-23 stsp echo "passwd.link is a symlink"
2985 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2986 c631b115 2020-07-23 stsp return 1
2987 c631b115 2020-07-23 stsp fi
2988 c631b115 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
2989 c631b115 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
2990 c631b115 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
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/content.expected $testroot/content
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/zeta.link ]; then
2999 c631b115 2020-07-23 stsp echo "zeta.link is not 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
3004 c631b115 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
3005 c631b115 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
3006 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
3007 49c543a6 2022-03-31 naddy ret=$?
3008 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
3009 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
3010 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
3011 c631b115 2020-07-23 stsp return 1
3012 c631b115 2020-07-23 stsp fi
3013 c631b115 2020-07-23 stsp
3014 c631b115 2020-07-23 stsp test_done "$testroot" "0"
3015 eba70f38 2019-08-08 stsp }
3016 eba70f38 2019-08-08 stsp
3017 7fb414ae 2020-08-08 stsp test_parseargs "$@"
3018 fccbfb98 2019-08-03 stsp run_test test_stage_basic
3019 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
3020 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
3021 8564cb21 2019-08-08 stsp run_test test_stage_nonexistent
3022 a4f692bb 2019-08-04 stsp run_test test_stage_list
3023 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
3024 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
3025 d3e7c587 2019-08-03 stsp run_test test_double_stage
3026 c363b2c1 2019-08-03 stsp run_test test_stage_status
3027 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
3028 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
3029 24278f30 2019-08-03 stsp run_test test_stage_revert
3030 408b4ebc 2019-08-03 stsp run_test test_stage_diff
3031 b9622844 2019-08-03 stsp run_test test_stage_histedit
3032 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
3033 a76c42e6 2019-08-03 stsp run_test test_stage_update
3034 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
3035 0f1cfa7f 2019-08-08 stsp run_test test_stage_commit_out_of_date
3036 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
3037 dc424a06 2019-08-07 stsp run_test test_stage_patch
3038 af5a81b2 2019-08-08 stsp run_test test_stage_patch_twice
3039 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
3040 e70a841e 2019-08-08 stsp run_test test_stage_patch_added_twice
3041 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
3042 e70a841e 2019-08-08 stsp run_test test_stage_patch_removed_twice
3043 9fdde394 2022-06-04 op run_test test_stage_patch_reversed
3044 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
3045 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script
3046 c631b115 2020-07-23 stsp run_test test_stage_symlink
3047 fa3cef63 2020-07-23 stsp run_test test_stage_patch_symlink