3 ad493afc 2019-08-03 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 ad493afc 2019-08-03 stsp # Permission to use, copy, modify, and distribute this software for any
6 ad493afc 2019-08-03 stsp # purpose with or without fee is hereby granted, provided that the above
7 ad493afc 2019-08-03 stsp # copyright notice and this permission notice appear in all copies.
9 ad493afc 2019-08-03 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 ad493afc 2019-08-03 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 ad493afc 2019-08-03 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 ad493afc 2019-08-03 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 ad493afc 2019-08-03 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 ad493afc 2019-08-03 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 ad493afc 2019-08-03 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 ad493afc 2019-08-03 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_unstage_basic() {
20 ad493afc 2019-08-03 stsp local testroot=`test_init unstage_basic`
22 ad493afc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 ad493afc 2019-08-03 stsp test_done "$testroot" "$ret"
29 ad493afc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
30 ad493afc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
31 ad493afc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
32 ad493afc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
34 ad493afc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
35 ad493afc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
36 ad493afc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
37 ad493afc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
39 ad493afc 2019-08-03 stsp (cd $testroot/wt && got unstage > $testroot/stdout)
41 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
42 57ba6a8b 2019-08-08 stsp echo "got unstage command failed unexpectedly" >&2
43 ad493afc 2019-08-03 stsp test_done "$testroot" "1"
47 ad493afc 2019-08-03 stsp echo 'G alpha' > $testroot/stdout.expected
48 ad493afc 2019-08-03 stsp echo 'D beta' >> $testroot/stdout.expected
49 ad493afc 2019-08-03 stsp echo 'G foo' >> $testroot/stdout.expected
50 ad493afc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
52 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
53 ad493afc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
54 ad493afc 2019-08-03 stsp test_done "$testroot" "$ret"
58 ad493afc 2019-08-03 stsp echo 'M alpha' > $testroot/stdout.expected
59 ad493afc 2019-08-03 stsp echo 'D beta' >> $testroot/stdout.expected
60 ad493afc 2019-08-03 stsp echo 'A foo' >> $testroot/stdout.expected
61 ad493afc 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
62 ad493afc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
64 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
65 ad493afc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
67 ad493afc 2019-08-03 stsp test_done "$testroot" "$ret"
70 f6cae3ed 2020-09-13 naddy test_unstage_unversioned() {
71 8b13ce36 2019-08-08 stsp local testroot=`test_init unstage_unversioned`
73 8b13ce36 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
75 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
76 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
80 8b13ce36 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
81 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
82 8b13ce36 2019-08-08 stsp echo "new file" > $testroot/wt/foo
83 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
85 8b13ce36 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
86 8b13ce36 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
87 8b13ce36 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
88 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
90 8b13ce36 2019-08-08 stsp touch $testroot/wt/unversioned-file
92 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
93 8b13ce36 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
94 8b13ce36 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
95 8b13ce36 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
96 8b13ce36 2019-08-08 stsp echo "? unversioned-file" >> $testroot/stdout.expected
97 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
99 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
100 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
101 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
105 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got unstage > $testroot/stdout)
107 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
108 8b13ce36 2019-08-08 stsp echo "got unstage command failed unexpectedly" >&2
109 8b13ce36 2019-08-08 stsp test_done "$testroot" "1"
113 8b13ce36 2019-08-08 stsp echo 'G alpha' > $testroot/stdout.expected
114 8b13ce36 2019-08-08 stsp echo 'D beta' >> $testroot/stdout.expected
115 8b13ce36 2019-08-08 stsp echo 'G foo' >> $testroot/stdout.expected
116 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
118 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
119 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
120 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
124 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
126 8b13ce36 2019-08-08 stsp # unstaging an unversioned path is a no-op
127 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got unstage unversioned > $testroot/stdout)
129 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
130 8b13ce36 2019-08-08 stsp echo "got unstage command failed unexpectedly" >&2
131 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
135 8b13ce36 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
136 8b13ce36 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
137 8b13ce36 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
138 8b13ce36 2019-08-08 stsp echo "? unversioned-file" >> $testroot/stdout.expected
139 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
140 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
142 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
143 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
145 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
148 f6cae3ed 2020-09-13 naddy test_unstage_nonexistent() {
149 8564cb21 2019-08-08 stsp local testroot=`test_init unstage_nonexistent`
151 8564cb21 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
153 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
154 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
158 8564cb21 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
159 8564cb21 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
160 8564cb21 2019-08-08 stsp echo "new file" > $testroot/wt/foo
161 8564cb21 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
163 8564cb21 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
164 8564cb21 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
165 8564cb21 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
166 8564cb21 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
168 8564cb21 2019-08-08 stsp # unstaging a non-existent file is a no-op
169 8564cb21 2019-08-08 stsp (cd $testroot/wt && got unstage nonexistent-file > $testroot/stdout)
171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
172 8564cb21 2019-08-08 stsp echo "got unstage command failed unexpectedly" >&2
173 8564cb21 2019-08-08 stsp test_done "$testroot" "1"
177 8564cb21 2019-08-08 stsp echo -n > $testroot/stdout.expected
178 8564cb21 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
180 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
181 8564cb21 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
183 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
186 f6cae3ed 2020-09-13 naddy test_unstage_patch() {
187 2e1f37b0 2019-08-08 stsp local testroot=`test_init unstage_patch`
189 2e1f37b0 2019-08-08 stsp jot 16 > $testroot/repo/numbers
190 2e1f37b0 2019-08-08 stsp (cd $testroot/repo && git add numbers)
191 2e1f37b0 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
192 2e1f37b0 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
194 2e1f37b0 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
196 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
197 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
201 2e1f37b0 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
202 2e1f37b0 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
203 2e1f37b0 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
205 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
207 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
208 2e1f37b0 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
209 2e1f37b0 2019-08-08 stsp test_done "$testroot" "1"
213 2e1f37b0 2019-08-08 stsp # don't unstage any hunks
214 2e1f37b0 2019-08-08 stsp printf "n\nn\nn\n" > $testroot/patchscript
215 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
216 2e1f37b0 2019-08-08 stsp numbers > $testroot/stdout)
218 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
219 57ba6a8b 2019-08-08 stsp echo "got unstage command failed unexpectedly" >&2
220 2e1f37b0 2019-08-08 stsp test_done "$testroot" "1"
223 2e1f37b0 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
224 2e1f37b0 2019-08-08 stsp -----------------------------------------------
225 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
232 2e1f37b0 2019-08-08 stsp -----------------------------------------------
233 2e1f37b0 2019-08-08 stsp M numbers (change 1 of 3)
234 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
235 2e1f37b0 2019-08-08 stsp -----------------------------------------------
236 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@
245 2e1f37b0 2019-08-08 stsp -----------------------------------------------
246 2e1f37b0 2019-08-08 stsp M numbers (change 2 of 3)
247 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
248 2e1f37b0 2019-08-08 stsp -----------------------------------------------
249 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
255 2e1f37b0 2019-08-08 stsp -----------------------------------------------
256 2e1f37b0 2019-08-08 stsp M numbers (change 3 of 3)
257 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
259 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
261 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
262 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
263 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
267 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
268 2e1f37b0 2019-08-08 stsp echo " M numbers" > $testroot/stdout.expected
269 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
271 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
272 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
273 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
277 2e1f37b0 2019-08-08 stsp # unstage middle hunk
278 2e1f37b0 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
279 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
280 2e1f37b0 2019-08-08 stsp numbers > $testroot/stdout)
282 2e1f37b0 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
283 2e1f37b0 2019-08-08 stsp -----------------------------------------------
284 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
291 2e1f37b0 2019-08-08 stsp -----------------------------------------------
292 2e1f37b0 2019-08-08 stsp M numbers (change 1 of 3)
293 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
294 2e1f37b0 2019-08-08 stsp -----------------------------------------------
295 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@
304 2e1f37b0 2019-08-08 stsp -----------------------------------------------
305 2e1f37b0 2019-08-08 stsp M numbers (change 2 of 3)
306 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
307 2e1f37b0 2019-08-08 stsp -----------------------------------------------
308 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
314 2e1f37b0 2019-08-08 stsp -----------------------------------------------
315 2e1f37b0 2019-08-08 stsp M numbers (change 3 of 3)
316 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
319 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
321 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
322 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
323 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
327 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
328 2e1f37b0 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
329 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
331 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
332 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
333 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
337 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
339 8469d821 2022-06-25 stsp echo "diff -s $testroot/wt" > $testroot/stdout.expected
340 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
341 8469d821 2022-06-25 stsp echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
342 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
343 2e1f37b0 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
344 2e1f37b0 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
345 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
346 2e1f37b0 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
347 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
348 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
349 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
350 2e1f37b0 2019-08-08 stsp --- numbers
351 2e1f37b0 2019-08-08 stsp +++ numbers
352 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
359 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
366 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
368 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
369 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
370 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
374 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
375 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
376 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
377 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
378 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
379 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
380 4ce46740 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
381 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
382 2e1f37b0 2019-08-08 stsp echo "file + numbers" >> $testroot/stdout.expected
383 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
384 2e1f37b0 2019-08-08 stsp --- numbers
385 2e1f37b0 2019-08-08 stsp +++ numbers
386 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@ a
396 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
398 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
399 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
400 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
404 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage >/dev/null)
406 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
407 2e1f37b0 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
408 2e1f37b0 2019-08-08 stsp test_done "$testroot" "1"
412 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
413 2e1f37b0 2019-08-08 stsp echo " M numbers" > $testroot/stdout.expected
414 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
416 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
417 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
418 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
422 2e1f37b0 2019-08-08 stsp # unstage last hunk
423 2e1f37b0 2019-08-08 stsp printf "n\nn\ny\n" > $testroot/patchscript
424 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
425 2e1f37b0 2019-08-08 stsp numbers > $testroot/stdout)
427 2e1f37b0 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
428 2e1f37b0 2019-08-08 stsp -----------------------------------------------
429 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
436 2e1f37b0 2019-08-08 stsp -----------------------------------------------
437 2e1f37b0 2019-08-08 stsp M numbers (change 1 of 3)
438 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
439 2e1f37b0 2019-08-08 stsp -----------------------------------------------
440 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@
449 2e1f37b0 2019-08-08 stsp -----------------------------------------------
450 2e1f37b0 2019-08-08 stsp M numbers (change 2 of 3)
451 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
452 2e1f37b0 2019-08-08 stsp -----------------------------------------------
453 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
459 2e1f37b0 2019-08-08 stsp -----------------------------------------------
460 2e1f37b0 2019-08-08 stsp M numbers (change 3 of 3)
461 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
464 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
466 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
467 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
468 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
472 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
473 2e1f37b0 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
474 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
476 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
477 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
478 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
482 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
484 8469d821 2022-06-25 stsp echo "diff -s $testroot/wt" > $testroot/stdout.expected
485 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
486 8469d821 2022-06-25 stsp echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
487 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
488 2e1f37b0 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
489 2e1f37b0 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
490 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
491 2e1f37b0 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
492 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
493 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
494 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
495 2e1f37b0 2019-08-08 stsp --- numbers
496 2e1f37b0 2019-08-08 stsp +++ numbers
497 2e1f37b0 2019-08-08 stsp @@ -1,10 +1,10 @@
511 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
513 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
514 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
515 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
519 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
520 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
521 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
522 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
523 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
524 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
525 4ce46740 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
526 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
527 2e1f37b0 2019-08-08 stsp echo "file + numbers" >> $testroot/stdout.expected
528 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
529 2e1f37b0 2019-08-08 stsp --- numbers
530 2e1f37b0 2019-08-08 stsp +++ numbers
531 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@ b
538 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
540 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
541 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
542 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
546 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage >/dev/null)
548 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
549 2e1f37b0 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
550 2e1f37b0 2019-08-08 stsp test_done "$testroot" "1"
554 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
555 2e1f37b0 2019-08-08 stsp echo " M numbers" > $testroot/stdout.expected
556 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
558 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
559 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
560 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
564 2e1f37b0 2019-08-08 stsp # unstage all hunks
565 2e1f37b0 2019-08-08 stsp printf "y\ny\ny\n" > $testroot/patchscript
566 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
567 2e1f37b0 2019-08-08 stsp numbers > $testroot/stdout)
569 2e1f37b0 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
570 2e1f37b0 2019-08-08 stsp -----------------------------------------------
571 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
578 2e1f37b0 2019-08-08 stsp -----------------------------------------------
579 2e1f37b0 2019-08-08 stsp M numbers (change 1 of 3)
580 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
581 2e1f37b0 2019-08-08 stsp -----------------------------------------------
582 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@
591 2e1f37b0 2019-08-08 stsp -----------------------------------------------
592 2e1f37b0 2019-08-08 stsp M numbers (change 2 of 3)
593 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
594 2e1f37b0 2019-08-08 stsp -----------------------------------------------
595 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
601 2e1f37b0 2019-08-08 stsp -----------------------------------------------
602 2e1f37b0 2019-08-08 stsp M numbers (change 3 of 3)
603 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
606 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
608 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
609 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
610 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
614 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
615 2e1f37b0 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
616 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
618 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
619 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
620 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
624 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
625 2e1f37b0 2019-08-08 stsp echo -n > $testroot/stdout.expected
626 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
628 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
629 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
630 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
634 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
636 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
637 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
638 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
639 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
640 2e1f37b0 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
641 2e1f37b0 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
642 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
643 2e1f37b0 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
644 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
645 2e1f37b0 2019-08-08 stsp --- numbers
646 2e1f37b0 2019-08-08 stsp +++ numbers
647 2e1f37b0 2019-08-08 stsp @@ -1,10 +1,10 @@
660 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
667 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
669 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
670 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
672 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
676 f6cae3ed 2020-09-13 naddy test_unstage_patch_added() {
677 2e1f37b0 2019-08-08 stsp local testroot=`test_init unstage_patch_added`
678 2e1f37b0 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
680 2e1f37b0 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
682 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
683 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
687 2e1f37b0 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
688 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
690 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
692 2e1f37b0 2019-08-08 stsp printf "y\n" > $testroot/patchscript
693 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
694 2e1f37b0 2019-08-08 stsp epsilon/new > $testroot/stdout)
696 2e1f37b0 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
697 2e1f37b0 2019-08-08 stsp echo "unstage this addition? [y/n] y" >> $testroot/stdout.expected
698 2e1f37b0 2019-08-08 stsp echo "G epsilon/new" >> $testroot/stdout.expected
699 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
701 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
702 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
703 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
707 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
708 2e1f37b0 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
709 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
711 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
712 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
713 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
717 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
718 2e1f37b0 2019-08-08 stsp echo -n > $testroot/stdout.expected
719 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
721 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
722 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
723 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
727 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
729 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
730 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
731 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
732 2e1f37b0 2019-08-08 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
733 2ad87fff 2022-09-23 stsp echo 'file + epsilon/new (mode 644)' >> $testroot/stdout.expected
734 1cb46f00 2020-11-21 stsp echo "--- /dev/null" >> $testroot/stdout.expected
735 2e1f37b0 2019-08-08 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
736 2e1f37b0 2019-08-08 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
737 2e1f37b0 2019-08-08 stsp echo "+new" >> $testroot/stdout.expected
738 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
740 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
741 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
743 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
746 f6cae3ed 2020-09-13 naddy test_unstage_patch_removed() {
747 2e1f37b0 2019-08-08 stsp local testroot=`test_init unstage_patch_removed`
748 2e1f37b0 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
750 2e1f37b0 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
752 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
753 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
757 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
758 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
760 2e1f37b0 2019-08-08 stsp printf "y\n" > $testroot/patchscript
761 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
762 2e1f37b0 2019-08-08 stsp beta > $testroot/stdout)
764 2e1f37b0 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
765 2e1f37b0 2019-08-08 stsp echo "unstage this deletion? [y/n] y" >> $testroot/stdout.expected
766 2e1f37b0 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
767 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
769 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
770 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
771 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
775 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
776 2e1f37b0 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
777 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
779 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
780 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
781 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
785 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
786 2e1f37b0 2019-08-08 stsp echo -n > $testroot/stdout.expected
787 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
789 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
790 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
791 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
795 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
797 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
798 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
799 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
800 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
801 2e1f37b0 2019-08-08 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
802 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
803 2e1f37b0 2019-08-08 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
804 2e1f37b0 2019-08-08 stsp echo "--- beta" >> $testroot/stdout.expected
805 1cb46f00 2020-11-21 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
806 2e1f37b0 2019-08-08 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
807 2e1f37b0 2019-08-08 stsp echo "-beta" >> $testroot/stdout.expected
808 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
810 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
811 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
813 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
816 f6cae3ed 2020-09-13 naddy test_unstage_patch_quit() {
817 19e4b907 2019-08-08 stsp local testroot=`test_init unstage_patch_quit`
819 19e4b907 2019-08-08 stsp jot 16 > $testroot/repo/numbers
820 19e4b907 2019-08-08 stsp echo zzz > $testroot/repo/zzz
821 19e4b907 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
822 19e4b907 2019-08-08 stsp git_commit $testroot/repo -m "added files"
823 19e4b907 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
825 19e4b907 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
827 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
828 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
832 19e4b907 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
833 19e4b907 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
834 19e4b907 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
835 19e4b907 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
836 19e4b907 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
838 19e4b907 2019-08-08 stsp # unstage first hunk and quit; and don't pass a path argument to
839 19e4b907 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
840 19e4b907 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
841 19e4b907 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
842 19e4b907 2019-08-08 stsp > $testroot/stdout)
844 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
845 57ba6a8b 2019-08-08 stsp echo "got unstage command failed unexpectedly" >&2
846 19e4b907 2019-08-08 stsp test_done "$testroot" "1"
849 19e4b907 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
850 19e4b907 2019-08-08 stsp -----------------------------------------------
851 19e4b907 2019-08-08 stsp @@ -1,5 +1,5 @@
858 19e4b907 2019-08-08 stsp -----------------------------------------------
859 19e4b907 2019-08-08 stsp M numbers (change 1 of 3)
860 19e4b907 2019-08-08 stsp unstage this change? [y/n/q] y
861 19e4b907 2019-08-08 stsp -----------------------------------------------
862 19e4b907 2019-08-08 stsp @@ -4,7 +4,7 @@
871 19e4b907 2019-08-08 stsp -----------------------------------------------
872 19e4b907 2019-08-08 stsp M numbers (change 2 of 3)
873 19e4b907 2019-08-08 stsp unstage this change? [y/n/q] q
876 19e4b907 2019-08-08 stsp unstage this deletion? [y/n] n
878 19e4b907 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
880 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
881 19e4b907 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
882 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
886 19e4b907 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
887 19e4b907 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
888 19e4b907 2019-08-08 stsp echo " D zzz" >> $testroot/stdout.expected
889 19e4b907 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
891 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
892 19e4b907 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
893 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
897 19e4b907 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
899 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
900 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
901 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
902 19e4b907 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
903 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
904 4ce46740 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
905 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
906 19e4b907 2019-08-08 stsp echo "file + numbers" >> $testroot/stdout.expected
907 19e4b907 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
908 19e4b907 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
909 19e4b907 2019-08-08 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
910 19e4b907 2019-08-08 stsp echo " 1" >> $testroot/stdout.expected
911 19e4b907 2019-08-08 stsp echo "-2" >> $testroot/stdout.expected
912 19e4b907 2019-08-08 stsp echo "+a" >> $testroot/stdout.expected
913 19e4b907 2019-08-08 stsp echo " 3" >> $testroot/stdout.expected
914 19e4b907 2019-08-08 stsp echo " 4" >> $testroot/stdout.expected
915 19e4b907 2019-08-08 stsp echo " 5" >> $testroot/stdout.expected
916 19e4b907 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
918 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
919 19e4b907 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
920 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
924 19e4b907 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
925 8469d821 2022-06-25 stsp echo "diff -s $testroot/wt" > $testroot/stdout.expected
926 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
927 8469d821 2022-06-25 stsp echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
928 19e4b907 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
929 19e4b907 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
930 19e4b907 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
931 19e4b907 2019-08-08 stsp >> $testroot/stdout.expected
932 19e4b907 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
933 19e4b907 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
934 19e4b907 2019-08-08 stsp >> $testroot/stdout.expected
935 19e4b907 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
936 19e4b907 2019-08-08 stsp --- numbers
937 19e4b907 2019-08-08 stsp +++ numbers
938 19e4b907 2019-08-08 stsp @@ -4,7 +4,7 @@
947 19e4b907 2019-08-08 stsp @@ -13,4 +13,4 @@
954 19e4b907 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
955 19e4b907 2019-08-08 stsp got tree -r $testroot/repo -i | grep 'zzz$' | cut -d' ' -f 1 \
956 19e4b907 2019-08-08 stsp >> $testroot/stdout.expected
957 19e4b907 2019-08-08 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
958 19e4b907 2019-08-08 stsp echo "--- zzz" >> $testroot/stdout.expected
959 19e4b907 2019-08-08 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
960 19e4b907 2019-08-08 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
961 19e4b907 2019-08-08 stsp echo "-zzz" >> $testroot/stdout.expected
962 19e4b907 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
964 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
965 19e4b907 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
967 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
970 f6cae3ed 2020-09-13 naddy test_unstage_symlink() {
971 ea7786be 2020-07-23 stsp local testroot=`test_init unstage_symlink`
973 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
974 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
975 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
976 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
977 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
978 ea7786be 2020-07-23 stsp (cd $testroot/repo && git add .)
979 ea7786be 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
980 ea7786be 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
982 ea7786be 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
984 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
985 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
989 ea7786be 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
990 ea7786be 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
991 ea7786be 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
992 ea7786be 2020-07-23 stsp echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
993 ea7786be 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
994 ea7786be 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
995 ea7786be 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
996 ea7786be 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
997 ea7786be 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
998 ea7786be 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
1000 35213c7c 2020-07-23 stsp (cd $testroot/wt && got stage -S > /dev/null)
1002 ea7786be 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1003 ea7786be 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1004 ea7786be 2020-07-23 stsp M alpha.link
1005 ea7786be 2020-07-23 stsp A dotgotbar.link
1006 ea7786be 2020-07-23 stsp A dotgotfoo.link
1007 ea7786be 2020-07-23 stsp M epsilon/beta.link
1008 ea7786be 2020-07-23 stsp M epsilon.link
1009 ea7786be 2020-07-23 stsp D nonexistent.link
1010 ea7786be 2020-07-23 stsp A zeta.link
1012 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1014 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1015 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1016 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1020 ea7786be 2020-07-23 stsp (cd $testroot/wt && got unstage > $testroot/stdout)
1022 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1023 ea7786be 2020-07-23 stsp echo "got unstage command failed unexpectedly" >&2
1024 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1028 ea7786be 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1029 ea7786be 2020-07-23 stsp G alpha.link
1030 ea7786be 2020-07-23 stsp G dotgotbar.link
1031 ea7786be 2020-07-23 stsp G dotgotfoo.link
1032 ea7786be 2020-07-23 stsp G epsilon/beta.link
1033 ea7786be 2020-07-23 stsp G epsilon.link
1034 ea7786be 2020-07-23 stsp D nonexistent.link
1035 ea7786be 2020-07-23 stsp G zeta.link
1038 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1040 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1041 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1042 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1046 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/alpha.link ]; then
1047 ea7786be 2020-07-23 stsp echo "alpha.link is not a symlink"
1048 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1052 ea7786be 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1053 ea7786be 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
1054 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1056 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1057 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1058 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1062 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/epsilon.link ]; then
1063 ea7786be 2020-07-23 stsp echo "epsilon.link is not a symlink"
1064 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1068 ea7786be 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1069 ea7786be 2020-07-23 stsp echo "gamma" > $testroot/stdout.expected
1070 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1072 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1073 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1074 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1078 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/epsilon/beta.link ]; then
1079 ea7786be 2020-07-23 stsp echo "epsilon/beta.link is not a symlink"
1080 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1084 ea7786be 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1085 ea7786be 2020-07-23 stsp echo "../gamma/delta" > $testroot/stdout.expected
1086 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1088 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1089 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1090 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1094 ea7786be 2020-07-23 stsp if [ ! -f $testroot/wt/dotgotfoo.link ]; then
1095 ea7786be 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
1096 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1100 ea7786be 2020-07-23 stsp echo "this is regular file foo" > $testroot/content.expected
1101 ea7786be 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
1102 ea7786be 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1104 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1105 ea7786be 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1106 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1110 ea7786be 2020-07-23 stsp # bad symlinks are allowed as-is for commit and stage/unstage
1111 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
1112 ea7786be 2020-07-23 stsp echo "dotgotbar.link is not a symlink"
1113 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1117 ea7786be 2020-07-23 stsp readlink $testroot/wt/dotgotbar.link > $testroot/stdout
1118 ea7786be 2020-07-23 stsp echo ".got/bar" > $testroot/stdout.expected
1119 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1121 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1122 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1123 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1127 ea7786be 2020-07-23 stsp if [ -e $testroot/wt/nonexistent.link ]; then
1128 ea7786be 2020-07-23 stsp echo "nonexistent.link exists on disk"
1129 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1133 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/zeta.link ]; then
1134 ea7786be 2020-07-23 stsp echo "zeta.link is not a symlink"
1135 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1139 ea7786be 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
1140 ea7786be 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
1141 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1143 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1144 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1145 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1149 ea7786be 2020-07-23 stsp test_done "$testroot" "0"
1152 f6cae3ed 2020-09-13 naddy test_unstage_patch_symlink() {
1153 36bf999c 2020-07-23 stsp local testroot=`test_init unstage_patch_symlink`
1155 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1156 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1157 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1158 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1159 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1160 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1161 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta2.link)
1162 36bf999c 2020-07-23 stsp (cd $testroot/repo && git add .)
1163 36bf999c 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1164 36bf999c 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
1166 36bf999c 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1168 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1169 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1173 36bf999c 2020-07-23 stsp # symlink to file A now points to file B
1174 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1175 36bf999c 2020-07-23 stsp # symlink to a directory A now points to file B
1176 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sfh beta epsilon.link)
1177 36bf999c 2020-07-23 stsp # "bad" symlink now contains a different target path
1178 36bf999c 2020-07-23 stsp echo "foo" > $testroot/wt/passwd.link
1179 36bf999c 2020-07-23 stsp # relative symlink to directory A now points to relative directory B
1180 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
1181 36bf999c 2020-07-23 stsp # an unversioned symlink
1182 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1183 36bf999c 2020-07-23 stsp # symlink to file A now points to non-existent file B
1184 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1185 36bf999c 2020-07-23 stsp # removed symlink
1186 36bf999c 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
1187 36bf999c 2020-07-23 stsp (cd $testroot/wt && got rm zeta2.link > /dev/null)
1188 36bf999c 2020-07-23 stsp # added symlink
1189 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
1190 36bf999c 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1191 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf beta zeta3.link)
1192 36bf999c 2020-07-23 stsp (cd $testroot/wt && got add zeta3.link > /dev/null)
1194 36bf999c 2020-07-23 stsp (cd $testroot/wt && got stage -S > /dev/null)
1196 36bf999c 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1197 36bf999c 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1198 36bf999c 2020-07-23 stsp M alpha.link
1199 36bf999c 2020-07-23 stsp ? dotgotfoo.link
1200 36bf999c 2020-07-23 stsp M epsilon/beta.link
1201 36bf999c 2020-07-23 stsp M epsilon.link
1202 36bf999c 2020-07-23 stsp A new.link
1203 36bf999c 2020-07-23 stsp M nonexistent.link
1204 36bf999c 2020-07-23 stsp M passwd.link
1205 36bf999c 2020-07-23 stsp D zeta.link
1206 36bf999c 2020-07-23 stsp D zeta2.link
1207 36bf999c 2020-07-23 stsp A zeta3.link
1209 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1211 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1212 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1213 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1217 36bf999c 2020-07-23 stsp printf "y\nn\ny\nn\ny\ny\nn\ny\ny\n" > $testroot/patchscript
1218 36bf999c 2020-07-23 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
1219 36bf999c 2020-07-23 stsp > $testroot/stdout)
1221 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1222 36bf999c 2020-07-23 stsp echo "got unstage command failed unexpectedly" >&2
1223 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1227 36bf999c 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1228 36bf999c 2020-07-23 stsp -----------------------------------------------
1229 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1231 36bf999c 2020-07-23 stsp \ No newline at end of file
1232 36bf999c 2020-07-23 stsp +gamma/delta
1233 36bf999c 2020-07-23 stsp \ No newline at end of file
1234 36bf999c 2020-07-23 stsp -----------------------------------------------
1235 36bf999c 2020-07-23 stsp M alpha.link (change 1 of 1)
1236 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] y
1237 36bf999c 2020-07-23 stsp G alpha.link
1238 36bf999c 2020-07-23 stsp -----------------------------------------------
1239 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1241 36bf999c 2020-07-23 stsp \ No newline at end of file
1243 36bf999c 2020-07-23 stsp \ No newline at end of file
1244 36bf999c 2020-07-23 stsp -----------------------------------------------
1245 36bf999c 2020-07-23 stsp M epsilon/beta.link (change 1 of 1)
1246 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] n
1247 36bf999c 2020-07-23 stsp -----------------------------------------------
1248 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1250 36bf999c 2020-07-23 stsp \ No newline at end of file
1252 36bf999c 2020-07-23 stsp \ No newline at end of file
1253 36bf999c 2020-07-23 stsp -----------------------------------------------
1254 36bf999c 2020-07-23 stsp M epsilon.link (change 1 of 1)
1255 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] y
1256 36bf999c 2020-07-23 stsp G epsilon.link
1257 36bf999c 2020-07-23 stsp A new.link
1258 36bf999c 2020-07-23 stsp unstage this addition? [y/n] n
1259 36bf999c 2020-07-23 stsp -----------------------------------------------
1260 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1261 36bf999c 2020-07-23 stsp -nonexistent
1262 36bf999c 2020-07-23 stsp \ No newline at end of file
1263 36bf999c 2020-07-23 stsp +nonexistent2
1264 36bf999c 2020-07-23 stsp \ No newline at end of file
1265 36bf999c 2020-07-23 stsp -----------------------------------------------
1266 36bf999c 2020-07-23 stsp M nonexistent.link (change 1 of 1)
1267 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] y
1268 36bf999c 2020-07-23 stsp G nonexistent.link
1269 36bf999c 2020-07-23 stsp -----------------------------------------------
1270 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1271 36bf999c 2020-07-23 stsp -/etc/passwd
1272 36bf999c 2020-07-23 stsp \ No newline at end of file
1274 36bf999c 2020-07-23 stsp -----------------------------------------------
1275 36bf999c 2020-07-23 stsp M passwd.link (change 1 of 1)
1276 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] y
1277 36bf999c 2020-07-23 stsp G passwd.link
1278 36bf999c 2020-07-23 stsp D zeta.link
1279 36bf999c 2020-07-23 stsp unstage this deletion? [y/n] n
1280 36bf999c 2020-07-23 stsp D zeta2.link
1281 36bf999c 2020-07-23 stsp unstage this deletion? [y/n] y
1282 36bf999c 2020-07-23 stsp D zeta2.link
1283 36bf999c 2020-07-23 stsp A zeta3.link
1284 36bf999c 2020-07-23 stsp unstage this addition? [y/n] y
1285 36bf999c 2020-07-23 stsp G zeta3.link
1287 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1289 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1290 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1291 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1295 36bf999c 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1296 36bf999c 2020-07-23 stsp echo "alpha.link is not a symlink"
1297 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1301 36bf999c 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1302 36bf999c 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
1303 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1305 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1306 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1307 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1311 36bf999c 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1312 36bf999c 2020-07-23 stsp echo "epsilon.link is not a symlink"
1313 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1317 36bf999c 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1318 36bf999c 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
1319 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1321 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1322 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1323 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1327 36bf999c 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1328 36bf999c 2020-07-23 stsp echo "passwd.link should not be a symlink" >&2
1329 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1333 36bf999c 2020-07-23 stsp echo "foo" > $testroot/content.expected
1334 36bf999c 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1336 36bf999c 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1338 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1339 36bf999c 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1340 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1344 36bf999c 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1345 36bf999c 2020-07-23 stsp echo "../gamma" > $testroot/stdout.expected
1346 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1348 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1349 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1350 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1354 36bf999c 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1355 36bf999c 2020-07-23 stsp echo "nonexistent2" > $testroot/stdout.expected
1356 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1358 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1359 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1360 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1364 36bf999c 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1365 36bf999c 2020-07-23 stsp echo "dotgotfoo.link is not a symlink " >&2
1366 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1369 36bf999c 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1370 36bf999c 2020-07-23 stsp echo ".got/foo" > $testroot/stdout.expected
1371 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1373 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1374 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1375 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1380 36bf999c 2020-07-23 stsp if [ -e $testroot/wt/zeta.link ]; then
1381 36bf999c 2020-07-23 stsp echo -n "zeta.link should not exist on disk" >&2
1382 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1386 36bf999c 2020-07-23 stsp if [ -e $testroot/wt/zeta2.link ]; then
1387 36bf999c 2020-07-23 stsp echo -n "zeta2.link exists on disk" >&2
1388 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1392 36bf999c 2020-07-23 stsp if [ ! -h $testroot/wt/zeta3.link ]; then
1393 36bf999c 2020-07-23 stsp echo -n "zeta3.link is not a symlink" >&2
1394 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1398 36bf999c 2020-07-23 stsp readlink $testroot/wt/zeta3.link > $testroot/stdout
1399 36bf999c 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
1400 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1402 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1403 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1404 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1408 36bf999c 2020-07-23 stsp if [ ! -h $testroot/wt/new.link ]; then
1409 36bf999c 2020-07-23 stsp echo -n "new.link is not a symlink" >&2
1410 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1414 36bf999c 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1415 36bf999c 2020-07-23 stsp echo "M alpha.link" > $testroot/stdout.expected
1416 36bf999c 2020-07-23 stsp echo "? dotgotfoo.link" >> $testroot/stdout.expected
1417 36bf999c 2020-07-23 stsp echo " M epsilon/beta.link" >> $testroot/stdout.expected
1418 36bf999c 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1419 36bf999c 2020-07-23 stsp echo " A new.link" >> $testroot/stdout.expected
1420 36bf999c 2020-07-23 stsp echo "M nonexistent.link" >> $testroot/stdout.expected
1421 36bf999c 2020-07-23 stsp echo "M passwd.link" >> $testroot/stdout.expected
1422 36bf999c 2020-07-23 stsp echo " D zeta.link" >> $testroot/stdout.expected
1423 36bf999c 2020-07-23 stsp echo "D zeta2.link" >> $testroot/stdout.expected
1424 36bf999c 2020-07-23 stsp echo "A zeta3.link" >> $testroot/stdout.expected
1425 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1427 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1428 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1431 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1434 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1435 ad493afc 2019-08-03 stsp run_test test_unstage_basic
1436 8b13ce36 2019-08-08 stsp run_test test_unstage_unversioned
1437 8564cb21 2019-08-08 stsp run_test test_unstage_nonexistent
1438 2e1f37b0 2019-08-08 stsp run_test test_unstage_patch
1439 2e1f37b0 2019-08-08 stsp run_test test_unstage_patch_added
1440 2e1f37b0 2019-08-08 stsp run_test test_unstage_patch_removed
1441 19e4b907 2019-08-08 stsp run_test test_unstage_patch_quit
1442 ea7786be 2020-07-23 stsp run_test test_unstage_symlink
1443 36bf999c 2020-07-23 stsp run_test test_unstage_patch_symlink