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