Blame


1 ad493afc 2019-08-03 stsp #!/bin/sh
2 ad493afc 2019-08-03 stsp #
3 ad493afc 2019-08-03 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 ad493afc 2019-08-03 stsp #
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.
8 ad493afc 2019-08-03 stsp #
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.
16 ad493afc 2019-08-03 stsp
17 ad493afc 2019-08-03 stsp . ./common.sh
18 ad493afc 2019-08-03 stsp
19 f6cae3ed 2020-09-13 naddy test_unstage_basic() {
20 ad493afc 2019-08-03 stsp local testroot=`test_init unstage_basic`
21 ad493afc 2019-08-03 stsp
22 ad493afc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 49c543a6 2022-03-31 naddy ret=$?
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 ad493afc 2019-08-03 stsp test_done "$testroot" "$ret"
26 ad493afc 2019-08-03 stsp return 1
27 ad493afc 2019-08-03 stsp fi
28 ad493afc 2019-08-03 stsp
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)
33 ad493afc 2019-08-03 stsp
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)
38 ad493afc 2019-08-03 stsp
39 ad493afc 2019-08-03 stsp (cd $testroot/wt && got unstage > $testroot/stdout)
40 49c543a6 2022-03-31 naddy ret=$?
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"
44 ad493afc 2019-08-03 stsp return 1
45 ad493afc 2019-08-03 stsp fi
46 ad493afc 2019-08-03 stsp
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
51 49c543a6 2022-03-31 naddy ret=$?
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"
55 ad493afc 2019-08-03 stsp return 1
56 ad493afc 2019-08-03 stsp fi
57 ad493afc 2019-08-03 stsp
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 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
62 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
63 49c543a6 2022-03-31 naddy ret=$?
64 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
65 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
66 2e1f37b0 2019-08-08 stsp fi
67 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
68 2e1f37b0 2019-08-08 stsp }
69 2e1f37b0 2019-08-08 stsp
70 f6cae3ed 2020-09-13 naddy test_unstage_unversioned() {
71 8b13ce36 2019-08-08 stsp local testroot=`test_init unstage_unversioned`
72 8b13ce36 2019-08-08 stsp
73 8b13ce36 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
74 49c543a6 2022-03-31 naddy ret=$?
75 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
76 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
77 8b13ce36 2019-08-08 stsp return 1
78 8b13ce36 2019-08-08 stsp fi
79 8b13ce36 2019-08-08 stsp
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)
84 8b13ce36 2019-08-08 stsp
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)
89 8b13ce36 2019-08-08 stsp
90 8b13ce36 2019-08-08 stsp touch $testroot/wt/unversioned-file
91 8b13ce36 2019-08-08 stsp
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
98 49c543a6 2022-03-31 naddy ret=$?
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"
102 8b13ce36 2019-08-08 stsp return 1
103 8b13ce36 2019-08-08 stsp fi
104 8b13ce36 2019-08-08 stsp
105 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got unstage > $testroot/stdout)
106 49c543a6 2022-03-31 naddy ret=$?
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"
110 8b13ce36 2019-08-08 stsp return 1
111 8b13ce36 2019-08-08 stsp fi
112 8b13ce36 2019-08-08 stsp
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
117 49c543a6 2022-03-31 naddy ret=$?
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"
121 8b13ce36 2019-08-08 stsp return 1
122 8b13ce36 2019-08-08 stsp fi
123 8b13ce36 2019-08-08 stsp
124 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
125 8b13ce36 2019-08-08 stsp
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)
128 49c543a6 2022-03-31 naddy ret=$?
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"
132 8b13ce36 2019-08-08 stsp return 1
133 8b13ce36 2019-08-08 stsp fi
134 8b13ce36 2019-08-08 stsp
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
141 49c543a6 2022-03-31 naddy ret=$?
142 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
143 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
144 8b13ce36 2019-08-08 stsp fi
145 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
146 8b13ce36 2019-08-08 stsp }
147 8b13ce36 2019-08-08 stsp
148 f6cae3ed 2020-09-13 naddy test_unstage_nonexistent() {
149 8564cb21 2019-08-08 stsp local testroot=`test_init unstage_nonexistent`
150 8564cb21 2019-08-08 stsp
151 8564cb21 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
152 49c543a6 2022-03-31 naddy ret=$?
153 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
154 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
155 8564cb21 2019-08-08 stsp return 1
156 8564cb21 2019-08-08 stsp fi
157 8564cb21 2019-08-08 stsp
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)
162 8564cb21 2019-08-08 stsp
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)
167 8564cb21 2019-08-08 stsp
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)
170 49c543a6 2022-03-31 naddy ret=$?
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"
174 8564cb21 2019-08-08 stsp return 1
175 8564cb21 2019-08-08 stsp fi
176 8564cb21 2019-08-08 stsp
177 8564cb21 2019-08-08 stsp echo -n > $testroot/stdout.expected
178 8564cb21 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
179 49c543a6 2022-03-31 naddy ret=$?
180 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
181 8564cb21 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
182 8564cb21 2019-08-08 stsp fi
183 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
184 8564cb21 2019-08-08 stsp }
185 8564cb21 2019-08-08 stsp
186 f6cae3ed 2020-09-13 naddy test_unstage_patch() {
187 2e1f37b0 2019-08-08 stsp local testroot=`test_init unstage_patch`
188 2e1f37b0 2019-08-08 stsp
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`
193 2e1f37b0 2019-08-08 stsp
194 2e1f37b0 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
195 49c543a6 2022-03-31 naddy ret=$?
196 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
197 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
198 2e1f37b0 2019-08-08 stsp return 1
199 2e1f37b0 2019-08-08 stsp fi
200 2e1f37b0 2019-08-08 stsp
201 885e96df 2023-03-06 naddy ed -s $testroot/wt/numbers <<-\EOF
202 885e96df 2023-03-06 naddy ,s/^2$/a/
203 885e96df 2023-03-06 naddy ,s/^7$/b/
204 885e96df 2023-03-06 naddy ,s/^16$/c/
205 885e96df 2023-03-06 naddy w
206 885e96df 2023-03-06 naddy EOF
207 2e1f37b0 2019-08-08 stsp
208 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
209 49c543a6 2022-03-31 naddy ret=$?
210 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
211 2e1f37b0 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
212 2e1f37b0 2019-08-08 stsp test_done "$testroot" "1"
213 2e1f37b0 2019-08-08 stsp return 1
214 2e1f37b0 2019-08-08 stsp fi
215 2e1f37b0 2019-08-08 stsp
216 2e1f37b0 2019-08-08 stsp # don't unstage any hunks
217 2e1f37b0 2019-08-08 stsp printf "n\nn\nn\n" > $testroot/patchscript
218 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
219 2e1f37b0 2019-08-08 stsp numbers > $testroot/stdout)
220 49c543a6 2022-03-31 naddy ret=$?
221 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
222 57ba6a8b 2019-08-08 stsp echo "got unstage command failed unexpectedly" >&2
223 2e1f37b0 2019-08-08 stsp test_done "$testroot" "1"
224 2e1f37b0 2019-08-08 stsp return 1
225 2e1f37b0 2019-08-08 stsp fi
226 2e1f37b0 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
227 2e1f37b0 2019-08-08 stsp -----------------------------------------------
228 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
229 2e1f37b0 2019-08-08 stsp 1
230 2e1f37b0 2019-08-08 stsp -2
231 2e1f37b0 2019-08-08 stsp +a
232 2e1f37b0 2019-08-08 stsp 3
233 2e1f37b0 2019-08-08 stsp 4
234 2e1f37b0 2019-08-08 stsp 5
235 2e1f37b0 2019-08-08 stsp -----------------------------------------------
236 2e1f37b0 2019-08-08 stsp M numbers (change 1 of 3)
237 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
238 2e1f37b0 2019-08-08 stsp -----------------------------------------------
239 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@
240 2e1f37b0 2019-08-08 stsp 4
241 2e1f37b0 2019-08-08 stsp 5
242 2e1f37b0 2019-08-08 stsp 6
243 2e1f37b0 2019-08-08 stsp -7
244 2e1f37b0 2019-08-08 stsp +b
245 2e1f37b0 2019-08-08 stsp 8
246 2e1f37b0 2019-08-08 stsp 9
247 2e1f37b0 2019-08-08 stsp 10
248 2e1f37b0 2019-08-08 stsp -----------------------------------------------
249 2e1f37b0 2019-08-08 stsp M numbers (change 2 of 3)
250 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
251 2e1f37b0 2019-08-08 stsp -----------------------------------------------
252 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
253 2e1f37b0 2019-08-08 stsp 13
254 2e1f37b0 2019-08-08 stsp 14
255 2e1f37b0 2019-08-08 stsp 15
256 2e1f37b0 2019-08-08 stsp -16
257 2e1f37b0 2019-08-08 stsp +c
258 2e1f37b0 2019-08-08 stsp -----------------------------------------------
259 2e1f37b0 2019-08-08 stsp M numbers (change 3 of 3)
260 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
261 2e1f37b0 2019-08-08 stsp EOF
262 2e1f37b0 2019-08-08 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 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
267 2e1f37b0 2019-08-08 stsp return 1
268 2e1f37b0 2019-08-08 stsp fi
269 2e1f37b0 2019-08-08 stsp
270 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
271 2e1f37b0 2019-08-08 stsp echo " M numbers" > $testroot/stdout.expected
272 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
273 49c543a6 2022-03-31 naddy ret=$?
274 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
275 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
276 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
277 2e1f37b0 2019-08-08 stsp return 1
278 2e1f37b0 2019-08-08 stsp fi
279 2e1f37b0 2019-08-08 stsp
280 2e1f37b0 2019-08-08 stsp # unstage middle hunk
281 2e1f37b0 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
282 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
283 2e1f37b0 2019-08-08 stsp numbers > $testroot/stdout)
284 2e1f37b0 2019-08-08 stsp
285 2e1f37b0 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
286 2e1f37b0 2019-08-08 stsp -----------------------------------------------
287 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
288 2e1f37b0 2019-08-08 stsp 1
289 2e1f37b0 2019-08-08 stsp -2
290 2e1f37b0 2019-08-08 stsp +a
291 2e1f37b0 2019-08-08 stsp 3
292 2e1f37b0 2019-08-08 stsp 4
293 2e1f37b0 2019-08-08 stsp 5
294 2e1f37b0 2019-08-08 stsp -----------------------------------------------
295 2e1f37b0 2019-08-08 stsp M numbers (change 1 of 3)
296 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
297 2e1f37b0 2019-08-08 stsp -----------------------------------------------
298 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@
299 2e1f37b0 2019-08-08 stsp 4
300 2e1f37b0 2019-08-08 stsp 5
301 2e1f37b0 2019-08-08 stsp 6
302 2e1f37b0 2019-08-08 stsp -7
303 2e1f37b0 2019-08-08 stsp +b
304 2e1f37b0 2019-08-08 stsp 8
305 2e1f37b0 2019-08-08 stsp 9
306 2e1f37b0 2019-08-08 stsp 10
307 2e1f37b0 2019-08-08 stsp -----------------------------------------------
308 2e1f37b0 2019-08-08 stsp M numbers (change 2 of 3)
309 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
310 2e1f37b0 2019-08-08 stsp -----------------------------------------------
311 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
312 2e1f37b0 2019-08-08 stsp 13
313 2e1f37b0 2019-08-08 stsp 14
314 2e1f37b0 2019-08-08 stsp 15
315 2e1f37b0 2019-08-08 stsp -16
316 2e1f37b0 2019-08-08 stsp +c
317 2e1f37b0 2019-08-08 stsp -----------------------------------------------
318 2e1f37b0 2019-08-08 stsp M numbers (change 3 of 3)
319 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
320 2e1f37b0 2019-08-08 stsp G numbers
321 2e1f37b0 2019-08-08 stsp EOF
322 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
323 49c543a6 2022-03-31 naddy ret=$?
324 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
325 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
326 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
327 2e1f37b0 2019-08-08 stsp return 1
328 2e1f37b0 2019-08-08 stsp fi
329 2e1f37b0 2019-08-08 stsp
330 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
331 2e1f37b0 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
332 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
333 49c543a6 2022-03-31 naddy ret=$?
334 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
335 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
336 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
337 2e1f37b0 2019-08-08 stsp return 1
338 2e1f37b0 2019-08-08 stsp fi
339 2e1f37b0 2019-08-08 stsp
340 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
341 2e1f37b0 2019-08-08 stsp
342 8469d821 2022-06-25 stsp echo "diff -s $testroot/wt" > $testroot/stdout.expected
343 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
344 8469d821 2022-06-25 stsp echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
345 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
346 2e1f37b0 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
347 2e1f37b0 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
348 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
349 2e1f37b0 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
350 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
351 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
352 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
353 2e1f37b0 2019-08-08 stsp --- numbers
354 2e1f37b0 2019-08-08 stsp +++ numbers
355 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
356 2e1f37b0 2019-08-08 stsp 1
357 2e1f37b0 2019-08-08 stsp -2
358 2e1f37b0 2019-08-08 stsp +a
359 2e1f37b0 2019-08-08 stsp 3
360 2e1f37b0 2019-08-08 stsp 4
361 2e1f37b0 2019-08-08 stsp 5
362 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
363 2e1f37b0 2019-08-08 stsp 13
364 2e1f37b0 2019-08-08 stsp 14
365 2e1f37b0 2019-08-08 stsp 15
366 2e1f37b0 2019-08-08 stsp -16
367 2e1f37b0 2019-08-08 stsp +c
368 2e1f37b0 2019-08-08 stsp EOF
369 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
370 49c543a6 2022-03-31 naddy ret=$?
371 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
372 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
373 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
374 2e1f37b0 2019-08-08 stsp return 1
375 2e1f37b0 2019-08-08 stsp fi
376 2e1f37b0 2019-08-08 stsp
377 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
378 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
379 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
380 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
381 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
382 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
383 4ce46740 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
384 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
385 2e1f37b0 2019-08-08 stsp echo "file + numbers" >> $testroot/stdout.expected
386 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
387 2e1f37b0 2019-08-08 stsp --- numbers
388 2e1f37b0 2019-08-08 stsp +++ numbers
389 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@ a
390 2e1f37b0 2019-08-08 stsp 4
391 2e1f37b0 2019-08-08 stsp 5
392 2e1f37b0 2019-08-08 stsp 6
393 2e1f37b0 2019-08-08 stsp -7
394 2e1f37b0 2019-08-08 stsp +b
395 2e1f37b0 2019-08-08 stsp 8
396 2e1f37b0 2019-08-08 stsp 9
397 2e1f37b0 2019-08-08 stsp 10
398 2e1f37b0 2019-08-08 stsp EOF
399 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
400 49c543a6 2022-03-31 naddy ret=$?
401 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
402 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
403 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
404 2e1f37b0 2019-08-08 stsp return 1
405 2e1f37b0 2019-08-08 stsp fi
406 2e1f37b0 2019-08-08 stsp
407 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage >/dev/null)
408 49c543a6 2022-03-31 naddy ret=$?
409 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
410 2e1f37b0 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
411 2e1f37b0 2019-08-08 stsp test_done "$testroot" "1"
412 2e1f37b0 2019-08-08 stsp return 1
413 2e1f37b0 2019-08-08 stsp fi
414 2e1f37b0 2019-08-08 stsp
415 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
416 2e1f37b0 2019-08-08 stsp echo " M numbers" > $testroot/stdout.expected
417 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
418 49c543a6 2022-03-31 naddy ret=$?
419 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
420 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
421 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
422 2e1f37b0 2019-08-08 stsp return 1
423 2e1f37b0 2019-08-08 stsp fi
424 2e1f37b0 2019-08-08 stsp
425 2e1f37b0 2019-08-08 stsp # unstage last hunk
426 2e1f37b0 2019-08-08 stsp printf "n\nn\ny\n" > $testroot/patchscript
427 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
428 2e1f37b0 2019-08-08 stsp numbers > $testroot/stdout)
429 2e1f37b0 2019-08-08 stsp
430 2e1f37b0 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
431 2e1f37b0 2019-08-08 stsp -----------------------------------------------
432 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
433 2e1f37b0 2019-08-08 stsp 1
434 2e1f37b0 2019-08-08 stsp -2
435 2e1f37b0 2019-08-08 stsp +a
436 2e1f37b0 2019-08-08 stsp 3
437 2e1f37b0 2019-08-08 stsp 4
438 2e1f37b0 2019-08-08 stsp 5
439 2e1f37b0 2019-08-08 stsp -----------------------------------------------
440 2e1f37b0 2019-08-08 stsp M numbers (change 1 of 3)
441 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
442 2e1f37b0 2019-08-08 stsp -----------------------------------------------
443 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@
444 2e1f37b0 2019-08-08 stsp 4
445 2e1f37b0 2019-08-08 stsp 5
446 2e1f37b0 2019-08-08 stsp 6
447 2e1f37b0 2019-08-08 stsp -7
448 2e1f37b0 2019-08-08 stsp +b
449 2e1f37b0 2019-08-08 stsp 8
450 2e1f37b0 2019-08-08 stsp 9
451 2e1f37b0 2019-08-08 stsp 10
452 2e1f37b0 2019-08-08 stsp -----------------------------------------------
453 2e1f37b0 2019-08-08 stsp M numbers (change 2 of 3)
454 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] n
455 2e1f37b0 2019-08-08 stsp -----------------------------------------------
456 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
457 2e1f37b0 2019-08-08 stsp 13
458 2e1f37b0 2019-08-08 stsp 14
459 2e1f37b0 2019-08-08 stsp 15
460 2e1f37b0 2019-08-08 stsp -16
461 2e1f37b0 2019-08-08 stsp +c
462 2e1f37b0 2019-08-08 stsp -----------------------------------------------
463 2e1f37b0 2019-08-08 stsp M numbers (change 3 of 3)
464 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
465 2e1f37b0 2019-08-08 stsp G numbers
466 2e1f37b0 2019-08-08 stsp EOF
467 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
468 49c543a6 2022-03-31 naddy ret=$?
469 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
470 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
471 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
472 2e1f37b0 2019-08-08 stsp return 1
473 2e1f37b0 2019-08-08 stsp fi
474 2e1f37b0 2019-08-08 stsp
475 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
476 2e1f37b0 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
477 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
478 49c543a6 2022-03-31 naddy ret=$?
479 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
480 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
481 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
482 2e1f37b0 2019-08-08 stsp return 1
483 2e1f37b0 2019-08-08 stsp fi
484 2e1f37b0 2019-08-08 stsp
485 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
486 2e1f37b0 2019-08-08 stsp
487 8469d821 2022-06-25 stsp echo "diff -s $testroot/wt" > $testroot/stdout.expected
488 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
489 8469d821 2022-06-25 stsp echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
490 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
491 2e1f37b0 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
492 2e1f37b0 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
493 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
494 2e1f37b0 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
495 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
496 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
497 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
498 2e1f37b0 2019-08-08 stsp --- numbers
499 2e1f37b0 2019-08-08 stsp +++ numbers
500 2e1f37b0 2019-08-08 stsp @@ -1,10 +1,10 @@
501 2e1f37b0 2019-08-08 stsp 1
502 2e1f37b0 2019-08-08 stsp -2
503 2e1f37b0 2019-08-08 stsp +a
504 2e1f37b0 2019-08-08 stsp 3
505 2e1f37b0 2019-08-08 stsp 4
506 2e1f37b0 2019-08-08 stsp 5
507 2e1f37b0 2019-08-08 stsp 6
508 2e1f37b0 2019-08-08 stsp -7
509 2e1f37b0 2019-08-08 stsp +b
510 2e1f37b0 2019-08-08 stsp 8
511 2e1f37b0 2019-08-08 stsp 9
512 2e1f37b0 2019-08-08 stsp 10
513 2e1f37b0 2019-08-08 stsp EOF
514 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
515 49c543a6 2022-03-31 naddy ret=$?
516 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
517 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
518 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
519 2e1f37b0 2019-08-08 stsp return 1
520 2e1f37b0 2019-08-08 stsp fi
521 2e1f37b0 2019-08-08 stsp
522 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
523 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
524 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
525 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
526 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
527 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
528 4ce46740 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
529 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
530 2e1f37b0 2019-08-08 stsp echo "file + numbers" >> $testroot/stdout.expected
531 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
532 2e1f37b0 2019-08-08 stsp --- numbers
533 2e1f37b0 2019-08-08 stsp +++ numbers
534 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@ b
535 2e1f37b0 2019-08-08 stsp 13
536 2e1f37b0 2019-08-08 stsp 14
537 2e1f37b0 2019-08-08 stsp 15
538 2e1f37b0 2019-08-08 stsp -16
539 2e1f37b0 2019-08-08 stsp +c
540 2e1f37b0 2019-08-08 stsp EOF
541 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
542 49c543a6 2022-03-31 naddy ret=$?
543 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
544 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
545 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
546 2e1f37b0 2019-08-08 stsp return 1
547 2e1f37b0 2019-08-08 stsp fi
548 2e1f37b0 2019-08-08 stsp
549 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage >/dev/null)
550 49c543a6 2022-03-31 naddy ret=$?
551 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
552 2e1f37b0 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
553 2e1f37b0 2019-08-08 stsp test_done "$testroot" "1"
554 2e1f37b0 2019-08-08 stsp return 1
555 2e1f37b0 2019-08-08 stsp fi
556 2e1f37b0 2019-08-08 stsp
557 ad493afc 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
558 2e1f37b0 2019-08-08 stsp echo " M numbers" > $testroot/stdout.expected
559 ad493afc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
560 49c543a6 2022-03-31 naddy ret=$?
561 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
562 ad493afc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
563 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
564 2e1f37b0 2019-08-08 stsp return 1
565 ad493afc 2019-08-03 stsp fi
566 2e1f37b0 2019-08-08 stsp
567 2e1f37b0 2019-08-08 stsp # unstage all hunks
568 2e1f37b0 2019-08-08 stsp printf "y\ny\ny\n" > $testroot/patchscript
569 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
570 2e1f37b0 2019-08-08 stsp numbers > $testroot/stdout)
571 2e1f37b0 2019-08-08 stsp
572 2e1f37b0 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
573 2e1f37b0 2019-08-08 stsp -----------------------------------------------
574 2e1f37b0 2019-08-08 stsp @@ -1,5 +1,5 @@
575 2e1f37b0 2019-08-08 stsp 1
576 2e1f37b0 2019-08-08 stsp -2
577 2e1f37b0 2019-08-08 stsp +a
578 2e1f37b0 2019-08-08 stsp 3
579 2e1f37b0 2019-08-08 stsp 4
580 2e1f37b0 2019-08-08 stsp 5
581 2e1f37b0 2019-08-08 stsp -----------------------------------------------
582 2e1f37b0 2019-08-08 stsp M numbers (change 1 of 3)
583 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
584 2e1f37b0 2019-08-08 stsp -----------------------------------------------
585 2e1f37b0 2019-08-08 stsp @@ -4,7 +4,7 @@
586 2e1f37b0 2019-08-08 stsp 4
587 2e1f37b0 2019-08-08 stsp 5
588 2e1f37b0 2019-08-08 stsp 6
589 2e1f37b0 2019-08-08 stsp -7
590 2e1f37b0 2019-08-08 stsp +b
591 2e1f37b0 2019-08-08 stsp 8
592 2e1f37b0 2019-08-08 stsp 9
593 2e1f37b0 2019-08-08 stsp 10
594 2e1f37b0 2019-08-08 stsp -----------------------------------------------
595 2e1f37b0 2019-08-08 stsp M numbers (change 2 of 3)
596 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
597 2e1f37b0 2019-08-08 stsp -----------------------------------------------
598 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
599 2e1f37b0 2019-08-08 stsp 13
600 2e1f37b0 2019-08-08 stsp 14
601 2e1f37b0 2019-08-08 stsp 15
602 2e1f37b0 2019-08-08 stsp -16
603 2e1f37b0 2019-08-08 stsp +c
604 2e1f37b0 2019-08-08 stsp -----------------------------------------------
605 2e1f37b0 2019-08-08 stsp M numbers (change 3 of 3)
606 2e1f37b0 2019-08-08 stsp unstage this change? [y/n/q] y
607 2e1f37b0 2019-08-08 stsp G numbers
608 2e1f37b0 2019-08-08 stsp EOF
609 2e1f37b0 2019-08-08 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 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
613 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
614 2e1f37b0 2019-08-08 stsp return 1
615 2e1f37b0 2019-08-08 stsp fi
616 2e1f37b0 2019-08-08 stsp
617 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
618 2e1f37b0 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
619 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
620 49c543a6 2022-03-31 naddy ret=$?
621 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
622 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
623 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
624 2e1f37b0 2019-08-08 stsp return 1
625 2e1f37b0 2019-08-08 stsp fi
626 2e1f37b0 2019-08-08 stsp
627 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
628 2e1f37b0 2019-08-08 stsp echo -n > $testroot/stdout.expected
629 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
630 49c543a6 2022-03-31 naddy ret=$?
631 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
632 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
633 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
634 2e1f37b0 2019-08-08 stsp return 1
635 2e1f37b0 2019-08-08 stsp fi
636 2e1f37b0 2019-08-08 stsp
637 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
638 2e1f37b0 2019-08-08 stsp
639 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
640 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
641 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
642 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
643 2e1f37b0 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
644 2e1f37b0 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
645 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
646 2e1f37b0 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
647 2e1f37b0 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
648 2e1f37b0 2019-08-08 stsp --- numbers
649 2e1f37b0 2019-08-08 stsp +++ numbers
650 2e1f37b0 2019-08-08 stsp @@ -1,10 +1,10 @@
651 2e1f37b0 2019-08-08 stsp 1
652 2e1f37b0 2019-08-08 stsp -2
653 2e1f37b0 2019-08-08 stsp +a
654 2e1f37b0 2019-08-08 stsp 3
655 2e1f37b0 2019-08-08 stsp 4
656 2e1f37b0 2019-08-08 stsp 5
657 2e1f37b0 2019-08-08 stsp 6
658 2e1f37b0 2019-08-08 stsp -7
659 2e1f37b0 2019-08-08 stsp +b
660 2e1f37b0 2019-08-08 stsp 8
661 2e1f37b0 2019-08-08 stsp 9
662 2e1f37b0 2019-08-08 stsp 10
663 2e1f37b0 2019-08-08 stsp @@ -13,4 +13,4 @@
664 2e1f37b0 2019-08-08 stsp 13
665 2e1f37b0 2019-08-08 stsp 14
666 2e1f37b0 2019-08-08 stsp 15
667 2e1f37b0 2019-08-08 stsp -16
668 2e1f37b0 2019-08-08 stsp +c
669 2e1f37b0 2019-08-08 stsp EOF
670 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
671 49c543a6 2022-03-31 naddy ret=$?
672 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
673 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
674 2e1f37b0 2019-08-08 stsp fi
675 ad493afc 2019-08-03 stsp test_done "$testroot" "$ret"
676 2e1f37b0 2019-08-08 stsp
677 ad493afc 2019-08-03 stsp }
678 ad493afc 2019-08-03 stsp
679 f6cae3ed 2020-09-13 naddy test_unstage_patch_added() {
680 2e1f37b0 2019-08-08 stsp local testroot=`test_init unstage_patch_added`
681 2e1f37b0 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
682 2e1f37b0 2019-08-08 stsp
683 2e1f37b0 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
684 49c543a6 2022-03-31 naddy ret=$?
685 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
686 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
687 2e1f37b0 2019-08-08 stsp return 1
688 2e1f37b0 2019-08-08 stsp fi
689 2e1f37b0 2019-08-08 stsp
690 2e1f37b0 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
691 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
692 2e1f37b0 2019-08-08 stsp
693 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
694 2e1f37b0 2019-08-08 stsp
695 2e1f37b0 2019-08-08 stsp printf "y\n" > $testroot/patchscript
696 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
697 2e1f37b0 2019-08-08 stsp epsilon/new > $testroot/stdout)
698 2e1f37b0 2019-08-08 stsp
699 2e1f37b0 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
700 2e1f37b0 2019-08-08 stsp echo "unstage this addition? [y/n] y" >> $testroot/stdout.expected
701 2e1f37b0 2019-08-08 stsp echo "G epsilon/new" >> $testroot/stdout.expected
702 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
703 49c543a6 2022-03-31 naddy ret=$?
704 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
705 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
706 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
707 2e1f37b0 2019-08-08 stsp return 1
708 2e1f37b0 2019-08-08 stsp fi
709 2e1f37b0 2019-08-08 stsp
710 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
711 2e1f37b0 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
712 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
713 49c543a6 2022-03-31 naddy ret=$?
714 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
715 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
716 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
717 2e1f37b0 2019-08-08 stsp return 1
718 2e1f37b0 2019-08-08 stsp fi
719 2e1f37b0 2019-08-08 stsp
720 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
721 2e1f37b0 2019-08-08 stsp echo -n > $testroot/stdout.expected
722 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
723 49c543a6 2022-03-31 naddy ret=$?
724 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
725 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
726 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
727 2e1f37b0 2019-08-08 stsp return 1
728 2e1f37b0 2019-08-08 stsp fi
729 2e1f37b0 2019-08-08 stsp
730 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
731 2e1f37b0 2019-08-08 stsp
732 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
733 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
734 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
735 2e1f37b0 2019-08-08 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
736 2ad87fff 2022-09-23 stsp echo 'file + epsilon/new (mode 644)' >> $testroot/stdout.expected
737 1cb46f00 2020-11-21 stsp echo "--- /dev/null" >> $testroot/stdout.expected
738 2e1f37b0 2019-08-08 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
739 2e1f37b0 2019-08-08 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
740 2e1f37b0 2019-08-08 stsp echo "+new" >> $testroot/stdout.expected
741 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
742 49c543a6 2022-03-31 naddy ret=$?
743 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
744 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
745 2e1f37b0 2019-08-08 stsp fi
746 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
747 2e1f37b0 2019-08-08 stsp }
748 2e1f37b0 2019-08-08 stsp
749 f6cae3ed 2020-09-13 naddy test_unstage_patch_removed() {
750 2e1f37b0 2019-08-08 stsp local testroot=`test_init unstage_patch_removed`
751 2e1f37b0 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
752 2e1f37b0 2019-08-08 stsp
753 2e1f37b0 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
754 49c543a6 2022-03-31 naddy ret=$?
755 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
756 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
757 2e1f37b0 2019-08-08 stsp return 1
758 2e1f37b0 2019-08-08 stsp fi
759 2e1f37b0 2019-08-08 stsp
760 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
761 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
762 2e1f37b0 2019-08-08 stsp
763 2e1f37b0 2019-08-08 stsp printf "y\n" > $testroot/patchscript
764 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
765 2e1f37b0 2019-08-08 stsp beta > $testroot/stdout)
766 2e1f37b0 2019-08-08 stsp
767 2e1f37b0 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
768 2e1f37b0 2019-08-08 stsp echo "unstage this deletion? [y/n] y" >> $testroot/stdout.expected
769 2e1f37b0 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
770 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
771 49c543a6 2022-03-31 naddy ret=$?
772 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
773 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
774 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
775 2e1f37b0 2019-08-08 stsp return 1
776 2e1f37b0 2019-08-08 stsp fi
777 2e1f37b0 2019-08-08 stsp
778 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
779 2e1f37b0 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
780 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
781 49c543a6 2022-03-31 naddy ret=$?
782 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
783 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
784 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
785 2e1f37b0 2019-08-08 stsp return 1
786 2e1f37b0 2019-08-08 stsp fi
787 2e1f37b0 2019-08-08 stsp
788 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
789 2e1f37b0 2019-08-08 stsp echo -n > $testroot/stdout.expected
790 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
791 49c543a6 2022-03-31 naddy ret=$?
792 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
793 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
794 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
795 2e1f37b0 2019-08-08 stsp return 1
796 2e1f37b0 2019-08-08 stsp fi
797 2e1f37b0 2019-08-08 stsp
798 2e1f37b0 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
799 2e1f37b0 2019-08-08 stsp
800 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
801 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
802 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
803 2e1f37b0 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
804 2e1f37b0 2019-08-08 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
805 2e1f37b0 2019-08-08 stsp >> $testroot/stdout.expected
806 2e1f37b0 2019-08-08 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
807 2e1f37b0 2019-08-08 stsp echo "--- beta" >> $testroot/stdout.expected
808 1cb46f00 2020-11-21 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
809 2e1f37b0 2019-08-08 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
810 2e1f37b0 2019-08-08 stsp echo "-beta" >> $testroot/stdout.expected
811 2e1f37b0 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
812 49c543a6 2022-03-31 naddy ret=$?
813 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
814 2e1f37b0 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
815 2e1f37b0 2019-08-08 stsp fi
816 2e1f37b0 2019-08-08 stsp test_done "$testroot" "$ret"
817 2e1f37b0 2019-08-08 stsp }
818 19e4b907 2019-08-08 stsp
819 f6cae3ed 2020-09-13 naddy test_unstage_patch_quit() {
820 19e4b907 2019-08-08 stsp local testroot=`test_init unstage_patch_quit`
821 19e4b907 2019-08-08 stsp
822 19e4b907 2019-08-08 stsp jot 16 > $testroot/repo/numbers
823 19e4b907 2019-08-08 stsp echo zzz > $testroot/repo/zzz
824 19e4b907 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
825 19e4b907 2019-08-08 stsp git_commit $testroot/repo -m "added files"
826 19e4b907 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
827 19e4b907 2019-08-08 stsp
828 19e4b907 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
829 49c543a6 2022-03-31 naddy ret=$?
830 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
831 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
832 19e4b907 2019-08-08 stsp return 1
833 19e4b907 2019-08-08 stsp fi
834 2e1f37b0 2019-08-08 stsp
835 885e96df 2023-03-06 naddy ed -s $testroot/wt/numbers <<-\EOF
836 885e96df 2023-03-06 naddy ,s/^2$/a/
837 885e96df 2023-03-06 naddy ,s/^7$/b/
838 885e96df 2023-03-06 naddy ,s/^16$/c/
839 885e96df 2023-03-06 naddy w
840 885e96df 2023-03-06 naddy EOF
841 19e4b907 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
842 19e4b907 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
843 19e4b907 2019-08-08 stsp
844 19e4b907 2019-08-08 stsp # unstage first hunk and quit; and don't pass a path argument to
845 19e4b907 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
846 19e4b907 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
847 19e4b907 2019-08-08 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
848 19e4b907 2019-08-08 stsp > $testroot/stdout)
849 49c543a6 2022-03-31 naddy ret=$?
850 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
851 57ba6a8b 2019-08-08 stsp echo "got unstage command failed unexpectedly" >&2
852 19e4b907 2019-08-08 stsp test_done "$testroot" "1"
853 19e4b907 2019-08-08 stsp return 1
854 19e4b907 2019-08-08 stsp fi
855 19e4b907 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
856 19e4b907 2019-08-08 stsp -----------------------------------------------
857 19e4b907 2019-08-08 stsp @@ -1,5 +1,5 @@
858 19e4b907 2019-08-08 stsp 1
859 19e4b907 2019-08-08 stsp -2
860 19e4b907 2019-08-08 stsp +a
861 19e4b907 2019-08-08 stsp 3
862 19e4b907 2019-08-08 stsp 4
863 19e4b907 2019-08-08 stsp 5
864 19e4b907 2019-08-08 stsp -----------------------------------------------
865 19e4b907 2019-08-08 stsp M numbers (change 1 of 3)
866 19e4b907 2019-08-08 stsp unstage this change? [y/n/q] y
867 19e4b907 2019-08-08 stsp -----------------------------------------------
868 19e4b907 2019-08-08 stsp @@ -4,7 +4,7 @@
869 19e4b907 2019-08-08 stsp 4
870 19e4b907 2019-08-08 stsp 5
871 19e4b907 2019-08-08 stsp 6
872 19e4b907 2019-08-08 stsp -7
873 19e4b907 2019-08-08 stsp +b
874 19e4b907 2019-08-08 stsp 8
875 19e4b907 2019-08-08 stsp 9
876 19e4b907 2019-08-08 stsp 10
877 19e4b907 2019-08-08 stsp -----------------------------------------------
878 19e4b907 2019-08-08 stsp M numbers (change 2 of 3)
879 19e4b907 2019-08-08 stsp unstage this change? [y/n/q] q
880 19e4b907 2019-08-08 stsp G numbers
881 19e4b907 2019-08-08 stsp D zzz
882 19e4b907 2019-08-08 stsp unstage this deletion? [y/n] n
883 19e4b907 2019-08-08 stsp EOF
884 19e4b907 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
885 49c543a6 2022-03-31 naddy ret=$?
886 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
887 19e4b907 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
888 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
889 19e4b907 2019-08-08 stsp return 1
890 19e4b907 2019-08-08 stsp fi
891 19e4b907 2019-08-08 stsp
892 19e4b907 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
893 19e4b907 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
894 19e4b907 2019-08-08 stsp echo " D zzz" >> $testroot/stdout.expected
895 19e4b907 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
896 49c543a6 2022-03-31 naddy ret=$?
897 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
898 19e4b907 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
899 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
900 19e4b907 2019-08-08 stsp return 1
901 19e4b907 2019-08-08 stsp fi
902 19e4b907 2019-08-08 stsp
903 19e4b907 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
904 19e4b907 2019-08-08 stsp
905 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
906 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
907 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
908 19e4b907 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
909 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
910 4ce46740 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
911 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
912 19e4b907 2019-08-08 stsp echo "file + numbers" >> $testroot/stdout.expected
913 19e4b907 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
914 19e4b907 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
915 19e4b907 2019-08-08 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
916 19e4b907 2019-08-08 stsp echo " 1" >> $testroot/stdout.expected
917 19e4b907 2019-08-08 stsp echo "-2" >> $testroot/stdout.expected
918 19e4b907 2019-08-08 stsp echo "+a" >> $testroot/stdout.expected
919 19e4b907 2019-08-08 stsp echo " 3" >> $testroot/stdout.expected
920 19e4b907 2019-08-08 stsp echo " 4" >> $testroot/stdout.expected
921 19e4b907 2019-08-08 stsp echo " 5" >> $testroot/stdout.expected
922 19e4b907 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
923 49c543a6 2022-03-31 naddy ret=$?
924 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
925 19e4b907 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
926 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
927 19e4b907 2019-08-08 stsp return 1
928 19e4b907 2019-08-08 stsp fi
929 19e4b907 2019-08-08 stsp
930 19e4b907 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
931 8469d821 2022-06-25 stsp echo "diff -s $testroot/wt" > $testroot/stdout.expected
932 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
933 8469d821 2022-06-25 stsp echo "path + $testroot/wt (staged changes)" >> $testroot/stdout.expected
934 19e4b907 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
935 19e4b907 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
936 19e4b907 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
937 19e4b907 2019-08-08 stsp >> $testroot/stdout.expected
938 19e4b907 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
939 19e4b907 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
940 19e4b907 2019-08-08 stsp >> $testroot/stdout.expected
941 19e4b907 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
942 19e4b907 2019-08-08 stsp --- numbers
943 19e4b907 2019-08-08 stsp +++ numbers
944 19e4b907 2019-08-08 stsp @@ -4,7 +4,7 @@
945 19e4b907 2019-08-08 stsp 4
946 19e4b907 2019-08-08 stsp 5
947 19e4b907 2019-08-08 stsp 6
948 19e4b907 2019-08-08 stsp -7
949 19e4b907 2019-08-08 stsp +b
950 19e4b907 2019-08-08 stsp 8
951 19e4b907 2019-08-08 stsp 9
952 19e4b907 2019-08-08 stsp 10
953 19e4b907 2019-08-08 stsp @@ -13,4 +13,4 @@
954 19e4b907 2019-08-08 stsp 13
955 19e4b907 2019-08-08 stsp 14
956 19e4b907 2019-08-08 stsp 15
957 19e4b907 2019-08-08 stsp -16
958 19e4b907 2019-08-08 stsp +c
959 19e4b907 2019-08-08 stsp EOF
960 19e4b907 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
961 19e4b907 2019-08-08 stsp got tree -r $testroot/repo -i | grep 'zzz$' | cut -d' ' -f 1 \
962 19e4b907 2019-08-08 stsp >> $testroot/stdout.expected
963 19e4b907 2019-08-08 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
964 19e4b907 2019-08-08 stsp echo "--- zzz" >> $testroot/stdout.expected
965 19e4b907 2019-08-08 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
966 19e4b907 2019-08-08 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
967 19e4b907 2019-08-08 stsp echo "-zzz" >> $testroot/stdout.expected
968 19e4b907 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
969 49c543a6 2022-03-31 naddy ret=$?
970 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
971 19e4b907 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
972 19e4b907 2019-08-08 stsp fi
973 19e4b907 2019-08-08 stsp test_done "$testroot" "$ret"
974 19e4b907 2019-08-08 stsp }
975 ea7786be 2020-07-23 stsp
976 f6cae3ed 2020-09-13 naddy test_unstage_symlink() {
977 ea7786be 2020-07-23 stsp local testroot=`test_init unstage_symlink`
978 ea7786be 2020-07-23 stsp
979 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
980 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
981 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
982 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
983 ea7786be 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
984 ea7786be 2020-07-23 stsp (cd $testroot/repo && git add .)
985 ea7786be 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
986 ea7786be 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
987 19e4b907 2019-08-08 stsp
988 ea7786be 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
989 49c543a6 2022-03-31 naddy ret=$?
990 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
991 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
992 ea7786be 2020-07-23 stsp return 1
993 ea7786be 2020-07-23 stsp fi
994 ea7786be 2020-07-23 stsp
995 ea7786be 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
996 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
997 ea7786be 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
998 ea7786be 2020-07-23 stsp echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
999 ea7786be 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
1000 ea7786be 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1001 ea7786be 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1002 ea7786be 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1003 ea7786be 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1004 ea7786be 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
1005 ea7786be 2020-07-23 stsp
1006 35213c7c 2020-07-23 stsp (cd $testroot/wt && got stage -S > /dev/null)
1007 ea7786be 2020-07-23 stsp
1008 ea7786be 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1009 ea7786be 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1010 ea7786be 2020-07-23 stsp M alpha.link
1011 ea7786be 2020-07-23 stsp A dotgotbar.link
1012 ea7786be 2020-07-23 stsp A dotgotfoo.link
1013 ea7786be 2020-07-23 stsp M epsilon/beta.link
1014 ea7786be 2020-07-23 stsp M epsilon.link
1015 ea7786be 2020-07-23 stsp D nonexistent.link
1016 ea7786be 2020-07-23 stsp A zeta.link
1017 ea7786be 2020-07-23 stsp EOF
1018 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1019 49c543a6 2022-03-31 naddy ret=$?
1020 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1021 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1022 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1023 ea7786be 2020-07-23 stsp return 1
1024 ea7786be 2020-07-23 stsp fi
1025 ea7786be 2020-07-23 stsp
1026 ea7786be 2020-07-23 stsp (cd $testroot/wt && got unstage > $testroot/stdout)
1027 49c543a6 2022-03-31 naddy ret=$?
1028 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1029 ea7786be 2020-07-23 stsp echo "got unstage command failed unexpectedly" >&2
1030 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1031 ea7786be 2020-07-23 stsp return 1
1032 ea7786be 2020-07-23 stsp fi
1033 ea7786be 2020-07-23 stsp
1034 ea7786be 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1035 ea7786be 2020-07-23 stsp G alpha.link
1036 ea7786be 2020-07-23 stsp G dotgotbar.link
1037 ea7786be 2020-07-23 stsp G dotgotfoo.link
1038 ea7786be 2020-07-23 stsp G epsilon/beta.link
1039 ea7786be 2020-07-23 stsp G epsilon.link
1040 ea7786be 2020-07-23 stsp D nonexistent.link
1041 ea7786be 2020-07-23 stsp G zeta.link
1042 ea7786be 2020-07-23 stsp EOF
1043 ea7786be 2020-07-23 stsp
1044 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1045 49c543a6 2022-03-31 naddy ret=$?
1046 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1047 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1048 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1049 ea7786be 2020-07-23 stsp return 1
1050 ea7786be 2020-07-23 stsp fi
1051 ea7786be 2020-07-23 stsp
1052 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/alpha.link ]; then
1053 ea7786be 2020-07-23 stsp echo "alpha.link is not a symlink"
1054 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1055 ea7786be 2020-07-23 stsp return 1
1056 ea7786be 2020-07-23 stsp fi
1057 ea7786be 2020-07-23 stsp
1058 ea7786be 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1059 ea7786be 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
1060 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1061 49c543a6 2022-03-31 naddy ret=$?
1062 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1063 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1064 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1065 ea7786be 2020-07-23 stsp return 1
1066 ea7786be 2020-07-23 stsp fi
1067 ea7786be 2020-07-23 stsp
1068 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/epsilon.link ]; then
1069 ea7786be 2020-07-23 stsp echo "epsilon.link is not a symlink"
1070 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1071 ea7786be 2020-07-23 stsp return 1
1072 ea7786be 2020-07-23 stsp fi
1073 ea7786be 2020-07-23 stsp
1074 ea7786be 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1075 ea7786be 2020-07-23 stsp echo "gamma" > $testroot/stdout.expected
1076 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1077 49c543a6 2022-03-31 naddy ret=$?
1078 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1079 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1080 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1081 ea7786be 2020-07-23 stsp return 1
1082 ea7786be 2020-07-23 stsp fi
1083 ea7786be 2020-07-23 stsp
1084 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/epsilon/beta.link ]; then
1085 ea7786be 2020-07-23 stsp echo "epsilon/beta.link is not a symlink"
1086 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1087 ea7786be 2020-07-23 stsp return 1
1088 ea7786be 2020-07-23 stsp fi
1089 ea7786be 2020-07-23 stsp
1090 ea7786be 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1091 ea7786be 2020-07-23 stsp echo "../gamma/delta" > $testroot/stdout.expected
1092 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1093 49c543a6 2022-03-31 naddy ret=$?
1094 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1095 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1096 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1097 ea7786be 2020-07-23 stsp return 1
1098 ea7786be 2020-07-23 stsp fi
1099 ea7786be 2020-07-23 stsp
1100 ea7786be 2020-07-23 stsp if [ ! -f $testroot/wt/dotgotfoo.link ]; then
1101 ea7786be 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
1102 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1103 ea7786be 2020-07-23 stsp return 1
1104 ea7786be 2020-07-23 stsp fi
1105 ea7786be 2020-07-23 stsp
1106 ea7786be 2020-07-23 stsp echo "this is regular file foo" > $testroot/content.expected
1107 ea7786be 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
1108 ea7786be 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1109 49c543a6 2022-03-31 naddy ret=$?
1110 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1111 ea7786be 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1112 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1113 ea7786be 2020-07-23 stsp return 1
1114 ea7786be 2020-07-23 stsp fi
1115 ea7786be 2020-07-23 stsp
1116 ea7786be 2020-07-23 stsp # bad symlinks are allowed as-is for commit and stage/unstage
1117 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
1118 ea7786be 2020-07-23 stsp echo "dotgotbar.link is not a symlink"
1119 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1120 ea7786be 2020-07-23 stsp return 1
1121 ea7786be 2020-07-23 stsp fi
1122 ea7786be 2020-07-23 stsp
1123 ea7786be 2020-07-23 stsp readlink $testroot/wt/dotgotbar.link > $testroot/stdout
1124 ea7786be 2020-07-23 stsp echo ".got/bar" > $testroot/stdout.expected
1125 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1126 49c543a6 2022-03-31 naddy ret=$?
1127 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1128 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1129 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1130 ea7786be 2020-07-23 stsp return 1
1131 ea7786be 2020-07-23 stsp fi
1132 ea7786be 2020-07-23 stsp
1133 ea7786be 2020-07-23 stsp if [ -e $testroot/wt/nonexistent.link ]; then
1134 ea7786be 2020-07-23 stsp echo "nonexistent.link exists on disk"
1135 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1136 ea7786be 2020-07-23 stsp return 1
1137 ea7786be 2020-07-23 stsp fi
1138 ea7786be 2020-07-23 stsp
1139 ea7786be 2020-07-23 stsp if [ ! -h $testroot/wt/zeta.link ]; then
1140 ea7786be 2020-07-23 stsp echo "zeta.link is not a symlink"
1141 ea7786be 2020-07-23 stsp test_done "$testroot" "1"
1142 ea7786be 2020-07-23 stsp return 1
1143 ea7786be 2020-07-23 stsp fi
1144 ea7786be 2020-07-23 stsp
1145 ea7786be 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
1146 ea7786be 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
1147 ea7786be 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1148 49c543a6 2022-03-31 naddy ret=$?
1149 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1150 ea7786be 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1151 ea7786be 2020-07-23 stsp test_done "$testroot" "$ret"
1152 ea7786be 2020-07-23 stsp return 1
1153 ea7786be 2020-07-23 stsp fi
1154 ea7786be 2020-07-23 stsp
1155 ea7786be 2020-07-23 stsp test_done "$testroot" "0"
1156 ea7786be 2020-07-23 stsp }
1157 36bf999c 2020-07-23 stsp
1158 f6cae3ed 2020-09-13 naddy test_unstage_patch_symlink() {
1159 36bf999c 2020-07-23 stsp local testroot=`test_init unstage_patch_symlink`
1160 36bf999c 2020-07-23 stsp
1161 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1162 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1163 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1164 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1165 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1166 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1167 36bf999c 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta2.link)
1168 36bf999c 2020-07-23 stsp (cd $testroot/repo && git add .)
1169 36bf999c 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1170 36bf999c 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
1171 36bf999c 2020-07-23 stsp
1172 36bf999c 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1173 49c543a6 2022-03-31 naddy ret=$?
1174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1175 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1176 36bf999c 2020-07-23 stsp return 1
1177 36bf999c 2020-07-23 stsp fi
1178 36bf999c 2020-07-23 stsp
1179 36bf999c 2020-07-23 stsp # symlink to file A now points to file B
1180 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1181 36bf999c 2020-07-23 stsp # symlink to a directory A now points to file B
1182 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
1183 36bf999c 2020-07-23 stsp # "bad" symlink now contains a different target path
1184 36bf999c 2020-07-23 stsp echo "foo" > $testroot/wt/passwd.link
1185 36bf999c 2020-07-23 stsp # relative symlink to directory A now points to relative directory B
1186 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
1187 f55db25a 2023-03-03 naddy epsilon/beta.link)
1188 36bf999c 2020-07-23 stsp # an unversioned symlink
1189 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1190 36bf999c 2020-07-23 stsp # symlink to file A now points to non-existent file B
1191 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1192 36bf999c 2020-07-23 stsp # removed symlink
1193 36bf999c 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
1194 36bf999c 2020-07-23 stsp (cd $testroot/wt && got rm zeta2.link > /dev/null)
1195 36bf999c 2020-07-23 stsp # added symlink
1196 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
1197 36bf999c 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1198 36bf999c 2020-07-23 stsp (cd $testroot/wt && ln -sf beta zeta3.link)
1199 36bf999c 2020-07-23 stsp (cd $testroot/wt && got add zeta3.link > /dev/null)
1200 ea7786be 2020-07-23 stsp
1201 36bf999c 2020-07-23 stsp (cd $testroot/wt && got stage -S > /dev/null)
1202 36bf999c 2020-07-23 stsp
1203 36bf999c 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1204 36bf999c 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1205 36bf999c 2020-07-23 stsp M alpha.link
1206 36bf999c 2020-07-23 stsp ? dotgotfoo.link
1207 36bf999c 2020-07-23 stsp M epsilon/beta.link
1208 36bf999c 2020-07-23 stsp M epsilon.link
1209 36bf999c 2020-07-23 stsp A new.link
1210 36bf999c 2020-07-23 stsp M nonexistent.link
1211 36bf999c 2020-07-23 stsp M passwd.link
1212 36bf999c 2020-07-23 stsp D zeta.link
1213 36bf999c 2020-07-23 stsp D zeta2.link
1214 36bf999c 2020-07-23 stsp A zeta3.link
1215 36bf999c 2020-07-23 stsp EOF
1216 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1217 49c543a6 2022-03-31 naddy ret=$?
1218 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1219 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1220 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1221 36bf999c 2020-07-23 stsp return 1
1222 36bf999c 2020-07-23 stsp fi
1223 36bf999c 2020-07-23 stsp
1224 36bf999c 2020-07-23 stsp printf "y\nn\ny\nn\ny\ny\nn\ny\ny\n" > $testroot/patchscript
1225 36bf999c 2020-07-23 stsp (cd $testroot/wt && got unstage -F $testroot/patchscript -p \
1226 36bf999c 2020-07-23 stsp > $testroot/stdout)
1227 49c543a6 2022-03-31 naddy ret=$?
1228 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1229 36bf999c 2020-07-23 stsp echo "got unstage command failed unexpectedly" >&2
1230 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1231 36bf999c 2020-07-23 stsp return 1
1232 36bf999c 2020-07-23 stsp fi
1233 36bf999c 2020-07-23 stsp
1234 36bf999c 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1235 36bf999c 2020-07-23 stsp -----------------------------------------------
1236 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1237 36bf999c 2020-07-23 stsp -alpha
1238 36bf999c 2020-07-23 stsp \ No newline at end of file
1239 36bf999c 2020-07-23 stsp +gamma/delta
1240 36bf999c 2020-07-23 stsp \ No newline at end of file
1241 36bf999c 2020-07-23 stsp -----------------------------------------------
1242 36bf999c 2020-07-23 stsp M alpha.link (change 1 of 1)
1243 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] y
1244 36bf999c 2020-07-23 stsp G alpha.link
1245 36bf999c 2020-07-23 stsp -----------------------------------------------
1246 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1247 36bf999c 2020-07-23 stsp -../beta
1248 36bf999c 2020-07-23 stsp \ No newline at end of file
1249 36bf999c 2020-07-23 stsp +../gamma
1250 36bf999c 2020-07-23 stsp \ No newline at end of file
1251 36bf999c 2020-07-23 stsp -----------------------------------------------
1252 36bf999c 2020-07-23 stsp M epsilon/beta.link (change 1 of 1)
1253 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] n
1254 36bf999c 2020-07-23 stsp -----------------------------------------------
1255 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1256 36bf999c 2020-07-23 stsp -epsilon
1257 36bf999c 2020-07-23 stsp \ No newline at end of file
1258 36bf999c 2020-07-23 stsp +beta
1259 36bf999c 2020-07-23 stsp \ No newline at end of file
1260 36bf999c 2020-07-23 stsp -----------------------------------------------
1261 36bf999c 2020-07-23 stsp M epsilon.link (change 1 of 1)
1262 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] y
1263 36bf999c 2020-07-23 stsp G epsilon.link
1264 36bf999c 2020-07-23 stsp A new.link
1265 36bf999c 2020-07-23 stsp unstage this addition? [y/n] n
1266 36bf999c 2020-07-23 stsp -----------------------------------------------
1267 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1268 36bf999c 2020-07-23 stsp -nonexistent
1269 36bf999c 2020-07-23 stsp \ No newline at end of file
1270 36bf999c 2020-07-23 stsp +nonexistent2
1271 36bf999c 2020-07-23 stsp \ No newline at end of file
1272 36bf999c 2020-07-23 stsp -----------------------------------------------
1273 36bf999c 2020-07-23 stsp M nonexistent.link (change 1 of 1)
1274 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] y
1275 36bf999c 2020-07-23 stsp G nonexistent.link
1276 36bf999c 2020-07-23 stsp -----------------------------------------------
1277 36bf999c 2020-07-23 stsp @@ -1 +1 @@
1278 36bf999c 2020-07-23 stsp -/etc/passwd
1279 36bf999c 2020-07-23 stsp \ No newline at end of file
1280 36bf999c 2020-07-23 stsp +foo
1281 36bf999c 2020-07-23 stsp -----------------------------------------------
1282 36bf999c 2020-07-23 stsp M passwd.link (change 1 of 1)
1283 36bf999c 2020-07-23 stsp unstage this change? [y/n/q] y
1284 36bf999c 2020-07-23 stsp G passwd.link
1285 36bf999c 2020-07-23 stsp D zeta.link
1286 36bf999c 2020-07-23 stsp unstage this deletion? [y/n] n
1287 36bf999c 2020-07-23 stsp D zeta2.link
1288 36bf999c 2020-07-23 stsp unstage this deletion? [y/n] y
1289 36bf999c 2020-07-23 stsp D zeta2.link
1290 36bf999c 2020-07-23 stsp A zeta3.link
1291 36bf999c 2020-07-23 stsp unstage this addition? [y/n] y
1292 36bf999c 2020-07-23 stsp G zeta3.link
1293 36bf999c 2020-07-23 stsp EOF
1294 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1295 49c543a6 2022-03-31 naddy ret=$?
1296 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1297 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1298 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1299 36bf999c 2020-07-23 stsp return 1
1300 36bf999c 2020-07-23 stsp fi
1301 36bf999c 2020-07-23 stsp
1302 36bf999c 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1303 36bf999c 2020-07-23 stsp echo "alpha.link is not a symlink"
1304 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1305 36bf999c 2020-07-23 stsp return 1
1306 36bf999c 2020-07-23 stsp fi
1307 36bf999c 2020-07-23 stsp
1308 36bf999c 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1309 36bf999c 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
1310 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1311 49c543a6 2022-03-31 naddy ret=$?
1312 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1313 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1314 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1315 36bf999c 2020-07-23 stsp return 1
1316 36bf999c 2020-07-23 stsp fi
1317 36bf999c 2020-07-23 stsp
1318 36bf999c 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1319 36bf999c 2020-07-23 stsp echo "epsilon.link is not a symlink"
1320 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1321 36bf999c 2020-07-23 stsp return 1
1322 36bf999c 2020-07-23 stsp fi
1323 36bf999c 2020-07-23 stsp
1324 36bf999c 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1325 36bf999c 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
1326 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1327 49c543a6 2022-03-31 naddy ret=$?
1328 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1329 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1330 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1331 36bf999c 2020-07-23 stsp return 1
1332 36bf999c 2020-07-23 stsp fi
1333 36bf999c 2020-07-23 stsp
1334 36bf999c 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1335 36bf999c 2020-07-23 stsp echo "passwd.link should not be a symlink" >&2
1336 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1337 36bf999c 2020-07-23 stsp return 1
1338 36bf999c 2020-07-23 stsp fi
1339 36bf999c 2020-07-23 stsp
1340 36bf999c 2020-07-23 stsp echo "foo" > $testroot/content.expected
1341 36bf999c 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1342 36bf999c 2020-07-23 stsp
1343 36bf999c 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1344 49c543a6 2022-03-31 naddy ret=$?
1345 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1346 36bf999c 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1347 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1348 36bf999c 2020-07-23 stsp return 1
1349 36bf999c 2020-07-23 stsp fi
1350 36bf999c 2020-07-23 stsp
1351 36bf999c 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1352 36bf999c 2020-07-23 stsp echo "../gamma" > $testroot/stdout.expected
1353 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1354 49c543a6 2022-03-31 naddy ret=$?
1355 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1356 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1357 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1358 36bf999c 2020-07-23 stsp return 1
1359 36bf999c 2020-07-23 stsp fi
1360 36bf999c 2020-07-23 stsp
1361 36bf999c 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1362 36bf999c 2020-07-23 stsp echo "nonexistent2" > $testroot/stdout.expected
1363 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1364 49c543a6 2022-03-31 naddy ret=$?
1365 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1366 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1367 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1368 36bf999c 2020-07-23 stsp return 1
1369 36bf999c 2020-07-23 stsp fi
1370 36bf999c 2020-07-23 stsp
1371 36bf999c 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1372 36bf999c 2020-07-23 stsp echo "dotgotfoo.link is not a symlink " >&2
1373 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1374 36bf999c 2020-07-23 stsp return 1
1375 36bf999c 2020-07-23 stsp fi
1376 36bf999c 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1377 36bf999c 2020-07-23 stsp echo ".got/foo" > $testroot/stdout.expected
1378 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1379 49c543a6 2022-03-31 naddy ret=$?
1380 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1381 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1382 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1383 36bf999c 2020-07-23 stsp return 1
1384 36bf999c 2020-07-23 stsp fi
1385 36bf999c 2020-07-23 stsp
1386 36bf999c 2020-07-23 stsp
1387 36bf999c 2020-07-23 stsp if [ -e $testroot/wt/zeta.link ]; then
1388 36bf999c 2020-07-23 stsp echo -n "zeta.link should not exist on disk" >&2
1389 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1390 36bf999c 2020-07-23 stsp return 1
1391 36bf999c 2020-07-23 stsp fi
1392 36bf999c 2020-07-23 stsp
1393 36bf999c 2020-07-23 stsp if [ -e $testroot/wt/zeta2.link ]; then
1394 36bf999c 2020-07-23 stsp echo -n "zeta2.link exists on disk" >&2
1395 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1396 36bf999c 2020-07-23 stsp return 1
1397 36bf999c 2020-07-23 stsp fi
1398 36bf999c 2020-07-23 stsp
1399 36bf999c 2020-07-23 stsp if [ ! -h $testroot/wt/zeta3.link ]; then
1400 36bf999c 2020-07-23 stsp echo -n "zeta3.link is not a symlink" >&2
1401 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1402 36bf999c 2020-07-23 stsp return 1
1403 36bf999c 2020-07-23 stsp fi
1404 36bf999c 2020-07-23 stsp
1405 36bf999c 2020-07-23 stsp readlink $testroot/wt/zeta3.link > $testroot/stdout
1406 36bf999c 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
1407 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1408 49c543a6 2022-03-31 naddy ret=$?
1409 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1410 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1411 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1412 36bf999c 2020-07-23 stsp return 1
1413 36bf999c 2020-07-23 stsp fi
1414 36bf999c 2020-07-23 stsp
1415 36bf999c 2020-07-23 stsp if [ ! -h $testroot/wt/new.link ]; then
1416 36bf999c 2020-07-23 stsp echo -n "new.link is not a symlink" >&2
1417 36bf999c 2020-07-23 stsp test_done "$testroot" "1"
1418 36bf999c 2020-07-23 stsp return 1
1419 36bf999c 2020-07-23 stsp fi
1420 36bf999c 2020-07-23 stsp
1421 36bf999c 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1422 36bf999c 2020-07-23 stsp echo "M alpha.link" > $testroot/stdout.expected
1423 36bf999c 2020-07-23 stsp echo "? dotgotfoo.link" >> $testroot/stdout.expected
1424 36bf999c 2020-07-23 stsp echo " M epsilon/beta.link" >> $testroot/stdout.expected
1425 36bf999c 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1426 36bf999c 2020-07-23 stsp echo " A new.link" >> $testroot/stdout.expected
1427 36bf999c 2020-07-23 stsp echo "M nonexistent.link" >> $testroot/stdout.expected
1428 36bf999c 2020-07-23 stsp echo "M passwd.link" >> $testroot/stdout.expected
1429 36bf999c 2020-07-23 stsp echo " D zeta.link" >> $testroot/stdout.expected
1430 36bf999c 2020-07-23 stsp echo "D zeta2.link" >> $testroot/stdout.expected
1431 36bf999c 2020-07-23 stsp echo "A zeta3.link" >> $testroot/stdout.expected
1432 36bf999c 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1433 49c543a6 2022-03-31 naddy ret=$?
1434 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1435 36bf999c 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1436 36bf999c 2020-07-23 stsp return 1
1437 36bf999c 2020-07-23 stsp fi
1438 36bf999c 2020-07-23 stsp test_done "$testroot" "$ret"
1439 36bf999c 2020-07-23 stsp }
1440 36bf999c 2020-07-23 stsp
1441 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1442 ad493afc 2019-08-03 stsp run_test test_unstage_basic
1443 8b13ce36 2019-08-08 stsp run_test test_unstage_unversioned
1444 8564cb21 2019-08-08 stsp run_test test_unstage_nonexistent
1445 2e1f37b0 2019-08-08 stsp run_test test_unstage_patch
1446 2e1f37b0 2019-08-08 stsp run_test test_unstage_patch_added
1447 2e1f37b0 2019-08-08 stsp run_test test_unstage_patch_removed
1448 19e4b907 2019-08-08 stsp run_test test_unstage_patch_quit
1449 ea7786be 2020-07-23 stsp run_test test_unstage_symlink
1450 36bf999c 2020-07-23 stsp run_test test_unstage_patch_symlink