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