Blame


1 fccbfb98 2019-08-03 stsp #!/bin/sh
2 fccbfb98 2019-08-03 stsp #
3 fccbfb98 2019-08-03 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 fccbfb98 2019-08-03 stsp #
5 fccbfb98 2019-08-03 stsp # Permission to use, copy, modify, and distribute this software for any
6 fccbfb98 2019-08-03 stsp # purpose with or without fee is hereby granted, provided that the above
7 fccbfb98 2019-08-03 stsp # copyright notice and this permission notice appear in all copies.
8 fccbfb98 2019-08-03 stsp #
9 fccbfb98 2019-08-03 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 fccbfb98 2019-08-03 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 fccbfb98 2019-08-03 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 fccbfb98 2019-08-03 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 fccbfb98 2019-08-03 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 fccbfb98 2019-08-03 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 fccbfb98 2019-08-03 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 fccbfb98 2019-08-03 stsp
17 fccbfb98 2019-08-03 stsp . ./common.sh
18 fccbfb98 2019-08-03 stsp
19 c861864b 2022-01-03 stsp # disable automatic packing for these tests
20 c861864b 2022-01-03 stsp export GOT_TEST_PACK=""
21 c861864b 2022-01-03 stsp
22 f6cae3ed 2020-09-13 naddy test_stage_basic() {
23 fccbfb98 2019-08-03 stsp local testroot=`test_init stage_basic`
24 fccbfb98 2019-08-03 stsp
25 fccbfb98 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
26 fccbfb98 2019-08-03 stsp ret="$?"
27 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
28 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
29 fccbfb98 2019-08-03 stsp return 1
30 fccbfb98 2019-08-03 stsp fi
31 fccbfb98 2019-08-03 stsp
32 fccbfb98 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
33 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
34 fccbfb98 2019-08-03 stsp echo "new file" > $testroot/wt/foo
35 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
36 fccbfb98 2019-08-03 stsp
37 88d0e355 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
38 88d0e355 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
39 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
40 ec9d9b2f 2019-08-08 stsp (cd $testroot/wt && got stage > $testroot/stdout)
41 d3e7c587 2019-08-03 stsp
42 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
43 d3e7c587 2019-08-03 stsp ret="$?"
44 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
45 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
46 d3e7c587 2019-08-03 stsp fi
47 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
48 d3e7c587 2019-08-03 stsp }
49 d3e7c587 2019-08-03 stsp
50 f6cae3ed 2020-09-13 naddy test_stage_no_changes() {
51 31b20a6e 2019-08-06 stsp local testroot=`test_init stage_no_changes`
52 31b20a6e 2019-08-06 stsp
53 31b20a6e 2019-08-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
54 31b20a6e 2019-08-06 stsp ret="$?"
55 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
56 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
57 31b20a6e 2019-08-06 stsp return 1
58 31b20a6e 2019-08-06 stsp fi
59 31b20a6e 2019-08-06 stsp
60 31b20a6e 2019-08-06 stsp (cd $testroot/wt && got stage alpha beta > $testroot/stdout \
61 31b20a6e 2019-08-06 stsp 2> $testroot/stderr)
62 31b20a6e 2019-08-06 stsp ret="$?"
63 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
64 31b20a6e 2019-08-06 stsp echo "got stage command succeeded unexpectedly" >&2
65 31b20a6e 2019-08-06 stsp test_done "$testroot" "1"
66 31b20a6e 2019-08-06 stsp return 1
67 31b20a6e 2019-08-06 stsp fi
68 31b20a6e 2019-08-06 stsp
69 2db2652d 2019-08-07 stsp echo "got: no changes to stage" > $testroot/stderr.expected
70 31b20a6e 2019-08-06 stsp
71 31b20a6e 2019-08-06 stsp cmp -s $testroot/stderr.expected $testroot/stderr
72 31b20a6e 2019-08-06 stsp ret="$?"
73 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
74 31b20a6e 2019-08-06 stsp diff -u $testroot/stderr.expected $testroot/stderr
75 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
76 31b20a6e 2019-08-06 stsp return 1
77 31b20a6e 2019-08-06 stsp fi
78 31b20a6e 2019-08-06 stsp
79 31b20a6e 2019-08-06 stsp echo -n > $testroot/stdout.expected
80 31b20a6e 2019-08-06 stsp cmp -s $testroot/stdout.expected $testroot/stdout
81 31b20a6e 2019-08-06 stsp ret="$?"
82 31b20a6e 2019-08-06 stsp if [ "$ret" != "0" ]; then
83 31b20a6e 2019-08-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
84 31b20a6e 2019-08-06 stsp fi
85 31b20a6e 2019-08-06 stsp test_done "$testroot" "$ret"
86 31b20a6e 2019-08-06 stsp }
87 31b20a6e 2019-08-06 stsp
88 f6cae3ed 2020-09-13 naddy test_stage_unversioned() {
89 8b13ce36 2019-08-08 stsp local testroot=`test_init stage_unversioned`
90 8b13ce36 2019-08-08 stsp
91 8b13ce36 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
92 8b13ce36 2019-08-08 stsp ret="$?"
93 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
94 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
95 8b13ce36 2019-08-08 stsp return 1
96 8b13ce36 2019-08-08 stsp fi
97 8b13ce36 2019-08-08 stsp
98 8b13ce36 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
99 8b13ce36 2019-08-08 stsp touch $testroot/wt/unversioned-file
100 8b13ce36 2019-08-08 stsp
101 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
102 8b13ce36 2019-08-08 stsp echo "M alpha" > $testroot/stdout.expected
103 8b13ce36 2019-08-08 stsp echo "? unversioned-file" >> $testroot/stdout.expected
104 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
105 8b13ce36 2019-08-08 stsp ret="$?"
106 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
107 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
108 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
109 8b13ce36 2019-08-08 stsp return 1
110 8b13ce36 2019-08-08 stsp fi
111 8b13ce36 2019-08-08 stsp
112 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage > $testroot/stdout)
113 8b13ce36 2019-08-08 stsp ret="$?"
114 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
115 8b13ce36 2019-08-08 stsp echo "got stage command failed unexpectedly" >&2
116 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
117 8b13ce36 2019-08-08 stsp return 1
118 8b13ce36 2019-08-08 stsp fi
119 8b13ce36 2019-08-08 stsp
120 8b13ce36 2019-08-08 stsp echo " M alpha" > $testroot/stdout.expected
121 8b13ce36 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
122 8b13ce36 2019-08-08 stsp ret="$?"
123 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
124 8b13ce36 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
125 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
126 8b13ce36 2019-08-08 stsp return 1
127 8b13ce36 2019-08-08 stsp fi
128 8b13ce36 2019-08-08 stsp
129 8b13ce36 2019-08-08 stsp echo "modified file again" > $testroot/wt/alpha
130 8b13ce36 2019-08-08 stsp
131 8b13ce36 2019-08-08 stsp (cd $testroot/wt && got stage unversioned-file > $testroot/stdout \
132 8b13ce36 2019-08-08 stsp 2> $testroot/stderr)
133 8b13ce36 2019-08-08 stsp ret="$?"
134 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
135 8b13ce36 2019-08-08 stsp echo "got stage command succeed unexpectedly" >&2
136 8b13ce36 2019-08-08 stsp test_done "$testroot" "1"
137 8b13ce36 2019-08-08 stsp return 1
138 8b13ce36 2019-08-08 stsp fi
139 8b13ce36 2019-08-08 stsp
140 8b13ce36 2019-08-08 stsp echo "got: no changes to stage" > $testroot/stderr.expected
141 8b13ce36 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
142 8b13ce36 2019-08-08 stsp ret="$?"
143 8b13ce36 2019-08-08 stsp if [ "$ret" != "0" ]; then
144 8b13ce36 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
145 8b13ce36 2019-08-08 stsp fi
146 8b13ce36 2019-08-08 stsp test_done "$testroot" "$ret"
147 8564cb21 2019-08-08 stsp
148 8564cb21 2019-08-08 stsp }
149 8564cb21 2019-08-08 stsp
150 f6cae3ed 2020-09-13 naddy test_stage_nonexistent() {
151 8564cb21 2019-08-08 stsp local testroot=`test_init stage_nonexistent`
152 8564cb21 2019-08-08 stsp
153 8564cb21 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
154 8564cb21 2019-08-08 stsp ret="$?"
155 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
156 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
157 8564cb21 2019-08-08 stsp return 1
158 8564cb21 2019-08-08 stsp fi
159 8b13ce36 2019-08-08 stsp
160 8564cb21 2019-08-08 stsp (cd $testroot/wt && got stage nonexistent-file \
161 8564cb21 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
162 2a06fe5f 2019-08-24 stsp echo "got: nonexistent-file: No such file or directory" \
163 2a06fe5f 2019-08-24 stsp > $testroot/stderr.expected
164 8564cb21 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
165 8564cb21 2019-08-08 stsp ret="$?"
166 8564cb21 2019-08-08 stsp if [ "$ret" != "0" ]; then
167 8564cb21 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
168 8564cb21 2019-08-08 stsp fi
169 8564cb21 2019-08-08 stsp test_done "$testroot" "$ret"
170 8b13ce36 2019-08-08 stsp }
171 8b13ce36 2019-08-08 stsp
172 f6cae3ed 2020-09-13 naddy test_stage_list() {
173 a4f692bb 2019-08-04 stsp local testroot=`test_init stage_list`
174 a4f692bb 2019-08-04 stsp
175 a4f692bb 2019-08-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
176 a4f692bb 2019-08-04 stsp ret="$?"
177 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
178 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
179 a4f692bb 2019-08-04 stsp return 1
180 a4f692bb 2019-08-04 stsp fi
181 a4f692bb 2019-08-04 stsp
182 a4f692bb 2019-08-04 stsp echo "modified file" > $testroot/wt/alpha
183 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got rm beta > /dev/null)
184 a4f692bb 2019-08-04 stsp echo "new file" > $testroot/wt/foo
185 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got add foo > /dev/null)
186 a4f692bb 2019-08-04 stsp
187 a4f692bb 2019-08-04 stsp echo ' M alpha' > $testroot/stdout.expected
188 a4f692bb 2019-08-04 stsp echo ' D beta' >> $testroot/stdout.expected
189 a4f692bb 2019-08-04 stsp echo ' A foo' >> $testroot/stdout.expected
190 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
191 a4f692bb 2019-08-04 stsp
192 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l > $testroot/stdout)
193 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
194 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
195 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
196 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s beta | grep '^blob -' | \
197 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
198 a4f692bb 2019-08-04 stsp echo " D beta" >> $testroot/stdout.expected
199 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s foo | grep '^blob +' | \
200 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' >> $testroot/stdout.expected)
201 a4f692bb 2019-08-04 stsp echo " A foo" >> $testroot/stdout.expected
202 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
203 a4f692bb 2019-08-04 stsp ret="$?"
204 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
205 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
206 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
207 a4f692bb 2019-08-04 stsp return 1
208 a4f692bb 2019-08-04 stsp fi
209 a4f692bb 2019-08-04 stsp
210 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l epsilon nonexistent \
211 a4f692bb 2019-08-04 stsp > $testroot/stdout)
212 a4f692bb 2019-08-04 stsp
213 a4f692bb 2019-08-04 stsp echo -n > $testroot/stdout.expected
214 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
215 a4f692bb 2019-08-04 stsp ret="$?"
216 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
217 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
218 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
219 a4f692bb 2019-08-04 stsp return 1
220 a4f692bb 2019-08-04 stsp fi
221 a4f692bb 2019-08-04 stsp
222 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got stage -l alpha > $testroot/stdout)
223 a4f692bb 2019-08-04 stsp
224 a4f692bb 2019-08-04 stsp (cd $testroot/wt && got diff -s alpha | grep '^blob +' | \
225 a4f692bb 2019-08-04 stsp cut -d' ' -f3 | tr -d '\n' > $testroot/stdout.expected)
226 a4f692bb 2019-08-04 stsp echo " M alpha" >> $testroot/stdout.expected
227 a4f692bb 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
228 a4f692bb 2019-08-04 stsp ret="$?"
229 a4f692bb 2019-08-04 stsp if [ "$ret" != "0" ]; then
230 a4f692bb 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
231 a4f692bb 2019-08-04 stsp fi
232 a4f692bb 2019-08-04 stsp test_done "$testroot" "$ret"
233 a4f692bb 2019-08-04 stsp
234 a4f692bb 2019-08-04 stsp }
235 a4f692bb 2019-08-04 stsp
236 f6cae3ed 2020-09-13 naddy test_stage_conflict() {
237 ebf48fd5 2019-08-03 stsp local testroot=`test_init stage_conflict`
238 ebf48fd5 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
239 ebf48fd5 2019-08-03 stsp
240 ebf48fd5 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
241 ebf48fd5 2019-08-03 stsp ret="$?"
242 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
243 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
244 ebf48fd5 2019-08-03 stsp return 1
245 ebf48fd5 2019-08-03 stsp fi
246 ebf48fd5 2019-08-03 stsp
247 ebf48fd5 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
248 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
249 ebf48fd5 2019-08-03 stsp
250 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
251 ebf48fd5 2019-08-03 stsp
252 ebf48fd5 2019-08-03 stsp echo "modified alpha, too" > $testroot/wt/alpha
253 ebf48fd5 2019-08-03 stsp
254 ebf48fd5 2019-08-03 stsp echo "C alpha" > $testroot/stdout.expected
255 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
256 ebf48fd5 2019-08-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
257 ebf48fd5 2019-08-03 stsp echo >> $testroot/stdout.expected
258 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
259 ebf48fd5 2019-08-03 stsp
260 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout)
261 ebf48fd5 2019-08-03 stsp
262 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
263 ebf48fd5 2019-08-03 stsp ret="$?"
264 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
265 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
266 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
267 ebf48fd5 2019-08-03 stsp return 1
268 ebf48fd5 2019-08-03 stsp fi
269 ebf48fd5 2019-08-03 stsp
270 ebf48fd5 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
271 ebf48fd5 2019-08-03 stsp 2> $testroot/stderr)
272 ebf48fd5 2019-08-03 stsp ret="$?"
273 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
274 ebf48fd5 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
275 ebf48fd5 2019-08-03 stsp test_done "$testroot" "1"
276 ebf48fd5 2019-08-03 stsp return 1
277 ebf48fd5 2019-08-03 stsp fi
278 ebf48fd5 2019-08-03 stsp
279 ebf48fd5 2019-08-03 stsp echo -n > $testroot/stdout.expected
280 ebf48fd5 2019-08-03 stsp echo "got: alpha: cannot stage file in conflicted status" \
281 735ef5ac 2019-08-03 stsp > $testroot/stderr.expected
282 735ef5ac 2019-08-03 stsp
283 735ef5ac 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
284 735ef5ac 2019-08-03 stsp ret="$?"
285 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
286 735ef5ac 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
287 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
288 735ef5ac 2019-08-03 stsp return 1
289 735ef5ac 2019-08-03 stsp fi
290 735ef5ac 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
291 735ef5ac 2019-08-03 stsp ret="$?"
292 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
293 735ef5ac 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
294 735ef5ac 2019-08-03 stsp fi
295 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
296 735ef5ac 2019-08-03 stsp }
297 735ef5ac 2019-08-03 stsp
298 f6cae3ed 2020-09-13 naddy test_stage_out_of_date() {
299 735ef5ac 2019-08-03 stsp local testroot=`test_init stage_out_of_date`
300 735ef5ac 2019-08-03 stsp local initial_commit=`git_show_head $testroot/repo`
301 735ef5ac 2019-08-03 stsp
302 735ef5ac 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
303 735ef5ac 2019-08-03 stsp ret="$?"
304 735ef5ac 2019-08-03 stsp if [ "$ret" != "0" ]; then
305 735ef5ac 2019-08-03 stsp test_done "$testroot" "$ret"
306 735ef5ac 2019-08-03 stsp return 1
307 735ef5ac 2019-08-03 stsp fi
308 735ef5ac 2019-08-03 stsp
309 735ef5ac 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
310 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
311 735ef5ac 2019-08-03 stsp
312 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got update -c $initial_commit > /dev/null)
313 735ef5ac 2019-08-03 stsp
314 735ef5ac 2019-08-03 stsp echo "modified alpha again" > $testroot/wt/alpha
315 735ef5ac 2019-08-03 stsp (cd $testroot/wt && got stage alpha > $testroot/stdout \
316 735ef5ac 2019-08-03 stsp 2> $testroot/stderr)
317 735ef5ac 2019-08-03 stsp ret="$?"
318 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
319 735ef5ac 2019-08-03 stsp echo "got stage command succeeded unexpectedly" >&2
320 735ef5ac 2019-08-03 stsp test_done "$testroot" "1"
321 735ef5ac 2019-08-03 stsp return 1
322 735ef5ac 2019-08-03 stsp fi
323 735ef5ac 2019-08-03 stsp
324 735ef5ac 2019-08-03 stsp echo -n > $testroot/stdout.expected
325 735ef5ac 2019-08-03 stsp echo "got: work tree must be updated before changes can be staged" \
326 ebf48fd5 2019-08-03 stsp > $testroot/stderr.expected
327 ebf48fd5 2019-08-03 stsp
328 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
329 ebf48fd5 2019-08-03 stsp ret="$?"
330 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
331 ebf48fd5 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
332 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
333 ebf48fd5 2019-08-03 stsp return 1
334 ebf48fd5 2019-08-03 stsp fi
335 ebf48fd5 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
336 ebf48fd5 2019-08-03 stsp ret="$?"
337 ebf48fd5 2019-08-03 stsp if [ "$ret" != "0" ]; then
338 ebf48fd5 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
339 ebf48fd5 2019-08-03 stsp fi
340 ebf48fd5 2019-08-03 stsp test_done "$testroot" "$ret"
341 ebf48fd5 2019-08-03 stsp }
342 ebf48fd5 2019-08-03 stsp
343 ebf48fd5 2019-08-03 stsp
344 f6cae3ed 2020-09-13 naddy test_double_stage() {
345 d3e7c587 2019-08-03 stsp local testroot=`test_init double_stage`
346 d3e7c587 2019-08-03 stsp
347 d3e7c587 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
348 d3e7c587 2019-08-03 stsp ret="$?"
349 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
350 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
351 d3e7c587 2019-08-03 stsp return 1
352 d3e7c587 2019-08-03 stsp fi
353 d3e7c587 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
354 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
355 d3e7c587 2019-08-03 stsp echo "new file" > $testroot/wt/foo
356 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
357 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
358 d3e7c587 2019-08-03 stsp
359 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
360 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage alpha 2> $testroot/stderr)
361 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
362 d3e7c587 2019-08-03 stsp ret="$?"
363 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
364 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
365 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
366 d3e7c587 2019-08-03 stsp return 1
367 d3e7c587 2019-08-03 stsp fi
368 d3e7c587 2019-08-03 stsp
369 7b5dc508 2019-10-28 stsp (cd $testroot/wt && got stage beta \
370 7b5dc508 2019-10-28 stsp > $testroot/stdout 2> $testroot/stderr)
371 9c5c5eed 2019-08-03 stsp ret="$?"
372 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
373 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
374 7b5dc508 2019-10-28 stsp test_done "$testroot" "1"
375 7b5dc508 2019-10-28 stsp return 1
376 7b5dc508 2019-10-28 stsp fi
377 7b5dc508 2019-10-28 stsp echo -n > $testroot/stdout.expected
378 7b5dc508 2019-10-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
379 7b5dc508 2019-10-28 stsp ret="$?"
380 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
381 7b5dc508 2019-10-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
382 7b5dc508 2019-10-28 stsp test_done "$testroot" "$ret"
383 7b5dc508 2019-10-28 stsp return 1
384 7b5dc508 2019-10-28 stsp fi
385 7b5dc508 2019-10-28 stsp
386 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
387 7b5dc508 2019-10-28 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
388 7b5dc508 2019-10-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
389 7b5dc508 2019-10-28 stsp ret="$?"
390 7b5dc508 2019-10-28 stsp if [ "$ret" != "0" ]; then
391 7b5dc508 2019-10-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
392 7b5dc508 2019-10-28 stsp test_done "$testroot" "$ret"
393 7b5dc508 2019-10-28 stsp return 1
394 7b5dc508 2019-10-28 stsp fi
395 7b5dc508 2019-10-28 stsp
396 7b5dc508 2019-10-28 stsp printf "q\n" > $testroot/patchscript
397 7b5dc508 2019-10-28 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
398 7b5dc508 2019-10-28 stsp > $testroot/stdout 2> $testroot/stderr)
399 7b5dc508 2019-10-28 stsp ret="$?"
400 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
401 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
402 d3e7c587 2019-08-03 stsp test_done "$testroot" "1"
403 d3e7c587 2019-08-03 stsp return 1
404 d3e7c587 2019-08-03 stsp fi
405 d3e7c587 2019-08-03 stsp echo -n > $testroot/stdout.expected
406 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
407 d3e7c587 2019-08-03 stsp ret="$?"
408 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
409 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
410 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
411 d3e7c587 2019-08-03 stsp return 1
412 d3e7c587 2019-08-03 stsp fi
413 d3e7c587 2019-08-03 stsp
414 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
415 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got stage foo 2> $testroot/stderr)
416 d3e7c587 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
417 d3e7c587 2019-08-03 stsp ret="$?"
418 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
419 d3e7c587 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
420 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
421 d3e7c587 2019-08-03 stsp return 1
422 d3e7c587 2019-08-03 stsp fi
423 d3e7c587 2019-08-03 stsp
424 d3e7c587 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
425 d3e7c587 2019-08-03 stsp echo "modified new file" > $testroot/wt/foo
426 d3e7c587 2019-08-03 stsp
427 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
428 88d0e355 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
429 fccbfb98 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
430 d3e7c587 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
431 d3e7c587 2019-08-03 stsp ret="$?"
432 d3e7c587 2019-08-03 stsp if [ "$ret" != "0" ]; then
433 d3e7c587 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
434 d3e7c587 2019-08-03 stsp test_done "$testroot" "$ret"
435 d3e7c587 2019-08-03 stsp return 1
436 d3e7c587 2019-08-03 stsp fi
437 d3e7c587 2019-08-03 stsp
438 d3e7c587 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
439 d3e7c587 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
440 d3e7c587 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
441 fccbfb98 2019-08-03 stsp
442 d3e7c587 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
443 fccbfb98 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
444 fccbfb98 2019-08-03 stsp ret="$?"
445 fccbfb98 2019-08-03 stsp if [ "$ret" != "0" ]; then
446 fccbfb98 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
447 fccbfb98 2019-08-03 stsp fi
448 fccbfb98 2019-08-03 stsp test_done "$testroot" "$ret"
449 fccbfb98 2019-08-03 stsp }
450 fccbfb98 2019-08-03 stsp
451 f6cae3ed 2020-09-13 naddy test_stage_status() {
452 c363b2c1 2019-08-03 stsp local testroot=`test_init stage_status`
453 c363b2c1 2019-08-03 stsp
454 c363b2c1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
455 c363b2c1 2019-08-03 stsp ret="$?"
456 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
457 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
458 c363b2c1 2019-08-03 stsp return 1
459 c363b2c1 2019-08-03 stsp fi
460 c363b2c1 2019-08-03 stsp
461 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
462 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
463 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/foo
464 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
465 c363b2c1 2019-08-03 stsp echo "new file" > $testroot/wt/epsilon/new
466 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
467 c363b2c1 2019-08-03 stsp echo "modified file" > $testroot/wt/epsilon/zeta
468 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got rm gamma/delta > /dev/null)
469 c363b2c1 2019-08-03 stsp
470 c363b2c1 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
471 c363b2c1 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
472 c363b2c1 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
473 c363b2c1 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
474 c363b2c1 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
475 c363b2c1 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
476 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
477 c363b2c1 2019-08-03 stsp
478 c363b2c1 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
479 c363b2c1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
480 c363b2c1 2019-08-03 stsp ret="$?"
481 c363b2c1 2019-08-03 stsp if [ "$ret" != "0" ]; then
482 c363b2c1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
483 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
484 244725f2 2019-08-03 stsp return 1
485 c363b2c1 2019-08-03 stsp fi
486 244725f2 2019-08-03 stsp
487 244725f2 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
488 244725f2 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
489 244725f2 2019-08-03 stsp
490 244725f2 2019-08-03 stsp echo 'MM alpha' > $testroot/stdout.expected
491 244725f2 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
492 244725f2 2019-08-03 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
493 244725f2 2019-08-03 stsp echo 'M epsilon/zeta' >> $testroot/stdout.expected
494 244725f2 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
495 244725f2 2019-08-03 stsp echo 'D gamma/delta' >> $testroot/stdout.expected
496 244725f2 2019-08-03 stsp
497 244725f2 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
498 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
499 244725f2 2019-08-03 stsp ret="$?"
500 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
501 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
502 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
503 244725f2 2019-08-03 stsp return 1
504 244725f2 2019-08-03 stsp fi
505 244725f2 2019-08-03 stsp
506 244725f2 2019-08-03 stsp # test no-op change of added file with new stat(2) timestamp
507 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/foo
508 244725f2 2019-08-03 stsp echo ' A foo' > $testroot/stdout.expected
509 244725f2 2019-08-03 stsp (cd $testroot/wt && got status foo > $testroot/stdout)
510 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
511 244725f2 2019-08-03 stsp ret="$?"
512 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
513 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
514 244725f2 2019-08-03 stsp test_done "$testroot" "$ret"
515 244725f2 2019-08-03 stsp return 1
516 244725f2 2019-08-03 stsp fi
517 244725f2 2019-08-03 stsp
518 244725f2 2019-08-03 stsp # test staged deleted file which is restored on disk
519 244725f2 2019-08-03 stsp echo "new file" > $testroot/wt/beta
520 244725f2 2019-08-03 stsp echo ' D beta' > $testroot/stdout.expected
521 244725f2 2019-08-03 stsp (cd $testroot/wt && got status beta > $testroot/stdout)
522 244725f2 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
523 244725f2 2019-08-03 stsp ret="$?"
524 244725f2 2019-08-03 stsp if [ "$ret" != "0" ]; then
525 244725f2 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
526 244725f2 2019-08-03 stsp fi
527 c363b2c1 2019-08-03 stsp test_done "$testroot" "$ret"
528 244725f2 2019-08-03 stsp
529 c363b2c1 2019-08-03 stsp }
530 c363b2c1 2019-08-03 stsp
531 f6cae3ed 2020-09-13 naddy test_stage_add_already_staged_file() {
532 1e1446d3 2019-08-03 stsp local testroot=`test_init stage_add_already_staged_file`
533 1e1446d3 2019-08-03 stsp
534 1e1446d3 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
535 1e1446d3 2019-08-03 stsp ret="$?"
536 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
537 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
538 1e1446d3 2019-08-03 stsp return 1
539 1e1446d3 2019-08-03 stsp fi
540 1e1446d3 2019-08-03 stsp
541 1e1446d3 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
542 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
543 1e1446d3 2019-08-03 stsp echo "new file" > $testroot/wt/foo
544 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
545 1e1446d3 2019-08-03 stsp
546 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
547 1e1446d3 2019-08-03 stsp
548 1e1446d3 2019-08-03 stsp echo -n > $testroot/stdout.expected
549 6d022e97 2019-08-04 stsp for f in alpha beta foo; do
550 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got add $f \
551 1e1446d3 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
552 6d022e97 2019-08-04 stsp echo "got: $f: file has unexpected status" \
553 6d022e97 2019-08-04 stsp > $testroot/stderr.expected
554 6d022e97 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
555 1e1446d3 2019-08-03 stsp ret="$?"
556 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
557 6d022e97 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
558 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
559 1e1446d3 2019-08-03 stsp return 1
560 1e1446d3 2019-08-03 stsp fi
561 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
562 1e1446d3 2019-08-03 stsp ret="$?"
563 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
564 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
565 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
566 1e1446d3 2019-08-03 stsp return 1
567 1e1446d3 2019-08-03 stsp fi
568 1e1446d3 2019-08-03 stsp done
569 1e1446d3 2019-08-03 stsp
570 1e1446d3 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
571 1e1446d3 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
572 1e1446d3 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
573 1e1446d3 2019-08-03 stsp
574 1e1446d3 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
575 1e1446d3 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
576 1e1446d3 2019-08-03 stsp ret="$?"
577 1e1446d3 2019-08-03 stsp if [ "$ret" != "0" ]; then
578 1e1446d3 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
579 1e1446d3 2019-08-03 stsp fi
580 1e1446d3 2019-08-03 stsp test_done "$testroot" "$ret"
581 1e1446d3 2019-08-03 stsp }
582 1e1446d3 2019-08-03 stsp
583 f6cae3ed 2020-09-13 naddy test_stage_rm_already_staged_file() {
584 9acbc4fa 2019-08-03 stsp local testroot=`test_init stage_rm_already_staged_file`
585 9acbc4fa 2019-08-03 stsp
586 9acbc4fa 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
587 9acbc4fa 2019-08-03 stsp ret="$?"
588 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
589 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
590 9acbc4fa 2019-08-03 stsp return 1
591 9acbc4fa 2019-08-03 stsp fi
592 9acbc4fa 2019-08-03 stsp
593 9acbc4fa 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
594 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
595 9acbc4fa 2019-08-03 stsp echo "new file" > $testroot/wt/foo
596 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
597 9acbc4fa 2019-08-03 stsp
598 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > $testroot/stdout)
599 9acbc4fa 2019-08-03 stsp
600 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm beta \
601 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
602 9acbc4fa 2019-08-03 stsp ret="$?"
603 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
604 6d022e97 2019-08-04 stsp echo "got rm command failed unexpectedly" >&2
605 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
606 9acbc4fa 2019-08-03 stsp return 1
607 9acbc4fa 2019-08-03 stsp fi
608 6d022e97 2019-08-04 stsp echo -n > $testroot/stdout.expected
609 6d022e97 2019-08-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
610 6d022e97 2019-08-04 stsp ret="$?"
611 6d022e97 2019-08-04 stsp if [ "$ret" != "0" ]; then
612 6d022e97 2019-08-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
613 6d022e97 2019-08-04 stsp test_done "$testroot" "$ret"
614 6d022e97 2019-08-04 stsp return 1
615 6d022e97 2019-08-04 stsp fi
616 6d022e97 2019-08-04 stsp echo -n > $testroot/stderr.expected
617 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
618 9acbc4fa 2019-08-03 stsp ret="$?"
619 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
620 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
621 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
622 9acbc4fa 2019-08-03 stsp return 1
623 9acbc4fa 2019-08-03 stsp fi
624 9acbc4fa 2019-08-03 stsp
625 9acbc4fa 2019-08-03 stsp for f in alpha foo; do
626 24278f30 2019-08-03 stsp echo "got: $f: file is staged" > $testroot/stderr.expected
627 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got rm $f \
628 9acbc4fa 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
629 9acbc4fa 2019-08-03 stsp ret="$?"
630 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
631 9acbc4fa 2019-08-03 stsp echo "got rm command succeeded unexpectedly" >&2
632 9acbc4fa 2019-08-03 stsp test_done "$testroot" "1"
633 9acbc4fa 2019-08-03 stsp return 1
634 9acbc4fa 2019-08-03 stsp fi
635 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
636 9acbc4fa 2019-08-03 stsp ret="$?"
637 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
638 9acbc4fa 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
639 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
640 9acbc4fa 2019-08-03 stsp return 1
641 9acbc4fa 2019-08-03 stsp fi
642 9acbc4fa 2019-08-03 stsp done
643 9acbc4fa 2019-08-03 stsp
644 9acbc4fa 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
645 9acbc4fa 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
646 9acbc4fa 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
647 9acbc4fa 2019-08-03 stsp
648 9acbc4fa 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
649 9acbc4fa 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
650 9acbc4fa 2019-08-03 stsp ret="$?"
651 9acbc4fa 2019-08-03 stsp if [ "$ret" != "0" ]; then
652 9acbc4fa 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
653 9acbc4fa 2019-08-03 stsp fi
654 9acbc4fa 2019-08-03 stsp test_done "$testroot" "$ret"
655 9acbc4fa 2019-08-03 stsp }
656 24278f30 2019-08-03 stsp
657 f6cae3ed 2020-09-13 naddy test_stage_revert() {
658 24278f30 2019-08-03 stsp local testroot=`test_init stage_revert`
659 24278f30 2019-08-03 stsp
660 24278f30 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
661 24278f30 2019-08-03 stsp ret="$?"
662 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
663 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
664 24278f30 2019-08-03 stsp return 1
665 24278f30 2019-08-03 stsp fi
666 24278f30 2019-08-03 stsp
667 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
668 24278f30 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
669 24278f30 2019-08-03 stsp echo "new file" > $testroot/wt/foo
670 24278f30 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
671 24278f30 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
672 24278f30 2019-08-03 stsp
673 24278f30 2019-08-03 stsp echo "modified file again" >> $testroot/wt/alpha
674 24278f30 2019-08-03 stsp echo "modified added file again" >> $testroot/wt/foo
675 24278f30 2019-08-03 stsp
676 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
677 24278f30 2019-08-03 stsp ret="$?"
678 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
679 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
680 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
681 24278f30 2019-08-03 stsp return 1
682 24278f30 2019-08-03 stsp fi
683 24278f30 2019-08-03 stsp
684 24278f30 2019-08-03 stsp echo "R alpha" > $testroot/stdout.expected
685 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
686 24278f30 2019-08-03 stsp ret="$?"
687 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
688 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
689 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
690 24278f30 2019-08-03 stsp return 1
691 24278f30 2019-08-03 stsp fi
692 24278f30 2019-08-03 stsp
693 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
694 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
695 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
696 24278f30 2019-08-03 stsp ret="$?"
697 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
698 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
699 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
700 24278f30 2019-08-03 stsp return 1
701 24278f30 2019-08-03 stsp fi
702 9acbc4fa 2019-08-03 stsp
703 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
704 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
705 24278f30 2019-08-03 stsp echo 'MA foo' >> $testroot/stdout.expected
706 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
707 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
708 24278f30 2019-08-03 stsp ret="$?"
709 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
710 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
711 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
712 24278f30 2019-08-03 stsp return 1
713 24278f30 2019-08-03 stsp fi
714 24278f30 2019-08-03 stsp
715 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert alpha > $testroot/stdout)
716 24278f30 2019-08-03 stsp ret="$?"
717 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
718 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
719 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
720 24278f30 2019-08-03 stsp return 1
721 24278f30 2019-08-03 stsp fi
722 24278f30 2019-08-03 stsp
723 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
724 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
725 24278f30 2019-08-03 stsp ret="$?"
726 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
727 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
728 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
729 24278f30 2019-08-03 stsp return 1
730 24278f30 2019-08-03 stsp fi
731 24278f30 2019-08-03 stsp
732 24278f30 2019-08-03 stsp echo "modified alpha" > $testroot/content.expected
733 24278f30 2019-08-03 stsp cat $testroot/wt/alpha > $testroot/content
734 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
735 24278f30 2019-08-03 stsp ret="$?"
736 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
737 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
738 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
739 24278f30 2019-08-03 stsp return 1
740 24278f30 2019-08-03 stsp fi
741 24278f30 2019-08-03 stsp
742 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert beta > $testroot/stdout \
743 24278f30 2019-08-03 stsp 2> $testroot/stderr)
744 24278f30 2019-08-03 stsp ret="$?"
745 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
746 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
747 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
748 24278f30 2019-08-03 stsp return 1
749 24278f30 2019-08-03 stsp fi
750 24278f30 2019-08-03 stsp
751 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stdout.expected
752 d3bcc3d1 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
753 d3bcc3d1 2019-08-08 stsp ret="$?"
754 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
755 d3bcc3d1 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
756 d3bcc3d1 2019-08-08 stsp test_done "$testroot" "$ret"
757 d3bcc3d1 2019-08-08 stsp return 1
758 d3bcc3d1 2019-08-08 stsp fi
759 d3bcc3d1 2019-08-08 stsp
760 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
761 24278f30 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
762 24278f30 2019-08-03 stsp ret="$?"
763 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
764 24278f30 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
765 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
766 24278f30 2019-08-03 stsp return 1
767 24278f30 2019-08-03 stsp fi
768 24278f30 2019-08-03 stsp
769 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
770 24278f30 2019-08-03 stsp ret="$?"
771 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
772 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
773 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
774 24278f30 2019-08-03 stsp return 1
775 24278f30 2019-08-03 stsp fi
776 24278f30 2019-08-03 stsp
777 24278f30 2019-08-03 stsp echo "R foo" > $testroot/stdout.expected
778 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
779 24278f30 2019-08-03 stsp ret="$?"
780 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
781 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
782 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
783 24278f30 2019-08-03 stsp return 1
784 24278f30 2019-08-03 stsp fi
785 24278f30 2019-08-03 stsp
786 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
787 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
788 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
789 24278f30 2019-08-03 stsp ret="$?"
790 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
791 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
792 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
793 24278f30 2019-08-03 stsp return 1
794 24278f30 2019-08-03 stsp fi
795 24278f30 2019-08-03 stsp
796 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
797 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
798 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
799 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
800 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
801 24278f30 2019-08-03 stsp ret="$?"
802 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
803 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
804 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
805 24278f30 2019-08-03 stsp return 1
806 24278f30 2019-08-03 stsp fi
807 24278f30 2019-08-03 stsp
808 24278f30 2019-08-03 stsp (cd $testroot/wt && got revert foo > $testroot/stdout)
809 24278f30 2019-08-03 stsp ret="$?"
810 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
811 24278f30 2019-08-03 stsp echo "revert command failed unexpectedly" >&2
812 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
813 24278f30 2019-08-03 stsp return 1
814 24278f30 2019-08-03 stsp fi
815 24278f30 2019-08-03 stsp
816 24278f30 2019-08-03 stsp echo -n > $testroot/stdout.expected
817 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
818 24278f30 2019-08-03 stsp ret="$?"
819 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
820 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
821 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
822 24278f30 2019-08-03 stsp return 1
823 24278f30 2019-08-03 stsp fi
824 24278f30 2019-08-03 stsp
825 24278f30 2019-08-03 stsp echo "new file" > $testroot/content.expected
826 24278f30 2019-08-03 stsp cat $testroot/wt/foo > $testroot/content
827 24278f30 2019-08-03 stsp cmp -s $testroot/content.expected $testroot/content
828 24278f30 2019-08-03 stsp ret="$?"
829 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
830 24278f30 2019-08-03 stsp diff -u $testroot/content.expected $testroot/content
831 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
832 24278f30 2019-08-03 stsp return 1
833 24278f30 2019-08-03 stsp fi
834 24278f30 2019-08-03 stsp
835 24278f30 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
836 24278f30 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
837 24278f30 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
838 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
839 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
840 0f6d7415 2019-08-08 stsp ret="$?"
841 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
842 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
843 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
844 0f6d7415 2019-08-08 stsp return 1
845 0f6d7415 2019-08-08 stsp fi
846 0f6d7415 2019-08-08 stsp
847 0f6d7415 2019-08-08 stsp echo "modified file again" >> $testroot/wt/alpha
848 0f6d7415 2019-08-08 stsp echo "modified added file again" >> $testroot/wt/foo
849 0f6d7415 2019-08-08 stsp
850 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout \
851 0f6d7415 2019-08-08 stsp 2> $testroot/stderr)
852 0f6d7415 2019-08-08 stsp ret="$?"
853 d3bcc3d1 2019-08-08 stsp if [ "$ret" != "0" ]; then
854 d3bcc3d1 2019-08-08 stsp echo "revert command failed unexpectedly" >&2
855 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
856 0f6d7415 2019-08-08 stsp return 1
857 0f6d7415 2019-08-08 stsp fi
858 0f6d7415 2019-08-08 stsp
859 0f6d7415 2019-08-08 stsp echo "R alpha" > $testroot/stdout.expected
860 d3bcc3d1 2019-08-08 stsp echo "R foo" >> $testroot/stdout.expected
861 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
862 0f6d7415 2019-08-08 stsp ret="$?"
863 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
864 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
865 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
866 0f6d7415 2019-08-08 stsp return 1
867 0f6d7415 2019-08-08 stsp fi
868 0f6d7415 2019-08-08 stsp
869 d3bcc3d1 2019-08-08 stsp echo -n > $testroot/stderr.expected
870 0f6d7415 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
871 0f6d7415 2019-08-08 stsp ret="$?"
872 0f6d7415 2019-08-08 stsp if [ "$ret" != "0" ]; then
873 0f6d7415 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
874 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
875 0f6d7415 2019-08-08 stsp return 1
876 0f6d7415 2019-08-08 stsp fi
877 0f6d7415 2019-08-08 stsp
878 0f6d7415 2019-08-08 stsp echo ' M alpha' > $testroot/stdout.expected
879 0f6d7415 2019-08-08 stsp echo ' D beta' >> $testroot/stdout.expected
880 d3bcc3d1 2019-08-08 stsp echo ' A foo' >> $testroot/stdout.expected
881 24278f30 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
882 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
883 408b4ebc 2019-08-03 stsp ret="$?"
884 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
885 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
886 408b4ebc 2019-08-03 stsp fi
887 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
888 408b4ebc 2019-08-03 stsp }
889 408b4ebc 2019-08-03 stsp
890 f6cae3ed 2020-09-13 naddy test_stage_diff() {
891 408b4ebc 2019-08-03 stsp local testroot=`test_init stage_diff`
892 408b4ebc 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
893 408b4ebc 2019-08-03 stsp
894 408b4ebc 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
895 408b4ebc 2019-08-03 stsp ret="$?"
896 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
897 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
898 408b4ebc 2019-08-03 stsp return 1
899 408b4ebc 2019-08-03 stsp fi
900 408b4ebc 2019-08-03 stsp
901 408b4ebc 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
902 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
903 408b4ebc 2019-08-03 stsp echo "new file" > $testroot/wt/foo
904 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
905 98eaaa12 2019-08-03 stsp
906 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
907 98eaaa12 2019-08-03 stsp echo -n > $testroot/stdout.expected
908 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
909 98eaaa12 2019-08-03 stsp ret="$?"
910 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
911 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
912 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
913 98eaaa12 2019-08-03 stsp return 1
914 98eaaa12 2019-08-03 stsp fi
915 408b4ebc 2019-08-03 stsp
916 408b4ebc 2019-08-03 stsp echo ' M alpha' > $testroot/stdout.expected
917 408b4ebc 2019-08-03 stsp echo ' D beta' >> $testroot/stdout.expected
918 408b4ebc 2019-08-03 stsp echo ' A foo' >> $testroot/stdout.expected
919 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
920 408b4ebc 2019-08-03 stsp
921 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
922 408b4ebc 2019-08-03 stsp echo -n > $testroot/stdout.expected
923 408b4ebc 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
924 408b4ebc 2019-08-03 stsp ret="$?"
925 408b4ebc 2019-08-03 stsp if [ "$ret" != "0" ]; then
926 408b4ebc 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
927 408b4ebc 2019-08-03 stsp test_done "$testroot" "$ret"
928 408b4ebc 2019-08-03 stsp return 1
929 408b4ebc 2019-08-03 stsp fi
930 408b4ebc 2019-08-03 stsp
931 408b4ebc 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
932 408b4ebc 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
933 408b4ebc 2019-08-03 stsp
934 408b4ebc 2019-08-03 stsp (cd $testroot/wt && got diff > $testroot/stdout)
935 408b4ebc 2019-08-03 stsp
936 408b4ebc 2019-08-03 stsp echo "diff $head_commit $testroot/wt" > $testroot/stdout.expected
937 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
938 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 | tr -d '\n' \
939 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
940 4ce46740 2019-08-08 stsp echo ' (staged)' >> $testroot/stdout.expected
941 408b4ebc 2019-08-03 stsp echo 'file + alpha' >> $testroot/stdout.expected
942 408b4ebc 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
943 408b4ebc 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
944 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
945 408b4ebc 2019-08-03 stsp echo '-modified file' >> $testroot/stdout.expected
946 408b4ebc 2019-08-03 stsp echo '+modified file again' >> $testroot/stdout.expected
947 408b4ebc 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
948 4ce46740 2019-08-08 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 | tr -d '\n' \
949 408b4ebc 2019-08-03 stsp >> $testroot/stdout.expected
950 4ce46740 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
951 408b4ebc 2019-08-03 stsp echo 'file + foo' >> $testroot/stdout.expected
952 408b4ebc 2019-08-03 stsp echo '--- foo' >> $testroot/stdout.expected
953 408b4ebc 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
954 408b4ebc 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
955 408b4ebc 2019-08-03 stsp echo '-new file' >> $testroot/stdout.expected
956 408b4ebc 2019-08-03 stsp echo '+new file changed' >> $testroot/stdout.expected
957 98eaaa12 2019-08-03 stsp
958 98eaaa12 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
959 98eaaa12 2019-08-03 stsp ret="$?"
960 98eaaa12 2019-08-03 stsp if [ "$ret" != "0" ]; then
961 98eaaa12 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
962 98eaaa12 2019-08-03 stsp test_done "$testroot" "$ret"
963 98eaaa12 2019-08-03 stsp return 1
964 98eaaa12 2019-08-03 stsp fi
965 98eaaa12 2019-08-03 stsp
966 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
967 98eaaa12 2019-08-03 stsp
968 98eaaa12 2019-08-03 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
969 98eaaa12 2019-08-03 stsp > $testroot/stdout.expected
970 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
971 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
972 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
973 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
974 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
975 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
976 98eaaa12 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
977 98eaaa12 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
978 98eaaa12 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
979 98eaaa12 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
980 98eaaa12 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
981 98eaaa12 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
982 98eaaa12 2019-08-03 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
983 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
984 98eaaa12 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
985 98eaaa12 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
986 98eaaa12 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
987 98eaaa12 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
988 98eaaa12 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
989 98eaaa12 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
990 98eaaa12 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
991 98eaaa12 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
992 98eaaa12 2019-08-03 stsp >> $testroot/stdout.expected
993 98eaaa12 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
994 98eaaa12 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
995 98eaaa12 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
996 98eaaa12 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
997 408b4ebc 2019-08-03 stsp
998 24278f30 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
999 24278f30 2019-08-03 stsp ret="$?"
1000 24278f30 2019-08-03 stsp if [ "$ret" != "0" ]; then
1001 24278f30 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1002 24278f30 2019-08-03 stsp fi
1003 24278f30 2019-08-03 stsp test_done "$testroot" "$ret"
1004 408b4ebc 2019-08-03 stsp
1005 24278f30 2019-08-03 stsp }
1006 b9622844 2019-08-03 stsp
1007 f6cae3ed 2020-09-13 naddy test_stage_histedit() {
1008 b9622844 2019-08-03 stsp local testroot=`test_init stage_histedit`
1009 b9622844 2019-08-03 stsp local orig_commit=`git_show_head $testroot/repo`
1010 b9622844 2019-08-03 stsp
1011 b9622844 2019-08-03 stsp got checkout -c $orig_commit $testroot/repo $testroot/wt > /dev/null
1012 b9622844 2019-08-03 stsp ret="$?"
1013 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1014 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1015 b9622844 2019-08-03 stsp return 1
1016 b9622844 2019-08-03 stsp fi
1017 b9622844 2019-08-03 stsp
1018 b9622844 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1019 b9622844 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1020 b9622844 2019-08-03 stsp
1021 b9622844 2019-08-03 stsp echo "modified alpha on master" > $testroot/repo/alpha
1022 b9622844 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1023 b9622844 2019-08-03 stsp echo "new file on master" > $testroot/repo/epsilon/new
1024 b9622844 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1025 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing changes"
1026 b9622844 2019-08-03 stsp local old_commit1=`git_show_head $testroot/repo`
1027 24278f30 2019-08-03 stsp
1028 b9622844 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1029 b9622844 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1030 b9622844 2019-08-03 stsp local old_commit2=`git_show_head $testroot/repo`
1031 b9622844 2019-08-03 stsp
1032 b9622844 2019-08-03 stsp echo "pick $old_commit1" > $testroot/histedit-script
1033 b9622844 2019-08-03 stsp echo "pick $old_commit2" >> $testroot/histedit-script
1034 b9622844 2019-08-03 stsp
1035 b9622844 2019-08-03 stsp (cd $testroot/wt && got histedit -F $testroot/histedit-script \
1036 b9622844 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1037 b9622844 2019-08-03 stsp ret="$?"
1038 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1039 b9622844 2019-08-03 stsp echo "got histedit command succeeded unexpectedly" >&2
1040 b9622844 2019-08-03 stsp test_done "$testroot" "1"
1041 b9622844 2019-08-03 stsp return 1
1042 b9622844 2019-08-03 stsp fi
1043 b9622844 2019-08-03 stsp
1044 b9622844 2019-08-03 stsp echo -n > $testroot/stdout.expected
1045 b9622844 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1046 b9622844 2019-08-03 stsp
1047 b9622844 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1048 b9622844 2019-08-03 stsp ret="$?"
1049 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1050 b9622844 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1051 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1052 b9622844 2019-08-03 stsp return 1
1053 b9622844 2019-08-03 stsp fi
1054 b9622844 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1055 b9622844 2019-08-03 stsp ret="$?"
1056 b9622844 2019-08-03 stsp if [ "$ret" != "0" ]; then
1057 b9622844 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1058 b9622844 2019-08-03 stsp fi
1059 b9622844 2019-08-03 stsp test_done "$testroot" "$ret"
1060 243d7cf1 2019-08-03 stsp
1061 243d7cf1 2019-08-03 stsp }
1062 243d7cf1 2019-08-03 stsp
1063 f6cae3ed 2020-09-13 naddy test_stage_rebase() {
1064 243d7cf1 2019-08-03 stsp local testroot=`test_init stage_rebase`
1065 243d7cf1 2019-08-03 stsp
1066 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1067 243d7cf1 2019-08-03 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1068 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1069 243d7cf1 2019-08-03 stsp
1070 243d7cf1 2019-08-03 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1071 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git rm -q beta)
1072 243d7cf1 2019-08-03 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1073 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git add epsilon/new)
1074 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1075 243d7cf1 2019-08-03 stsp
1076 243d7cf1 2019-08-03 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1077 243d7cf1 2019-08-03 stsp local orig_commit2=`git_show_head $testroot/repo`
1078 243d7cf1 2019-08-03 stsp
1079 243d7cf1 2019-08-03 stsp (cd $testroot/repo && git checkout -q master)
1080 243d7cf1 2019-08-03 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1081 243d7cf1 2019-08-03 stsp git_commit $testroot/repo -m "committing to zeta on master"
1082 243d7cf1 2019-08-03 stsp local master_commit=`git_show_head $testroot/repo`
1083 243d7cf1 2019-08-03 stsp
1084 243d7cf1 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1085 243d7cf1 2019-08-03 stsp ret="$?"
1086 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1087 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1088 243d7cf1 2019-08-03 stsp return 1
1089 243d7cf1 2019-08-03 stsp fi
1090 243d7cf1 2019-08-03 stsp
1091 243d7cf1 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1092 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1093 b9622844 2019-08-03 stsp
1094 243d7cf1 2019-08-03 stsp (cd $testroot/wt && got rebase newbranch \
1095 243d7cf1 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1096 243d7cf1 2019-08-03 stsp ret="$?"
1097 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1098 243d7cf1 2019-08-03 stsp echo "got rebase command succeeded unexpectedly" >&2
1099 243d7cf1 2019-08-03 stsp test_done "$testroot" "1"
1100 243d7cf1 2019-08-03 stsp return 1
1101 243d7cf1 2019-08-03 stsp fi
1102 243d7cf1 2019-08-03 stsp
1103 243d7cf1 2019-08-03 stsp echo -n > $testroot/stdout.expected
1104 243d7cf1 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1105 243d7cf1 2019-08-03 stsp
1106 243d7cf1 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1107 243d7cf1 2019-08-03 stsp ret="$?"
1108 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1109 243d7cf1 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1110 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1111 243d7cf1 2019-08-03 stsp return 1
1112 243d7cf1 2019-08-03 stsp fi
1113 243d7cf1 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1114 243d7cf1 2019-08-03 stsp ret="$?"
1115 243d7cf1 2019-08-03 stsp if [ "$ret" != "0" ]; then
1116 243d7cf1 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1117 243d7cf1 2019-08-03 stsp fi
1118 243d7cf1 2019-08-03 stsp test_done "$testroot" "$ret"
1119 b9622844 2019-08-03 stsp }
1120 b9622844 2019-08-03 stsp
1121 f6cae3ed 2020-09-13 naddy test_stage_update() {
1122 a76c42e6 2019-08-03 stsp local testroot=`test_init stage_update`
1123 a76c42e6 2019-08-03 stsp
1124 a76c42e6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1125 a76c42e6 2019-08-03 stsp ret="$?"
1126 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1127 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1128 a76c42e6 2019-08-03 stsp return 1
1129 a76c42e6 2019-08-03 stsp fi
1130 243d7cf1 2019-08-03 stsp
1131 a76c42e6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1132 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got stage alpha > /dev/null)
1133 a76c42e6 2019-08-03 stsp
1134 a76c42e6 2019-08-03 stsp echo "modified alpha" > $testroot/repo/alpha
1135 a76c42e6 2019-08-03 stsp git_commit $testroot/repo -m "modified alpha"
1136 a76c42e6 2019-08-03 stsp
1137 a76c42e6 2019-08-03 stsp (cd $testroot/wt && got update > $testroot/stdout \
1138 a76c42e6 2019-08-03 stsp 2> $testroot/stderr)
1139 a76c42e6 2019-08-03 stsp ret="$?"
1140 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1141 a76c42e6 2019-08-03 stsp echo "got update command succeeded unexpectedly" >&2
1142 a76c42e6 2019-08-03 stsp test_done "$testroot" "1"
1143 a76c42e6 2019-08-03 stsp return 1
1144 a76c42e6 2019-08-03 stsp fi
1145 a76c42e6 2019-08-03 stsp
1146 a76c42e6 2019-08-03 stsp echo -n > $testroot/stdout.expected
1147 a76c42e6 2019-08-03 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1148 a76c42e6 2019-08-03 stsp
1149 a76c42e6 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1150 a76c42e6 2019-08-03 stsp ret="$?"
1151 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1152 a76c42e6 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1153 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1154 a76c42e6 2019-08-03 stsp return 1
1155 a76c42e6 2019-08-03 stsp fi
1156 a76c42e6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1157 a76c42e6 2019-08-03 stsp ret="$?"
1158 a76c42e6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1159 a76c42e6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1160 a76c42e6 2019-08-03 stsp fi
1161 a76c42e6 2019-08-03 stsp test_done "$testroot" "$ret"
1162 a76c42e6 2019-08-03 stsp }
1163 f0b75401 2019-08-03 stsp
1164 f6cae3ed 2020-09-13 naddy test_stage_commit_non_staged() {
1165 f0b75401 2019-08-03 stsp local testroot=`test_init stage_commit_non_staged`
1166 f0b75401 2019-08-03 stsp
1167 f0b75401 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1168 f0b75401 2019-08-03 stsp ret="$?"
1169 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1170 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1171 f0b75401 2019-08-03 stsp return 1
1172 f0b75401 2019-08-03 stsp fi
1173 f0b75401 2019-08-03 stsp
1174 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1175 f0b75401 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1176 f0b75401 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1177 f0b75401 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1178 f0b75401 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1179 a76c42e6 2019-08-03 stsp
1180 f0b75401 2019-08-03 stsp echo "modified file" > $testroot/wt/gamma/delta
1181 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m "change delta" gamma/delta \
1182 f0b75401 2019-08-03 stsp > $testroot/stdout 2> $testroot/stderr)
1183 f0b75401 2019-08-03 stsp ret="$?"
1184 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1185 f0b75401 2019-08-03 stsp echo "got commit command succeeded unexpectedly" >&2
1186 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
1187 f0b75401 2019-08-03 stsp return 1
1188 f0b75401 2019-08-03 stsp fi
1189 f0b75401 2019-08-03 stsp
1190 f0b75401 2019-08-03 stsp echo -n > $testroot/stdout.expected
1191 f0b75401 2019-08-03 stsp echo "got: gamma/delta: file is not staged" > $testroot/stderr.expected
1192 f0b75401 2019-08-03 stsp
1193 f0b75401 2019-08-03 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1194 f0b75401 2019-08-03 stsp ret="$?"
1195 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1196 f0b75401 2019-08-03 stsp diff -u $testroot/stderr.expected $testroot/stderr
1197 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1198 5f8a88c6 2019-08-03 stsp return 1
1199 5f8a88c6 2019-08-03 stsp fi
1200 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1201 5f8a88c6 2019-08-03 stsp ret="$?"
1202 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1203 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1204 5f8a88c6 2019-08-03 stsp fi
1205 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1206 5f8a88c6 2019-08-03 stsp }
1207 0f1cfa7f 2019-08-08 stsp
1208 f6cae3ed 2020-09-13 naddy test_stage_commit_out_of_date() {
1209 0f1cfa7f 2019-08-08 stsp local testroot=`test_init stage_commit_out_of_date`
1210 0f1cfa7f 2019-08-08 stsp
1211 0f1cfa7f 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1212 0f1cfa7f 2019-08-08 stsp ret="$?"
1213 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1214 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1215 0f1cfa7f 2019-08-08 stsp return 1
1216 0f1cfa7f 2019-08-08 stsp fi
1217 0f1cfa7f 2019-08-08 stsp
1218 0f1cfa7f 2019-08-08 stsp echo "modified file" > $testroot/wt/alpha
1219 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
1220 0f1cfa7f 2019-08-08 stsp echo "new file" > $testroot/wt/foo
1221 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got add foo > /dev/null)
1222 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1223 0f1cfa7f 2019-08-08 stsp
1224 0f1cfa7f 2019-08-08 stsp echo "changed file" > $testroot/repo/alpha
1225 0f1cfa7f 2019-08-08 stsp git_commit $testroot/repo -m "changed alpha in repo"
1226 0f1cfa7f 2019-08-08 stsp
1227 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try to commit" > $testroot/stdout \
1228 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1229 0f1cfa7f 2019-08-08 stsp ret="$?"
1230 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1231 0f1cfa7f 2019-08-08 stsp echo "got commit command succeeded unexpectedly" >&2
1232 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "1"
1233 0f1cfa7f 2019-08-08 stsp return 1
1234 0f1cfa7f 2019-08-08 stsp fi
1235 0f1cfa7f 2019-08-08 stsp
1236 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1237 0f1cfa7f 2019-08-08 stsp echo -n "got: work tree must be updated before these changes " \
1238 0f1cfa7f 2019-08-08 stsp > $testroot/stderr.expected
1239 0f1cfa7f 2019-08-08 stsp echo "can be committed" >> $testroot/stderr.expected
1240 5f8a88c6 2019-08-03 stsp
1241 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1242 0f1cfa7f 2019-08-08 stsp ret="$?"
1243 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1244 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1245 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1246 0f1cfa7f 2019-08-08 stsp return 1
1247 0f1cfa7f 2019-08-08 stsp fi
1248 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1249 0f1cfa7f 2019-08-08 stsp ret="$?"
1250 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1251 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1252 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1253 0f1cfa7f 2019-08-08 stsp return 1
1254 0f1cfa7f 2019-08-08 stsp fi
1255 0f1cfa7f 2019-08-08 stsp
1256 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout \
1257 0f1cfa7f 2019-08-08 stsp 2> $testroot/stderr)
1258 0f1cfa7f 2019-08-08 stsp echo -n > $testroot/stdout.expected
1259 0f1cfa7f 2019-08-08 stsp echo "got: alpha: file is staged" > $testroot/stderr.expected
1260 0f1cfa7f 2019-08-08 stsp
1261 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1262 0f1cfa7f 2019-08-08 stsp ret="$?"
1263 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1264 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1265 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1266 0f1cfa7f 2019-08-08 stsp return 1
1267 0f1cfa7f 2019-08-08 stsp fi
1268 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1269 0f1cfa7f 2019-08-08 stsp ret="$?"
1270 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1271 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1272 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1273 0f1cfa7f 2019-08-08 stsp return 1
1274 0f1cfa7f 2019-08-08 stsp fi
1275 0f1cfa7f 2019-08-08 stsp
1276 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got unstage > /dev/null)
1277 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
1278 0f1cfa7f 2019-08-08 stsp ret="$?"
1279 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1280 0f1cfa7f 2019-08-08 stsp echo "got update command failed unexpectedly" >&2
1281 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1282 0f1cfa7f 2019-08-08 stsp return 1
1283 0f1cfa7f 2019-08-08 stsp fi
1284 0f1cfa7f 2019-08-08 stsp
1285 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1286 0f1cfa7f 2019-08-08 stsp echo "C alpha" > $testroot/stdout.expected
1287 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1288 0f1cfa7f 2019-08-08 stsp echo "A foo" >> $testroot/stdout.expected
1289 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1290 0f1cfa7f 2019-08-08 stsp ret="$?"
1291 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1292 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1293 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1294 0f1cfa7f 2019-08-08 stsp return 1
1295 0f1cfa7f 2019-08-08 stsp fi
1296 0f1cfa7f 2019-08-08 stsp
1297 0f1cfa7f 2019-08-08 stsp # resolve conflict
1298 0f1cfa7f 2019-08-08 stsp echo "resolved file" > $testroot/wt/alpha
1299 0f1cfa7f 2019-08-08 stsp
1300 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got stage > /dev/null)
1301 0f1cfa7f 2019-08-08 stsp
1302 0f1cfa7f 2019-08-08 stsp (cd $testroot/wt && got commit -m "try again" > $testroot/stdout)
1303 0f1cfa7f 2019-08-08 stsp ret="$?"
1304 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1305 0f1cfa7f 2019-08-08 stsp echo "got commit command failed unexpectedly" >&2
1306 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1307 0f1cfa7f 2019-08-08 stsp return 1
1308 0f1cfa7f 2019-08-08 stsp fi
1309 0f1cfa7f 2019-08-08 stsp
1310 0f1cfa7f 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1311 0f1cfa7f 2019-08-08 stsp echo "A foo" > $testroot/stdout.expected
1312 0f1cfa7f 2019-08-08 stsp echo "M alpha" >> $testroot/stdout.expected
1313 0f1cfa7f 2019-08-08 stsp echo "D beta" >> $testroot/stdout.expected
1314 0f1cfa7f 2019-08-08 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
1315 0f1cfa7f 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1316 0f1cfa7f 2019-08-08 stsp ret="$?"
1317 0f1cfa7f 2019-08-08 stsp if [ "$ret" != "0" ]; then
1318 0f1cfa7f 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1319 0f1cfa7f 2019-08-08 stsp fi
1320 0f1cfa7f 2019-08-08 stsp test_done "$testroot" "$ret"
1321 0f1cfa7f 2019-08-08 stsp
1322 0f1cfa7f 2019-08-08 stsp }
1323 0f1cfa7f 2019-08-08 stsp
1324 f6cae3ed 2020-09-13 naddy test_stage_commit() {
1325 5f8a88c6 2019-08-03 stsp local testroot=`test_init stage_commit`
1326 5f8a88c6 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
1327 5f8a88c6 2019-08-03 stsp
1328 5f8a88c6 2019-08-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1329 5f8a88c6 2019-08-03 stsp ret="$?"
1330 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1331 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1332 5f8a88c6 2019-08-03 stsp return 1
1333 5f8a88c6 2019-08-03 stsp fi
1334 5f8a88c6 2019-08-03 stsp
1335 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1336 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm beta > /dev/null)
1337 5f8a88c6 2019-08-03 stsp echo "new file" > $testroot/wt/foo
1338 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add foo > /dev/null)
1339 5f8a88c6 2019-08-03 stsp echo "modified file" > $testroot/wt/alpha
1340 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage alpha beta foo > /dev/null)
1341 5f8a88c6 2019-08-03 stsp
1342 5f8a88c6 2019-08-03 stsp echo "modified file again" > $testroot/wt/alpha
1343 5f8a88c6 2019-08-03 stsp echo "new file changed" > $testroot/wt/foo
1344 5f8a88c6 2019-08-03 stsp echo "non-staged change" > $testroot/wt/gamma/delta
1345 5f8a88c6 2019-08-03 stsp echo "non-staged new file" > $testroot/wt/epsilon/new
1346 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1347 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got rm epsilon/zeta > /dev/null)
1348 5f8a88c6 2019-08-03 stsp
1349 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l alpha) | cut -d' ' -f 1 \
1350 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_alpha
1351 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got stage -l foo) | cut -d' ' -f 1 \
1352 5f8a88c6 2019-08-03 stsp > $testroot/blob_id_foo
1353 5f8a88c6 2019-08-03 stsp
1354 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got commit -m "staged changes" \
1355 5f8a88c6 2019-08-03 stsp > $testroot/stdout)
1356 5f8a88c6 2019-08-03 stsp ret="$?"
1357 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1358 5f8a88c6 2019-08-03 stsp echo "got commit command failed unexpectedly" >&2
1359 5f8a88c6 2019-08-03 stsp test_done "$testroot" "1"
1360 5f8a88c6 2019-08-03 stsp return 1
1361 5f8a88c6 2019-08-03 stsp fi
1362 5f8a88c6 2019-08-03 stsp
1363 5f8a88c6 2019-08-03 stsp local head_commit=`git_show_head $testroot/repo`
1364 5f8a88c6 2019-08-03 stsp echo "A foo" > $testroot/stdout.expected
1365 5f8a88c6 2019-08-03 stsp echo "M alpha" >> $testroot/stdout.expected
1366 5f8a88c6 2019-08-03 stsp echo "D beta" >> $testroot/stdout.expected
1367 5f8a88c6 2019-08-03 stsp echo "Created commit $head_commit" >> $testroot/stdout.expected
1368 5f8a88c6 2019-08-03 stsp
1369 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1370 5f8a88c6 2019-08-03 stsp ret="$?"
1371 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1372 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1373 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1374 f0b75401 2019-08-03 stsp return 1
1375 f0b75401 2019-08-03 stsp fi
1376 5f8a88c6 2019-08-03 stsp
1377 5f8a88c6 2019-08-03 stsp got diff -r $testroot/repo $first_commit $head_commit \
1378 5f8a88c6 2019-08-03 stsp > $testroot/stdout
1379 5f8a88c6 2019-08-03 stsp
1380 5f8a88c6 2019-08-03 stsp echo "diff $first_commit $head_commit" \
1381 5f8a88c6 2019-08-03 stsp > $testroot/stdout.expected
1382 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1383 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit | \
1384 5f8a88c6 2019-08-03 stsp grep 'alpha$' | cut -d' ' -f 1 \
1385 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1386 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1387 5f8a88c6 2019-08-03 stsp cat $testroot/blob_id_alpha >> $testroot/stdout.expected
1388 5f8a88c6 2019-08-03 stsp echo '--- alpha' >> $testroot/stdout.expected
1389 5f8a88c6 2019-08-03 stsp echo '+++ alpha' >> $testroot/stdout.expected
1390 5f8a88c6 2019-08-03 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1391 5f8a88c6 2019-08-03 stsp echo '-alpha' >> $testroot/stdout.expected
1392 5f8a88c6 2019-08-03 stsp echo '+modified file' >> $testroot/stdout.expected
1393 5f8a88c6 2019-08-03 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1394 5f8a88c6 2019-08-03 stsp got tree -r $testroot/repo -i -c $first_commit \
1395 46f68b20 2019-10-19 stsp | grep 'beta$' | cut -d' ' -f 1 | tr -d '\n' \
1396 5f8a88c6 2019-08-03 stsp >> $testroot/stdout.expected
1397 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
1398 5f8a88c6 2019-08-03 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1399 5f8a88c6 2019-08-03 stsp echo '--- beta' >> $testroot/stdout.expected
1400 5f8a88c6 2019-08-03 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1401 5f8a88c6 2019-08-03 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1402 5f8a88c6 2019-08-03 stsp echo '-beta' >> $testroot/stdout.expected
1403 5f8a88c6 2019-08-03 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1404 5f8a88c6 2019-08-03 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1405 46f68b20 2019-10-19 stsp cat $testroot/blob_id_foo | tr -d '\n' >> $testroot/stdout.expected
1406 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
1407 5f8a88c6 2019-08-03 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1408 5f8a88c6 2019-08-03 stsp echo '+++ foo' >> $testroot/stdout.expected
1409 5f8a88c6 2019-08-03 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1410 5f8a88c6 2019-08-03 stsp echo '+new file' >> $testroot/stdout.expected
1411 5f8a88c6 2019-08-03 stsp
1412 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1413 f0b75401 2019-08-03 stsp ret="$?"
1414 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
1415 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1416 5f8a88c6 2019-08-03 stsp test_done "$testroot" "$ret"
1417 5f8a88c6 2019-08-03 stsp return 1
1418 f0b75401 2019-08-03 stsp fi
1419 5f8a88c6 2019-08-03 stsp
1420 72fd46fa 2019-09-06 stsp echo 'M alpha' > $testroot/stdout.expected
1421 72fd46fa 2019-09-06 stsp echo 'A epsilon/new' >> $testroot/stdout.expected
1422 5f8a88c6 2019-08-03 stsp echo 'D epsilon/zeta' >> $testroot/stdout.expected
1423 72fd46fa 2019-09-06 stsp echo 'M foo' >> $testroot/stdout.expected
1424 5f8a88c6 2019-08-03 stsp echo 'M gamma/delta' >> $testroot/stdout.expected
1425 5f8a88c6 2019-08-03 stsp
1426 5f8a88c6 2019-08-03 stsp (cd $testroot/wt && got status > $testroot/stdout)
1427 5f8a88c6 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1428 5f8a88c6 2019-08-03 stsp ret="$?"
1429 5f8a88c6 2019-08-03 stsp if [ "$ret" != "0" ]; then
1430 5f8a88c6 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1431 5f8a88c6 2019-08-03 stsp fi
1432 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
1433 f0b75401 2019-08-03 stsp }
1434 dc424a06 2019-08-07 stsp
1435 f6cae3ed 2020-09-13 naddy test_stage_patch() {
1436 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch`
1437 dc424a06 2019-08-07 stsp
1438 dc424a06 2019-08-07 stsp jot 16 > $testroot/repo/numbers
1439 dc424a06 2019-08-07 stsp (cd $testroot/repo && git add numbers)
1440 dc424a06 2019-08-07 stsp git_commit $testroot/repo -m "added numbers file"
1441 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1442 dc424a06 2019-08-07 stsp
1443 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1444 dc424a06 2019-08-07 stsp ret="$?"
1445 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1446 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1447 dc424a06 2019-08-07 stsp return 1
1448 dc424a06 2019-08-07 stsp fi
1449 dc424a06 2019-08-07 stsp
1450 dc424a06 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1451 dc424a06 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1452 dc424a06 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1453 dc424a06 2019-08-07 stsp
1454 dc424a06 2019-08-07 stsp # don't stage any hunks
1455 dc424a06 2019-08-07 stsp printf "n\nn\nn\n" > $testroot/patchscript
1456 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1457 7b5dc508 2019-10-28 stsp numbers > $testroot/stdout 2> $testroot/stderr)
1458 dc424a06 2019-08-07 stsp ret="$?"
1459 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1460 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
1461 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1462 dc424a06 2019-08-07 stsp return 1
1463 dc424a06 2019-08-07 stsp fi
1464 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1465 dc424a06 2019-08-07 stsp -----------------------------------------------
1466 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1467 dc424a06 2019-08-07 stsp 1
1468 dc424a06 2019-08-07 stsp -2
1469 dc424a06 2019-08-07 stsp +a
1470 dc424a06 2019-08-07 stsp 3
1471 dc424a06 2019-08-07 stsp 4
1472 dc424a06 2019-08-07 stsp 5
1473 dc424a06 2019-08-07 stsp -----------------------------------------------
1474 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1475 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1476 dc424a06 2019-08-07 stsp -----------------------------------------------
1477 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1478 dc424a06 2019-08-07 stsp 4
1479 dc424a06 2019-08-07 stsp 5
1480 dc424a06 2019-08-07 stsp 6
1481 dc424a06 2019-08-07 stsp -7
1482 dc424a06 2019-08-07 stsp +b
1483 dc424a06 2019-08-07 stsp 8
1484 dc424a06 2019-08-07 stsp 9
1485 dc424a06 2019-08-07 stsp 10
1486 dc424a06 2019-08-07 stsp -----------------------------------------------
1487 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1488 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1489 dc424a06 2019-08-07 stsp -----------------------------------------------
1490 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1491 dc424a06 2019-08-07 stsp 13
1492 dc424a06 2019-08-07 stsp 14
1493 dc424a06 2019-08-07 stsp 15
1494 dc424a06 2019-08-07 stsp -16
1495 dc424a06 2019-08-07 stsp +c
1496 dc424a06 2019-08-07 stsp -----------------------------------------------
1497 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1498 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1499 dc424a06 2019-08-07 stsp EOF
1500 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1501 dc424a06 2019-08-07 stsp ret="$?"
1502 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1503 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1504 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1505 dc424a06 2019-08-07 stsp return 1
1506 dc424a06 2019-08-07 stsp fi
1507 f0b75401 2019-08-03 stsp
1508 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
1509 7b5dc508 2019-10-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1510 7b5dc508 2019-10-28 stsp ret="$?"
1511 7b5dc508 2019-10-28 stsp if [ "$ret" != "0" ]; then
1512 7b5dc508 2019-10-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
1513 7b5dc508 2019-10-28 stsp test_done "$testroot" "$ret"
1514 7b5dc508 2019-10-28 stsp return 1
1515 7b5dc508 2019-10-28 stsp fi
1516 7b5dc508 2019-10-28 stsp
1517 7b5dc508 2019-10-28 stsp
1518 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1519 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1520 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1521 dc424a06 2019-08-07 stsp ret="$?"
1522 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1523 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1524 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1525 dc424a06 2019-08-07 stsp return 1
1526 dc424a06 2019-08-07 stsp fi
1527 dc424a06 2019-08-07 stsp
1528 dc424a06 2019-08-07 stsp # stage middle hunk
1529 dc424a06 2019-08-07 stsp printf "n\ny\nn\n" > $testroot/patchscript
1530 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1531 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1532 dc424a06 2019-08-07 stsp
1533 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1534 dc424a06 2019-08-07 stsp -----------------------------------------------
1535 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1536 dc424a06 2019-08-07 stsp 1
1537 dc424a06 2019-08-07 stsp -2
1538 dc424a06 2019-08-07 stsp +a
1539 dc424a06 2019-08-07 stsp 3
1540 dc424a06 2019-08-07 stsp 4
1541 dc424a06 2019-08-07 stsp 5
1542 dc424a06 2019-08-07 stsp -----------------------------------------------
1543 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1544 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1545 dc424a06 2019-08-07 stsp -----------------------------------------------
1546 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1547 dc424a06 2019-08-07 stsp 4
1548 dc424a06 2019-08-07 stsp 5
1549 dc424a06 2019-08-07 stsp 6
1550 dc424a06 2019-08-07 stsp -7
1551 dc424a06 2019-08-07 stsp +b
1552 dc424a06 2019-08-07 stsp 8
1553 dc424a06 2019-08-07 stsp 9
1554 dc424a06 2019-08-07 stsp 10
1555 dc424a06 2019-08-07 stsp -----------------------------------------------
1556 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1557 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1558 dc424a06 2019-08-07 stsp -----------------------------------------------
1559 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1560 dc424a06 2019-08-07 stsp 13
1561 dc424a06 2019-08-07 stsp 14
1562 dc424a06 2019-08-07 stsp 15
1563 dc424a06 2019-08-07 stsp -16
1564 dc424a06 2019-08-07 stsp +c
1565 dc424a06 2019-08-07 stsp -----------------------------------------------
1566 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1567 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1568 dc424a06 2019-08-07 stsp EOF
1569 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1570 dc424a06 2019-08-07 stsp ret="$?"
1571 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1572 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1573 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1574 dc424a06 2019-08-07 stsp return 1
1575 dc424a06 2019-08-07 stsp fi
1576 dc424a06 2019-08-07 stsp
1577 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1578 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1579 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1580 dc424a06 2019-08-07 stsp ret="$?"
1581 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1582 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1583 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1584 dc424a06 2019-08-07 stsp return 1
1585 dc424a06 2019-08-07 stsp fi
1586 dc424a06 2019-08-07 stsp
1587 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1588 dc424a06 2019-08-07 stsp
1589 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1590 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1591 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1592 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1593 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1594 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1595 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1596 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1597 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1598 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1599 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1600 dc424a06 2019-08-07 stsp echo "@@ -4,7 +4,7 @@" >> $testroot/stdout.expected
1601 dc424a06 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
1602 dc424a06 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
1603 dc424a06 2019-08-07 stsp echo " 6" >> $testroot/stdout.expected
1604 dc424a06 2019-08-07 stsp echo "-7" >> $testroot/stdout.expected
1605 dc424a06 2019-08-07 stsp echo "+b" >> $testroot/stdout.expected
1606 dc424a06 2019-08-07 stsp echo " 8" >> $testroot/stdout.expected
1607 dc424a06 2019-08-07 stsp echo " 9" >> $testroot/stdout.expected
1608 dc424a06 2019-08-07 stsp echo " 10" >> $testroot/stdout.expected
1609 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1610 dc424a06 2019-08-07 stsp ret="$?"
1611 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1612 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1613 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1614 dc424a06 2019-08-07 stsp return 1
1615 dc424a06 2019-08-07 stsp fi
1616 dc424a06 2019-08-07 stsp
1617 dc424a06 2019-08-07 stsp (cd $testroot/wt && got unstage >/dev/null)
1618 dc424a06 2019-08-07 stsp ret="$?"
1619 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1620 dc424a06 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
1621 dc424a06 2019-08-07 stsp test_done "$testroot" "1"
1622 dc424a06 2019-08-07 stsp return 1
1623 dc424a06 2019-08-07 stsp fi
1624 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1625 dc424a06 2019-08-07 stsp echo "M numbers" > $testroot/stdout.expected
1626 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1627 dc424a06 2019-08-07 stsp ret="$?"
1628 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1629 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1630 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1631 dc424a06 2019-08-07 stsp return 1
1632 dc424a06 2019-08-07 stsp fi
1633 dc424a06 2019-08-07 stsp
1634 dc424a06 2019-08-07 stsp # stage last hunk
1635 dc424a06 2019-08-07 stsp printf "n\nn\ny\n" > $testroot/patchscript
1636 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1637 dc424a06 2019-08-07 stsp numbers > $testroot/stdout)
1638 dc424a06 2019-08-07 stsp
1639 dc424a06 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
1640 dc424a06 2019-08-07 stsp -----------------------------------------------
1641 dc424a06 2019-08-07 stsp @@ -1,5 +1,5 @@
1642 dc424a06 2019-08-07 stsp 1
1643 dc424a06 2019-08-07 stsp -2
1644 dc424a06 2019-08-07 stsp +a
1645 dc424a06 2019-08-07 stsp 3
1646 dc424a06 2019-08-07 stsp 4
1647 dc424a06 2019-08-07 stsp 5
1648 dc424a06 2019-08-07 stsp -----------------------------------------------
1649 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
1650 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1651 dc424a06 2019-08-07 stsp -----------------------------------------------
1652 dc424a06 2019-08-07 stsp @@ -4,7 +4,7 @@
1653 dc424a06 2019-08-07 stsp 4
1654 dc424a06 2019-08-07 stsp 5
1655 dc424a06 2019-08-07 stsp 6
1656 dc424a06 2019-08-07 stsp -7
1657 dc424a06 2019-08-07 stsp +b
1658 dc424a06 2019-08-07 stsp 8
1659 dc424a06 2019-08-07 stsp 9
1660 dc424a06 2019-08-07 stsp 10
1661 dc424a06 2019-08-07 stsp -----------------------------------------------
1662 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
1663 b353a198 2019-08-07 stsp stage this change? [y/n/q] n
1664 dc424a06 2019-08-07 stsp -----------------------------------------------
1665 dc424a06 2019-08-07 stsp @@ -13,4 +13,4 @@
1666 dc424a06 2019-08-07 stsp 13
1667 dc424a06 2019-08-07 stsp 14
1668 dc424a06 2019-08-07 stsp 15
1669 dc424a06 2019-08-07 stsp -16
1670 dc424a06 2019-08-07 stsp +c
1671 dc424a06 2019-08-07 stsp -----------------------------------------------
1672 a7c9878d 2019-08-08 stsp M numbers (change 3 of 3)
1673 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
1674 dc424a06 2019-08-07 stsp EOF
1675 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1676 dc424a06 2019-08-07 stsp ret="$?"
1677 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1678 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1679 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1680 dc424a06 2019-08-07 stsp return 1
1681 dc424a06 2019-08-07 stsp fi
1682 dc424a06 2019-08-07 stsp
1683 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1684 dc424a06 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
1685 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1686 dc424a06 2019-08-07 stsp ret="$?"
1687 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1688 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1689 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1690 dc424a06 2019-08-07 stsp return 1
1691 dc424a06 2019-08-07 stsp fi
1692 dc424a06 2019-08-07 stsp
1693 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1694 dc424a06 2019-08-07 stsp
1695 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1696 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1697 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1698 dc424a06 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
1699 dc424a06 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1700 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1701 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1702 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1703 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1704 dc424a06 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
1705 dc424a06 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
1706 dc424a06 2019-08-07 stsp echo "@@ -13,4 +13,4 @@" >> $testroot/stdout.expected
1707 dc424a06 2019-08-07 stsp echo " 13" >> $testroot/stdout.expected
1708 dc424a06 2019-08-07 stsp echo " 14" >> $testroot/stdout.expected
1709 dc424a06 2019-08-07 stsp echo " 15" >> $testroot/stdout.expected
1710 dc424a06 2019-08-07 stsp echo "-16" >> $testroot/stdout.expected
1711 dc424a06 2019-08-07 stsp echo "+c" >> $testroot/stdout.expected
1712 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1713 af5a81b2 2019-08-08 stsp ret="$?"
1714 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1715 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1716 af5a81b2 2019-08-08 stsp fi
1717 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1718 af5a81b2 2019-08-08 stsp }
1719 af5a81b2 2019-08-08 stsp
1720 f6cae3ed 2020-09-13 naddy test_stage_patch_twice() {
1721 af5a81b2 2019-08-08 stsp local testroot=`test_init stage_patch_twice`
1722 af5a81b2 2019-08-08 stsp
1723 af5a81b2 2019-08-08 stsp jot 16 > $testroot/repo/numbers
1724 af5a81b2 2019-08-08 stsp (cd $testroot/repo && git add numbers)
1725 af5a81b2 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
1726 af5a81b2 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1727 af5a81b2 2019-08-08 stsp
1728 af5a81b2 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1729 af5a81b2 2019-08-08 stsp ret="$?"
1730 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1731 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1732 af5a81b2 2019-08-08 stsp return 1
1733 af5a81b2 2019-08-08 stsp fi
1734 af5a81b2 2019-08-08 stsp
1735 af5a81b2 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
1736 af5a81b2 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
1737 af5a81b2 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
1738 af5a81b2 2019-08-08 stsp
1739 af5a81b2 2019-08-08 stsp # stage middle hunk
1740 af5a81b2 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
1741 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1742 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1743 af5a81b2 2019-08-08 stsp
1744 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1745 af5a81b2 2019-08-08 stsp -----------------------------------------------
1746 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1747 af5a81b2 2019-08-08 stsp 1
1748 af5a81b2 2019-08-08 stsp -2
1749 af5a81b2 2019-08-08 stsp +a
1750 af5a81b2 2019-08-08 stsp 3
1751 af5a81b2 2019-08-08 stsp 4
1752 af5a81b2 2019-08-08 stsp 5
1753 af5a81b2 2019-08-08 stsp -----------------------------------------------
1754 af5a81b2 2019-08-08 stsp M numbers (change 1 of 3)
1755 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1756 af5a81b2 2019-08-08 stsp -----------------------------------------------
1757 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1758 af5a81b2 2019-08-08 stsp 4
1759 af5a81b2 2019-08-08 stsp 5
1760 af5a81b2 2019-08-08 stsp 6
1761 af5a81b2 2019-08-08 stsp -7
1762 af5a81b2 2019-08-08 stsp +b
1763 af5a81b2 2019-08-08 stsp 8
1764 af5a81b2 2019-08-08 stsp 9
1765 af5a81b2 2019-08-08 stsp 10
1766 af5a81b2 2019-08-08 stsp -----------------------------------------------
1767 af5a81b2 2019-08-08 stsp M numbers (change 2 of 3)
1768 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1769 af5a81b2 2019-08-08 stsp -----------------------------------------------
1770 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1771 af5a81b2 2019-08-08 stsp 13
1772 af5a81b2 2019-08-08 stsp 14
1773 af5a81b2 2019-08-08 stsp 15
1774 af5a81b2 2019-08-08 stsp -16
1775 af5a81b2 2019-08-08 stsp +c
1776 af5a81b2 2019-08-08 stsp -----------------------------------------------
1777 af5a81b2 2019-08-08 stsp M numbers (change 3 of 3)
1778 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1779 af5a81b2 2019-08-08 stsp EOF
1780 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1781 af5a81b2 2019-08-08 stsp ret="$?"
1782 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1783 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1784 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1785 af5a81b2 2019-08-08 stsp return 1
1786 af5a81b2 2019-08-08 stsp fi
1787 af5a81b2 2019-08-08 stsp
1788 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1789 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1790 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1791 af5a81b2 2019-08-08 stsp ret="$?"
1792 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1793 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1794 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1795 af5a81b2 2019-08-08 stsp return 1
1796 af5a81b2 2019-08-08 stsp fi
1797 af5a81b2 2019-08-08 stsp
1798 af5a81b2 2019-08-08 stsp # stage last hunk
1799 af5a81b2 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
1800 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1801 af5a81b2 2019-08-08 stsp numbers > $testroot/stdout)
1802 af5a81b2 2019-08-08 stsp
1803 af5a81b2 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
1804 af5a81b2 2019-08-08 stsp -----------------------------------------------
1805 fe621944 2020-11-10 stsp @@ -1,5 +1,5 @@
1806 af5a81b2 2019-08-08 stsp 1
1807 af5a81b2 2019-08-08 stsp -2
1808 af5a81b2 2019-08-08 stsp +a
1809 af5a81b2 2019-08-08 stsp 3
1810 af5a81b2 2019-08-08 stsp 4
1811 af5a81b2 2019-08-08 stsp 5
1812 af5a81b2 2019-08-08 stsp -----------------------------------------------
1813 af5a81b2 2019-08-08 stsp M numbers (change 1 of 2)
1814 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] n
1815 af5a81b2 2019-08-08 stsp -----------------------------------------------
1816 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@ b
1817 af5a81b2 2019-08-08 stsp 13
1818 af5a81b2 2019-08-08 stsp 14
1819 af5a81b2 2019-08-08 stsp 15
1820 af5a81b2 2019-08-08 stsp -16
1821 af5a81b2 2019-08-08 stsp +c
1822 af5a81b2 2019-08-08 stsp -----------------------------------------------
1823 af5a81b2 2019-08-08 stsp M numbers (change 2 of 2)
1824 af5a81b2 2019-08-08 stsp stage this change? [y/n/q] y
1825 af5a81b2 2019-08-08 stsp EOF
1826 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1827 af5a81b2 2019-08-08 stsp ret="$?"
1828 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1829 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1830 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1831 af5a81b2 2019-08-08 stsp return 1
1832 af5a81b2 2019-08-08 stsp fi
1833 af5a81b2 2019-08-08 stsp
1834 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1835 af5a81b2 2019-08-08 stsp echo "MM numbers" > $testroot/stdout.expected
1836 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1837 af5a81b2 2019-08-08 stsp ret="$?"
1838 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1839 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1840 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1841 af5a81b2 2019-08-08 stsp return 1
1842 af5a81b2 2019-08-08 stsp fi
1843 af5a81b2 2019-08-08 stsp
1844 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1845 af5a81b2 2019-08-08 stsp
1846 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1847 af5a81b2 2019-08-08 stsp > $testroot/stdout.expected
1848 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1849 af5a81b2 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
1850 af5a81b2 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
1851 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1852 af5a81b2 2019-08-08 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1853 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
1854 af5a81b2 2019-08-08 stsp >> $testroot/stdout.expected
1855 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1856 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1857 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1858 af5a81b2 2019-08-08 stsp @@ -4,7 +4,7 @@
1859 af5a81b2 2019-08-08 stsp 4
1860 af5a81b2 2019-08-08 stsp 5
1861 af5a81b2 2019-08-08 stsp 6
1862 af5a81b2 2019-08-08 stsp -7
1863 af5a81b2 2019-08-08 stsp +b
1864 af5a81b2 2019-08-08 stsp 8
1865 af5a81b2 2019-08-08 stsp 9
1866 af5a81b2 2019-08-08 stsp 10
1867 af5a81b2 2019-08-08 stsp @@ -13,4 +13,4 @@
1868 af5a81b2 2019-08-08 stsp 13
1869 af5a81b2 2019-08-08 stsp 14
1870 af5a81b2 2019-08-08 stsp 15
1871 af5a81b2 2019-08-08 stsp -16
1872 af5a81b2 2019-08-08 stsp +c
1873 af5a81b2 2019-08-08 stsp EOF
1874 af5a81b2 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1875 af5a81b2 2019-08-08 stsp ret="$?"
1876 af5a81b2 2019-08-08 stsp if [ "$ret" != "0" ]; then
1877 af5a81b2 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1878 af5a81b2 2019-08-08 stsp test_done "$testroot" "$ret"
1879 af5a81b2 2019-08-08 stsp return 1
1880 af5a81b2 2019-08-08 stsp fi
1881 af5a81b2 2019-08-08 stsp
1882 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1883 af5a81b2 2019-08-08 stsp
1884 af5a81b2 2019-08-08 stsp echo "diff $commit_id $testroot/wt" > $testroot/stdout.expected
1885 af5a81b2 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1886 af5a81b2 2019-08-08 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 | \
1887 af5a81b2 2019-08-08 stsp tr -d '\n' >> $testroot/stdout.expected
1888 af5a81b2 2019-08-08 stsp echo " (staged)" >> $testroot/stdout.expected
1889 af5a81b2 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
1890 af5a81b2 2019-08-08 stsp echo "--- numbers" >> $testroot/stdout.expected
1891 af5a81b2 2019-08-08 stsp echo "+++ numbers" >> $testroot/stdout.expected
1892 af5a81b2 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
1893 af5a81b2 2019-08-08 stsp @@ -1,5 +1,5 @@
1894 af5a81b2 2019-08-08 stsp 1
1895 af5a81b2 2019-08-08 stsp -2
1896 af5a81b2 2019-08-08 stsp +a
1897 af5a81b2 2019-08-08 stsp 3
1898 af5a81b2 2019-08-08 stsp 4
1899 af5a81b2 2019-08-08 stsp 5
1900 af5a81b2 2019-08-08 stsp EOF
1901 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1902 dc424a06 2019-08-07 stsp ret="$?"
1903 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1904 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1905 dc424a06 2019-08-07 stsp fi
1906 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1907 dc424a06 2019-08-07 stsp }
1908 dc424a06 2019-08-07 stsp
1909 f6cae3ed 2020-09-13 naddy test_stage_patch_added() {
1910 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_added`
1911 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
1912 dc424a06 2019-08-07 stsp
1913 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1914 dc424a06 2019-08-07 stsp ret="$?"
1915 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1916 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1917 dc424a06 2019-08-07 stsp return 1
1918 dc424a06 2019-08-07 stsp fi
1919 dc424a06 2019-08-07 stsp
1920 dc424a06 2019-08-07 stsp echo "new" > $testroot/wt/epsilon/new
1921 dc424a06 2019-08-07 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1922 dc424a06 2019-08-07 stsp
1923 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
1924 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1925 dc424a06 2019-08-07 stsp epsilon/new > $testroot/stdout)
1926 dc424a06 2019-08-07 stsp
1927 dc424a06 2019-08-07 stsp echo "A epsilon/new" > $testroot/stdout.expected
1928 c8ede203 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1929 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1930 dc424a06 2019-08-07 stsp ret="$?"
1931 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1932 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1933 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1934 dc424a06 2019-08-07 stsp return 1
1935 dc424a06 2019-08-07 stsp fi
1936 dc424a06 2019-08-07 stsp
1937 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
1938 dc424a06 2019-08-07 stsp echo " A epsilon/new" > $testroot/stdout.expected
1939 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1940 dc424a06 2019-08-07 stsp ret="$?"
1941 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
1942 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
1943 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
1944 dc424a06 2019-08-07 stsp return 1
1945 dc424a06 2019-08-07 stsp fi
1946 dc424a06 2019-08-07 stsp
1947 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
1948 dc424a06 2019-08-07 stsp
1949 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
1950 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
1951 dc424a06 2019-08-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1952 dc424a06 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
1953 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l epsilon/new) | cut -d' ' -f 1 \
1954 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
1955 dc424a06 2019-08-07 stsp echo "--- /dev/null" >> $testroot/stdout.expected
1956 dc424a06 2019-08-07 stsp echo "+++ epsilon/new" >> $testroot/stdout.expected
1957 dc424a06 2019-08-07 stsp echo "@@ -0,0 +1 @@" >> $testroot/stdout.expected
1958 dc424a06 2019-08-07 stsp echo "+new" >> $testroot/stdout.expected
1959 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1960 e70a841e 2019-08-08 stsp ret="$?"
1961 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1962 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1963 e70a841e 2019-08-08 stsp fi
1964 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1965 e70a841e 2019-08-08 stsp }
1966 e70a841e 2019-08-08 stsp
1967 f6cae3ed 2020-09-13 naddy test_stage_patch_added_twice() {
1968 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_added_twice`
1969 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
1970 e70a841e 2019-08-08 stsp
1971 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1972 e70a841e 2019-08-08 stsp ret="$?"
1973 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1974 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1975 e70a841e 2019-08-08 stsp return 1
1976 e70a841e 2019-08-08 stsp fi
1977 e70a841e 2019-08-08 stsp
1978 e70a841e 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
1979 e70a841e 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
1980 e70a841e 2019-08-08 stsp
1981 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
1982 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
1983 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout)
1984 e70a841e 2019-08-08 stsp
1985 e70a841e 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
1986 e70a841e 2019-08-08 stsp echo "stage this addition? [y/n] y" >> $testroot/stdout.expected
1987 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1988 e70a841e 2019-08-08 stsp ret="$?"
1989 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
1990 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
1991 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
1992 e70a841e 2019-08-08 stsp return 1
1993 e70a841e 2019-08-08 stsp fi
1994 e70a841e 2019-08-08 stsp
1995 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
1996 e70a841e 2019-08-08 stsp echo " A epsilon/new" > $testroot/stdout.expected
1997 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1998 dc424a06 2019-08-07 stsp ret="$?"
1999 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2000 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2001 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2002 e70a841e 2019-08-08 stsp return 1
2003 dc424a06 2019-08-07 stsp fi
2004 e70a841e 2019-08-08 stsp
2005 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2006 e70a841e 2019-08-08 stsp epsilon/new > $testroot/stdout 2> $testroot/stderr)
2007 e70a841e 2019-08-08 stsp ret="$?"
2008 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
2009 e70a841e 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2010 e70a841e 2019-08-08 stsp test_done "$testroot" "1"
2011 e70a841e 2019-08-08 stsp return 1
2012 e70a841e 2019-08-08 stsp fi
2013 e70a841e 2019-08-08 stsp
2014 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
2015 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2016 e70a841e 2019-08-08 stsp ret="$?"
2017 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2018 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2019 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2020 e70a841e 2019-08-08 stsp return 1
2021 e70a841e 2019-08-08 stsp fi
2022 e70a841e 2019-08-08 stsp
2023 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2024 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2025 e70a841e 2019-08-08 stsp ret="$?"
2026 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2027 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2028 e70a841e 2019-08-08 stsp fi
2029 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2030 dc424a06 2019-08-07 stsp }
2031 dc424a06 2019-08-07 stsp
2032 f6cae3ed 2020-09-13 naddy test_stage_patch_removed() {
2033 dc424a06 2019-08-07 stsp local testroot=`test_init stage_patch_removed`
2034 dc424a06 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2035 dc424a06 2019-08-07 stsp
2036 dc424a06 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2037 dc424a06 2019-08-07 stsp ret="$?"
2038 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2039 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2040 dc424a06 2019-08-07 stsp return 1
2041 dc424a06 2019-08-07 stsp fi
2042 dc424a06 2019-08-07 stsp
2043 dc424a06 2019-08-07 stsp (cd $testroot/wt && got rm beta > /dev/null)
2044 dc424a06 2019-08-07 stsp
2045 dc424a06 2019-08-07 stsp printf "y\n" > $testroot/patchscript
2046 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2047 dc424a06 2019-08-07 stsp beta > $testroot/stdout)
2048 dc424a06 2019-08-07 stsp
2049 dc424a06 2019-08-07 stsp echo -n > $testroot/stdout.expected
2050 dc424a06 2019-08-07 stsp
2051 dc424a06 2019-08-07 stsp echo "D beta" > $testroot/stdout.expected
2052 f5a17245 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2053 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2054 dc424a06 2019-08-07 stsp ret="$?"
2055 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2056 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2057 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2058 dc424a06 2019-08-07 stsp return 1
2059 dc424a06 2019-08-07 stsp fi
2060 dc424a06 2019-08-07 stsp
2061 dc424a06 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2062 dc424a06 2019-08-07 stsp echo " D beta" > $testroot/stdout.expected
2063 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2064 dc424a06 2019-08-07 stsp ret="$?"
2065 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2066 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2067 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2068 dc424a06 2019-08-07 stsp return 1
2069 dc424a06 2019-08-07 stsp fi
2070 dc424a06 2019-08-07 stsp
2071 dc424a06 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2072 dc424a06 2019-08-07 stsp
2073 dc424a06 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2074 dc424a06 2019-08-07 stsp > $testroot/stdout.expected
2075 dc424a06 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2076 dc424a06 2019-08-07 stsp (cd $testroot/wt && got stage -l beta) | cut -d' ' -f 1 \
2077 dc424a06 2019-08-07 stsp >> $testroot/stdout.expected
2078 dc424a06 2019-08-07 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2079 dc424a06 2019-08-07 stsp echo "--- beta" >> $testroot/stdout.expected
2080 dc424a06 2019-08-07 stsp echo "+++ /dev/null" >> $testroot/stdout.expected
2081 dc424a06 2019-08-07 stsp echo "@@ -1 +0,0 @@" >> $testroot/stdout.expected
2082 dc424a06 2019-08-07 stsp echo "-beta" >> $testroot/stdout.expected
2083 dc424a06 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2084 dc424a06 2019-08-07 stsp ret="$?"
2085 dc424a06 2019-08-07 stsp if [ "$ret" != "0" ]; then
2086 dc424a06 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2087 dc424a06 2019-08-07 stsp fi
2088 dc424a06 2019-08-07 stsp test_done "$testroot" "$ret"
2089 dc424a06 2019-08-07 stsp }
2090 b353a198 2019-08-07 stsp
2091 f6cae3ed 2020-09-13 naddy test_stage_patch_removed_twice() {
2092 e70a841e 2019-08-08 stsp local testroot=`test_init stage_patch_removed_twice`
2093 e70a841e 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2094 e70a841e 2019-08-08 stsp
2095 e70a841e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2096 e70a841e 2019-08-08 stsp ret="$?"
2097 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2098 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2099 e70a841e 2019-08-08 stsp return 1
2100 e70a841e 2019-08-08 stsp fi
2101 e70a841e 2019-08-08 stsp
2102 e70a841e 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
2103 e70a841e 2019-08-08 stsp
2104 e70a841e 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2105 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2106 e70a841e 2019-08-08 stsp beta > $testroot/stdout)
2107 e70a841e 2019-08-08 stsp
2108 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2109 e70a841e 2019-08-08 stsp
2110 e70a841e 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
2111 e70a841e 2019-08-08 stsp echo "stage this deletion? [y/n] y" >> $testroot/stdout.expected
2112 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2113 e70a841e 2019-08-08 stsp ret="$?"
2114 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2115 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2116 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2117 e70a841e 2019-08-08 stsp return 1
2118 e70a841e 2019-08-08 stsp fi
2119 e70a841e 2019-08-08 stsp
2120 e70a841e 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2121 e70a841e 2019-08-08 stsp echo " D beta" > $testroot/stdout.expected
2122 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2123 e70a841e 2019-08-08 stsp ret="$?"
2124 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2125 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2126 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2127 e70a841e 2019-08-08 stsp return 1
2128 e70a841e 2019-08-08 stsp fi
2129 e70a841e 2019-08-08 stsp
2130 e70a841e 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p beta \
2131 e70a841e 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2132 e70a841e 2019-08-08 stsp ret="$?"
2133 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
2134 7b5dc508 2019-10-28 stsp echo "got stage command succeeded unexpectedly" >&2
2135 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2136 e70a841e 2019-08-08 stsp return 1
2137 e70a841e 2019-08-08 stsp fi
2138 e70a841e 2019-08-08 stsp
2139 7b5dc508 2019-10-28 stsp echo "got: no changes to stage" > $testroot/stderr.expected
2140 e70a841e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2141 e70a841e 2019-08-08 stsp ret="$?"
2142 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2143 e70a841e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2144 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2145 e70a841e 2019-08-08 stsp return 1
2146 e70a841e 2019-08-08 stsp fi
2147 e70a841e 2019-08-08 stsp
2148 e70a841e 2019-08-08 stsp echo -n > $testroot/stdout.expected
2149 e70a841e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2150 e70a841e 2019-08-08 stsp ret="$?"
2151 e70a841e 2019-08-08 stsp if [ "$ret" != "0" ]; then
2152 e70a841e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2153 e70a841e 2019-08-08 stsp fi
2154 e70a841e 2019-08-08 stsp test_done "$testroot" "$ret"
2155 e70a841e 2019-08-08 stsp }
2156 e70a841e 2019-08-08 stsp
2157 f6cae3ed 2020-09-13 naddy test_stage_patch_quit() {
2158 b353a198 2019-08-07 stsp local testroot=`test_init stage_patch_quit`
2159 b353a198 2019-08-07 stsp
2160 b353a198 2019-08-07 stsp jot 16 > $testroot/repo/numbers
2161 88f33a19 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2162 88f33a19 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2163 88f33a19 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2164 b353a198 2019-08-07 stsp local commit_id=`git_show_head $testroot/repo`
2165 b353a198 2019-08-07 stsp
2166 b353a198 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2167 b353a198 2019-08-07 stsp ret="$?"
2168 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2169 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2170 b353a198 2019-08-07 stsp return 1
2171 b353a198 2019-08-07 stsp fi
2172 dc424a06 2019-08-07 stsp
2173 b353a198 2019-08-07 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2174 b353a198 2019-08-07 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2175 b353a198 2019-08-07 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2176 88f33a19 2019-08-08 stsp (cd $testroot/wt && got rm zzz > /dev/null)
2177 b353a198 2019-08-07 stsp
2178 88f33a19 2019-08-08 stsp # stage first hunk and quit; and don't pass a path argument to
2179 88f33a19 2019-08-08 stsp # ensure that we don't skip asking about the 'zzz' file after 'quit'
2180 88f33a19 2019-08-08 stsp printf "y\nq\nn\n" > $testroot/patchscript
2181 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2182 2db2652d 2019-08-07 stsp > $testroot/stdout)
2183 b353a198 2019-08-07 stsp ret="$?"
2184 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2185 b353a198 2019-08-07 stsp echo "got stage command failed unexpectedly" >&2
2186 b353a198 2019-08-07 stsp test_done "$testroot" "1"
2187 b353a198 2019-08-07 stsp return 1
2188 b353a198 2019-08-07 stsp fi
2189 b353a198 2019-08-07 stsp cat > $testroot/stdout.expected <<EOF
2190 b353a198 2019-08-07 stsp -----------------------------------------------
2191 b353a198 2019-08-07 stsp @@ -1,5 +1,5 @@
2192 b353a198 2019-08-07 stsp 1
2193 b353a198 2019-08-07 stsp -2
2194 b353a198 2019-08-07 stsp +a
2195 b353a198 2019-08-07 stsp 3
2196 b353a198 2019-08-07 stsp 4
2197 b353a198 2019-08-07 stsp 5
2198 b353a198 2019-08-07 stsp -----------------------------------------------
2199 a7c9878d 2019-08-08 stsp M numbers (change 1 of 3)
2200 b353a198 2019-08-07 stsp stage this change? [y/n/q] y
2201 b353a198 2019-08-07 stsp -----------------------------------------------
2202 b353a198 2019-08-07 stsp @@ -4,7 +4,7 @@
2203 b353a198 2019-08-07 stsp 4
2204 b353a198 2019-08-07 stsp 5
2205 b353a198 2019-08-07 stsp 6
2206 b353a198 2019-08-07 stsp -7
2207 b353a198 2019-08-07 stsp +b
2208 b353a198 2019-08-07 stsp 8
2209 b353a198 2019-08-07 stsp 9
2210 b353a198 2019-08-07 stsp 10
2211 b353a198 2019-08-07 stsp -----------------------------------------------
2212 a7c9878d 2019-08-08 stsp M numbers (change 2 of 3)
2213 b353a198 2019-08-07 stsp stage this change? [y/n/q] q
2214 88f33a19 2019-08-08 stsp D zzz
2215 f5a17245 2019-08-08 stsp stage this deletion? [y/n] n
2216 b353a198 2019-08-07 stsp EOF
2217 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2218 b353a198 2019-08-07 stsp ret="$?"
2219 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2220 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2221 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2222 b353a198 2019-08-07 stsp return 1
2223 b353a198 2019-08-07 stsp fi
2224 b353a198 2019-08-07 stsp
2225 b353a198 2019-08-07 stsp (cd $testroot/wt && got status > $testroot/stdout)
2226 b353a198 2019-08-07 stsp echo "MM numbers" > $testroot/stdout.expected
2227 88f33a19 2019-08-08 stsp echo "D zzz" >> $testroot/stdout.expected
2228 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2229 b353a198 2019-08-07 stsp ret="$?"
2230 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2231 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2232 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2233 b353a198 2019-08-07 stsp return 1
2234 b353a198 2019-08-07 stsp fi
2235 b353a198 2019-08-07 stsp
2236 b353a198 2019-08-07 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2237 b353a198 2019-08-07 stsp
2238 b353a198 2019-08-07 stsp echo "diff $commit_id $testroot/wt (staged changes)" \
2239 b353a198 2019-08-07 stsp > $testroot/stdout.expected
2240 b353a198 2019-08-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2241 b353a198 2019-08-07 stsp got tree -r $testroot/repo -i -c $commit_id \
2242 b353a198 2019-08-07 stsp | grep 'numbers$' | cut -d' ' -f 1 \
2243 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2244 b353a198 2019-08-07 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2245 b353a198 2019-08-07 stsp (cd $testroot/wt && got stage -l numbers) | cut -d' ' -f 1 \
2246 b353a198 2019-08-07 stsp >> $testroot/stdout.expected
2247 b353a198 2019-08-07 stsp echo "--- numbers" >> $testroot/stdout.expected
2248 b353a198 2019-08-07 stsp echo "+++ numbers" >> $testroot/stdout.expected
2249 b353a198 2019-08-07 stsp echo "@@ -1,5 +1,5 @@" >> $testroot/stdout.expected
2250 b353a198 2019-08-07 stsp echo " 1" >> $testroot/stdout.expected
2251 b353a198 2019-08-07 stsp echo "-2" >> $testroot/stdout.expected
2252 b353a198 2019-08-07 stsp echo "+a" >> $testroot/stdout.expected
2253 b353a198 2019-08-07 stsp echo " 3" >> $testroot/stdout.expected
2254 b353a198 2019-08-07 stsp echo " 4" >> $testroot/stdout.expected
2255 b353a198 2019-08-07 stsp echo " 5" >> $testroot/stdout.expected
2256 b353a198 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2257 b353a198 2019-08-07 stsp ret="$?"
2258 b353a198 2019-08-07 stsp if [ "$ret" != "0" ]; then
2259 b353a198 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
2260 b353a198 2019-08-07 stsp fi
2261 b353a198 2019-08-07 stsp test_done "$testroot" "$ret"
2262 b353a198 2019-08-07 stsp
2263 b353a198 2019-08-07 stsp }
2264 b353a198 2019-08-07 stsp
2265 f6cae3ed 2020-09-13 naddy test_stage_patch_incomplete_script() {
2266 eba70f38 2019-08-08 stsp local testroot=`test_init stage_incomplete_script`
2267 eba70f38 2019-08-08 stsp
2268 eba70f38 2019-08-08 stsp jot 16 > $testroot/repo/numbers
2269 eba70f38 2019-08-08 stsp echo zzz > $testroot/repo/zzz
2270 eba70f38 2019-08-08 stsp (cd $testroot/repo && git add numbers zzz)
2271 eba70f38 2019-08-08 stsp git_commit $testroot/repo -m "added files"
2272 eba70f38 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
2273 eba70f38 2019-08-08 stsp
2274 eba70f38 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2275 eba70f38 2019-08-08 stsp ret="$?"
2276 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2277 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2278 eba70f38 2019-08-08 stsp return 1
2279 eba70f38 2019-08-08 stsp fi
2280 eba70f38 2019-08-08 stsp
2281 eba70f38 2019-08-08 stsp sed -i -e 's/^2$/a/' $testroot/wt/numbers
2282 eba70f38 2019-08-08 stsp sed -i -e 's/^7$/b/' $testroot/wt/numbers
2283 eba70f38 2019-08-08 stsp sed -i -e 's/^16$/c/' $testroot/wt/numbers
2284 eba70f38 2019-08-08 stsp
2285 eba70f38 2019-08-08 stsp # stage first hunk and then stop responding; got should error out
2286 eba70f38 2019-08-08 stsp printf "y\n" > $testroot/patchscript
2287 eba70f38 2019-08-08 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2288 eba70f38 2019-08-08 stsp > $testroot/stdout 2> $testroot/stderr)
2289 eba70f38 2019-08-08 stsp ret="$?"
2290 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
2291 eba70f38 2019-08-08 stsp echo "got stage command succeeded unexpectedly" >&2
2292 eba70f38 2019-08-08 stsp test_done "$testroot" "1"
2293 eba70f38 2019-08-08 stsp return 1
2294 eba70f38 2019-08-08 stsp fi
2295 eba70f38 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
2296 eba70f38 2019-08-08 stsp -----------------------------------------------
2297 eba70f38 2019-08-08 stsp @@ -1,5 +1,5 @@
2298 eba70f38 2019-08-08 stsp 1
2299 eba70f38 2019-08-08 stsp -2
2300 eba70f38 2019-08-08 stsp +a
2301 eba70f38 2019-08-08 stsp 3
2302 eba70f38 2019-08-08 stsp 4
2303 eba70f38 2019-08-08 stsp 5
2304 eba70f38 2019-08-08 stsp -----------------------------------------------
2305 eba70f38 2019-08-08 stsp M numbers (change 1 of 3)
2306 eba70f38 2019-08-08 stsp stage this change? [y/n/q] y
2307 eba70f38 2019-08-08 stsp -----------------------------------------------
2308 eba70f38 2019-08-08 stsp @@ -4,7 +4,7 @@
2309 eba70f38 2019-08-08 stsp 4
2310 eba70f38 2019-08-08 stsp 5
2311 eba70f38 2019-08-08 stsp 6
2312 eba70f38 2019-08-08 stsp -7
2313 eba70f38 2019-08-08 stsp +b
2314 eba70f38 2019-08-08 stsp 8
2315 eba70f38 2019-08-08 stsp 9
2316 eba70f38 2019-08-08 stsp 10
2317 eba70f38 2019-08-08 stsp -----------------------------------------------
2318 eba70f38 2019-08-08 stsp M numbers (change 2 of 3)
2319 eba70f38 2019-08-08 stsp EOF
2320 eba70f38 2019-08-08 stsp echo -n "stage this change? [y/n/q] " >> $testroot/stdout.expected
2321 eba70f38 2019-08-08 stsp echo "got: invalid patch choice" > $testroot/stderr.expected
2322 eba70f38 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2323 eba70f38 2019-08-08 stsp ret="$?"
2324 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2325 eba70f38 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
2326 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2327 eba70f38 2019-08-08 stsp return 1
2328 eba70f38 2019-08-08 stsp fi
2329 eba70f38 2019-08-08 stsp
2330 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2331 eba70f38 2019-08-08 stsp ret="$?"
2332 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2333 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2334 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2335 eba70f38 2019-08-08 stsp return 1
2336 eba70f38 2019-08-08 stsp fi
2337 eba70f38 2019-08-08 stsp
2338 eba70f38 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
2339 eba70f38 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
2340 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2341 eba70f38 2019-08-08 stsp ret="$?"
2342 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2343 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2344 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2345 eba70f38 2019-08-08 stsp return 1
2346 eba70f38 2019-08-08 stsp fi
2347 eba70f38 2019-08-08 stsp
2348 eba70f38 2019-08-08 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2349 eba70f38 2019-08-08 stsp echo -n > $testroot/stdout.expected
2350 eba70f38 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2351 eba70f38 2019-08-08 stsp ret="$?"
2352 eba70f38 2019-08-08 stsp if [ "$ret" != "0" ]; then
2353 eba70f38 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
2354 eba70f38 2019-08-08 stsp fi
2355 eba70f38 2019-08-08 stsp test_done "$testroot" "$ret"
2356 c631b115 2020-07-23 stsp
2357 c631b115 2020-07-23 stsp }
2358 c631b115 2020-07-23 stsp
2359 f6cae3ed 2020-09-13 naddy test_stage_symlink() {
2360 c631b115 2020-07-23 stsp local testroot=`test_init stage_symlink`
2361 c631b115 2020-07-23 stsp
2362 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2363 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
2364 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2365 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2366 c631b115 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2367 c631b115 2020-07-23 stsp (cd $testroot/repo && git add .)
2368 c631b115 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2369 c631b115 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
2370 c631b115 2020-07-23 stsp
2371 c631b115 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2372 c631b115 2020-07-23 stsp ret="$?"
2373 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2374 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2375 c631b115 2020-07-23 stsp return 1
2376 c631b115 2020-07-23 stsp fi
2377 c631b115 2020-07-23 stsp
2378 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
2379 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
2380 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
2381 c631b115 2020-07-23 stsp echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
2382 c631b115 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2383 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
2384 c631b115 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2385 c631b115 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
2386 c631b115 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
2387 c631b115 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
2388 c631b115 2020-07-23 stsp
2389 35213c7c 2020-07-23 stsp (cd $testroot/wt && got stage > $testroot/stdout 2> $testroot/stderr)
2390 35213c7c 2020-07-23 stsp ret="$?"
2391 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
2392 35213c7c 2020-07-23 stsp echo "got stage succeeded unexpectedly" >&2
2393 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
2394 35213c7c 2020-07-23 stsp return 1
2395 35213c7c 2020-07-23 stsp fi
2396 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
2397 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
2398 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
2399 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2400 35213c7c 2020-07-23 stsp ret="$?"
2401 35213c7c 2020-07-23 stsp if [ "$ret" != "0" ]; then
2402 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
2403 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
2404 35213c7c 2020-07-23 stsp return 1
2405 35213c7c 2020-07-23 stsp fi
2406 35213c7c 2020-07-23 stsp
2407 35213c7c 2020-07-23 stsp (cd $testroot/wt && got stage -S > $testroot/stdout)
2408 c631b115 2020-07-23 stsp
2409 c631b115 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2410 c631b115 2020-07-23 stsp M alpha.link
2411 c631b115 2020-07-23 stsp A dotgotbar.link
2412 c631b115 2020-07-23 stsp A dotgotfoo.link
2413 c631b115 2020-07-23 stsp M epsilon/beta.link
2414 c631b115 2020-07-23 stsp M epsilon.link
2415 c631b115 2020-07-23 stsp D nonexistent.link
2416 c631b115 2020-07-23 stsp A zeta.link
2417 c631b115 2020-07-23 stsp EOF
2418 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2419 c631b115 2020-07-23 stsp ret="$?"
2420 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2421 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2422 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2423 c631b115 2020-07-23 stsp return 1
2424 c631b115 2020-07-23 stsp fi
2425 0aeb8099 2020-07-23 stsp
2426 0aeb8099 2020-07-23 stsp rm $testroot/wt/alpha.link
2427 0aeb8099 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/wt/alpha.link
2428 c631b115 2020-07-23 stsp
2429 c631b115 2020-07-23 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2430 c631b115 2020-07-23 stsp
2431 c631b115 2020-07-23 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
2432 c631b115 2020-07-23 stsp > $testroot/stdout.expected
2433 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2434 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
2435 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2436 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2437 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l alpha.link) | cut -d' ' -f 1 \
2438 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2439 c631b115 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
2440 c631b115 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
2441 c631b115 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2442 c631b115 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
2443 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2444 c631b115 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
2445 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2446 c631b115 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2447 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2448 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l dotgotbar.link) | cut -d' ' -f 1 \
2449 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2450 c631b115 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2451 c631b115 2020-07-23 stsp echo '+++ dotgotbar.link' >> $testroot/stdout.expected
2452 c631b115 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2453 c631b115 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
2454 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2455 c631b115 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2456 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2457 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
2458 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2459 c631b115 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2460 c631b115 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2461 c631b115 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2462 c631b115 2020-07-23 stsp echo '+this is regular file foo' >> $testroot/stdout.expected
2463 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2464 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i epsilon | grep 'beta.link@ -> ../beta$' | \
2465 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2466 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2467 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l epsilon/beta.link) | cut -d' ' -f 1 \
2468 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2469 c631b115 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
2470 c631b115 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
2471 c631b115 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2472 c631b115 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
2473 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2474 c631b115 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
2475 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2476 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2477 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
2478 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2479 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2480 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l epsilon.link) | cut -d' ' -f 1 \
2481 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2482 c631b115 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
2483 c631b115 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
2484 c631b115 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2485 c631b115 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
2486 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2487 c631b115 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
2488 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2489 c631b115 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2490 c631b115 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
2491 c631b115 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2492 c631b115 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2493 c631b115 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
2494 c631b115 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
2495 c631b115 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2496 c631b115 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
2497 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2498 c631b115 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2499 c631b115 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2500 c631b115 2020-07-23 stsp (cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
2501 c631b115 2020-07-23 stsp >> $testroot/stdout.expected
2502 c631b115 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2503 c631b115 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
2504 c631b115 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2505 c631b115 2020-07-23 stsp echo '+gamma/delta' >> $testroot/stdout.expected
2506 c631b115 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2507 c631b115 2020-07-23 stsp
2508 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2509 c631b115 2020-07-23 stsp ret="$?"
2510 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2511 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2512 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2513 c631b115 2020-07-23 stsp return 1
2514 c631b115 2020-07-23 stsp fi
2515 c631b115 2020-07-23 stsp
2516 c631b115 2020-07-23 stsp (cd $testroot/wt && got commit -m "staged symlink" \
2517 c631b115 2020-07-23 stsp > $testroot/stdout)
2518 c631b115 2020-07-23 stsp ret="$?"
2519 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2520 c631b115 2020-07-23 stsp echo "got commit command failed unexpectedly" >&2
2521 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2522 c631b115 2020-07-23 stsp return 1
2523 c631b115 2020-07-23 stsp fi
2524 eba70f38 2019-08-08 stsp
2525 c631b115 2020-07-23 stsp local commit_id=`git_show_head $testroot/repo`
2526 c631b115 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
2527 c631b115 2020-07-23 stsp echo "A dotgotfoo.link" >> $testroot/stdout.expected
2528 c631b115 2020-07-23 stsp echo "A zeta.link" >> $testroot/stdout.expected
2529 c631b115 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
2530 c631b115 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
2531 c631b115 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
2532 c631b115 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
2533 c631b115 2020-07-23 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
2534 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2535 c631b115 2020-07-23 stsp ret="$?"
2536 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2537 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2538 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2539 c631b115 2020-07-23 stsp return 1
2540 c631b115 2020-07-23 stsp fi
2541 c631b115 2020-07-23 stsp
2542 c631b115 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id > $testroot/stdout
2543 c631b115 2020-07-23 stsp ret="$?"
2544 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2545 c631b115 2020-07-23 stsp echo "got tree command failed unexpectedly" >&2
2546 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2547 c631b115 2020-07-23 stsp return 1
2548 c631b115 2020-07-23 stsp fi
2549 c631b115 2020-07-23 stsp
2550 c631b115 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2551 c631b115 2020-07-23 stsp alpha
2552 c631b115 2020-07-23 stsp alpha.link@ -> beta
2553 c631b115 2020-07-23 stsp beta
2554 c631b115 2020-07-23 stsp dotgotbar.link@ -> .got/bar
2555 c631b115 2020-07-23 stsp dotgotfoo.link
2556 c631b115 2020-07-23 stsp epsilon/
2557 c631b115 2020-07-23 stsp epsilon.link@ -> gamma
2558 c631b115 2020-07-23 stsp gamma/
2559 c631b115 2020-07-23 stsp passwd.link@ -> /etc/passwd
2560 c631b115 2020-07-23 stsp zeta.link@ -> gamma/delta
2561 c631b115 2020-07-23 stsp EOF
2562 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2563 c631b115 2020-07-23 stsp ret="$?"
2564 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2565 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2566 c631b115 2020-07-23 stsp return 1
2567 c631b115 2020-07-23 stsp fi
2568 c631b115 2020-07-23 stsp
2569 0aeb8099 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
2570 0aeb8099 2020-07-23 stsp echo "alpha.link is a symlink"
2571 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2572 c631b115 2020-07-23 stsp return 1
2573 c631b115 2020-07-23 stsp fi
2574 c631b115 2020-07-23 stsp
2575 0aeb8099 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/content.expected
2576 0aeb8099 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
2577 0aeb8099 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2578 c631b115 2020-07-23 stsp ret="$?"
2579 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2580 0aeb8099 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2581 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2582 c631b115 2020-07-23 stsp return 1
2583 c631b115 2020-07-23 stsp fi
2584 c631b115 2020-07-23 stsp
2585 75f0a0fb 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
2586 75f0a0fb 2020-07-23 stsp echo "dotgotbar.link is not a symlink"
2587 75f0a0fb 2020-07-23 stsp test_done "$testroot" "1"
2588 75f0a0fb 2020-07-23 stsp return 1
2589 75f0a0fb 2020-07-23 stsp fi
2590 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
2591 c631b115 2020-07-23 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
2592 c631b115 2020-07-23 stsp echo "dotgotbar.link is a symlink"
2593 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2594 c631b115 2020-07-23 stsp return 1
2595 c631b115 2020-07-23 stsp fi
2596 0aeb8099 2020-07-23 stsp echo -n ".got/bar" > $testroot/content.expected
2597 c631b115 2020-07-23 stsp cp $testroot/wt/dotgotbar.link $testroot/content
2598 fa3cef63 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2599 fa3cef63 2020-07-23 stsp ret="$?"
2600 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2601 fa3cef63 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2602 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2603 fa3cef63 2020-07-23 stsp return 1
2604 fa3cef63 2020-07-23 stsp fi
2605 fa3cef63 2020-07-23 stsp
2606 fa3cef63 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
2607 fa3cef63 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
2608 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2609 fa3cef63 2020-07-23 stsp return 1
2610 fa3cef63 2020-07-23 stsp fi
2611 fa3cef63 2020-07-23 stsp echo "this is regular file foo" > $testroot/content.expected
2612 fa3cef63 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
2613 fa3cef63 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2614 fa3cef63 2020-07-23 stsp ret="$?"
2615 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2616 fa3cef63 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2617 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2618 fa3cef63 2020-07-23 stsp return 1
2619 fa3cef63 2020-07-23 stsp fi
2620 fa3cef63 2020-07-23 stsp
2621 fa3cef63 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
2622 fa3cef63 2020-07-23 stsp echo "epsilon.link is not a symlink"
2623 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2624 fa3cef63 2020-07-23 stsp return 1
2625 fa3cef63 2020-07-23 stsp fi
2626 fa3cef63 2020-07-23 stsp
2627 fa3cef63 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
2628 fa3cef63 2020-07-23 stsp echo "gamma" > $testroot/stdout.expected
2629 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2630 fa3cef63 2020-07-23 stsp ret="$?"
2631 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2632 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2633 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2634 fa3cef63 2020-07-23 stsp return 1
2635 fa3cef63 2020-07-23 stsp fi
2636 fa3cef63 2020-07-23 stsp
2637 fa3cef63 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2638 fa3cef63 2020-07-23 stsp echo "passwd.link is a symlink"
2639 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2640 fa3cef63 2020-07-23 stsp return 1
2641 fa3cef63 2020-07-23 stsp fi
2642 fa3cef63 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
2643 fa3cef63 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
2644 fa3cef63 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2645 fa3cef63 2020-07-23 stsp ret="$?"
2646 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2647 fa3cef63 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2648 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2649 fa3cef63 2020-07-23 stsp return 1
2650 fa3cef63 2020-07-23 stsp fi
2651 fa3cef63 2020-07-23 stsp
2652 fa3cef63 2020-07-23 stsp if ! [ -h $testroot/wt/zeta.link ]; then
2653 fa3cef63 2020-07-23 stsp echo "zeta.link is not a symlink"
2654 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2655 fa3cef63 2020-07-23 stsp return 1
2656 fa3cef63 2020-07-23 stsp fi
2657 fa3cef63 2020-07-23 stsp
2658 fa3cef63 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
2659 fa3cef63 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
2660 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2661 fa3cef63 2020-07-23 stsp ret="$?"
2662 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2663 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2664 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2665 fa3cef63 2020-07-23 stsp return 1
2666 fa3cef63 2020-07-23 stsp fi
2667 fa3cef63 2020-07-23 stsp
2668 fa3cef63 2020-07-23 stsp test_done "$testroot" "0"
2669 fa3cef63 2020-07-23 stsp }
2670 fa3cef63 2020-07-23 stsp
2671 f6cae3ed 2020-09-13 naddy test_stage_patch_symlink() {
2672 fa3cef63 2020-07-23 stsp local testroot=`test_init stage_patch_symlink`
2673 fa3cef63 2020-07-23 stsp
2674 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2675 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
2676 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2677 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2678 fa3cef63 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2679 fa3cef63 2020-07-23 stsp (cd $testroot/repo && git add .)
2680 fa3cef63 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2681 fa3cef63 2020-07-23 stsp local head_commit=`git_show_head $testroot/repo`
2682 fa3cef63 2020-07-23 stsp
2683 fa3cef63 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2684 fa3cef63 2020-07-23 stsp ret="$?"
2685 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2686 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2687 fa3cef63 2020-07-23 stsp return 1
2688 fa3cef63 2020-07-23 stsp fi
2689 fa3cef63 2020-07-23 stsp
2690 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
2691 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
2692 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
2693 fa3cef63 2020-07-23 stsp echo 'this is regular file foo' > $testroot/wt/dotgotfoo.link
2694 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2695 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
2696 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2697 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
2698 fa3cef63 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
2699 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
2700 fa3cef63 2020-07-23 stsp
2701 fa3cef63 2020-07-23 stsp printf "y\nn\ny\nn\ny\ny\ny" > $testroot/patchscript
2702 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -F $testroot/patchscript -p \
2703 fa3cef63 2020-07-23 stsp > $testroot/stdout)
2704 fa3cef63 2020-07-23 stsp
2705 fa3cef63 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2706 fa3cef63 2020-07-23 stsp -----------------------------------------------
2707 fa3cef63 2020-07-23 stsp @@ -1 +1 @@
2708 fa3cef63 2020-07-23 stsp -alpha
2709 fa3cef63 2020-07-23 stsp \ No newline at end of file
2710 fa3cef63 2020-07-23 stsp +beta
2711 fa3cef63 2020-07-23 stsp \ No newline at end of file
2712 fa3cef63 2020-07-23 stsp -----------------------------------------------
2713 fa3cef63 2020-07-23 stsp M alpha.link (change 1 of 1)
2714 fa3cef63 2020-07-23 stsp stage this change? [y/n/q] y
2715 fa3cef63 2020-07-23 stsp A dotgotbar.link
2716 fa3cef63 2020-07-23 stsp stage this addition? [y/n] n
2717 fa3cef63 2020-07-23 stsp A dotgotfoo.link
2718 fa3cef63 2020-07-23 stsp stage this addition? [y/n] y
2719 fa3cef63 2020-07-23 stsp -----------------------------------------------
2720 fa3cef63 2020-07-23 stsp @@ -1 +1 @@
2721 fa3cef63 2020-07-23 stsp -../beta
2722 fa3cef63 2020-07-23 stsp \ No newline at end of file
2723 fa3cef63 2020-07-23 stsp +../gamma/delta
2724 fa3cef63 2020-07-23 stsp \ No newline at end of file
2725 fa3cef63 2020-07-23 stsp -----------------------------------------------
2726 fa3cef63 2020-07-23 stsp M epsilon/beta.link (change 1 of 1)
2727 fa3cef63 2020-07-23 stsp stage this change? [y/n/q] n
2728 fa3cef63 2020-07-23 stsp -----------------------------------------------
2729 fa3cef63 2020-07-23 stsp @@ -1 +1 @@
2730 fa3cef63 2020-07-23 stsp -epsilon
2731 fa3cef63 2020-07-23 stsp \ No newline at end of file
2732 fa3cef63 2020-07-23 stsp +gamma
2733 fa3cef63 2020-07-23 stsp \ No newline at end of file
2734 fa3cef63 2020-07-23 stsp -----------------------------------------------
2735 fa3cef63 2020-07-23 stsp M epsilon.link (change 1 of 1)
2736 fa3cef63 2020-07-23 stsp stage this change? [y/n/q] y
2737 fa3cef63 2020-07-23 stsp D nonexistent.link
2738 fa3cef63 2020-07-23 stsp stage this deletion? [y/n] y
2739 fa3cef63 2020-07-23 stsp A zeta.link
2740 fa3cef63 2020-07-23 stsp stage this addition? [y/n] y
2741 fa3cef63 2020-07-23 stsp EOF
2742 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2743 fa3cef63 2020-07-23 stsp ret="$?"
2744 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2745 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2746 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2747 fa3cef63 2020-07-23 stsp return 1
2748 fa3cef63 2020-07-23 stsp fi
2749 fa3cef63 2020-07-23 stsp
2750 fa3cef63 2020-07-23 stsp rm $testroot/wt/alpha.link
2751 fa3cef63 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/wt/alpha.link
2752 fa3cef63 2020-07-23 stsp
2753 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got diff -s > $testroot/stdout)
2754 fa3cef63 2020-07-23 stsp
2755 fa3cef63 2020-07-23 stsp echo "diff $head_commit $testroot/wt (staged changes)" \
2756 fa3cef63 2020-07-23 stsp > $testroot/stdout.expected
2757 fa3cef63 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2758 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'alpha.link@ -> alpha$' | \
2759 fa3cef63 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2760 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2761 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l alpha.link) | cut -d' ' -f 1 \
2762 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2763 fa3cef63 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
2764 fa3cef63 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
2765 fa3cef63 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2766 fa3cef63 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
2767 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2768 fa3cef63 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
2769 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2770 fa3cef63 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2771 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2772 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l dotgotfoo.link) | cut -d' ' -f 1 \
2773 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2774 fa3cef63 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2775 fa3cef63 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
2776 fa3cef63 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2777 fa3cef63 2020-07-23 stsp echo '+this is regular file foo' >> $testroot/stdout.expected
2778 fa3cef63 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2779 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'epsilon.link@ -> epsilon$' | \
2780 fa3cef63 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2781 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2782 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l epsilon.link) | cut -d' ' -f 1 \
2783 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2784 fa3cef63 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
2785 fa3cef63 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
2786 fa3cef63 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
2787 fa3cef63 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
2788 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2789 fa3cef63 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
2790 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2791 fa3cef63 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
2792 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -i | grep 'nonexistent.link@ -> nonexistent$' | \
2793 fa3cef63 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
2794 fa3cef63 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
2795 fa3cef63 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
2796 fa3cef63 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
2797 fa3cef63 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
2798 fa3cef63 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
2799 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2800 fa3cef63 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
2801 fa3cef63 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
2802 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got stage -l zeta.link) | cut -d' ' -f 1 \
2803 fa3cef63 2020-07-23 stsp >> $testroot/stdout.expected
2804 fa3cef63 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
2805 fa3cef63 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
2806 fa3cef63 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
2807 fa3cef63 2020-07-23 stsp echo '+gamma/delta' >> $testroot/stdout.expected
2808 fa3cef63 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
2809 fa3cef63 2020-07-23 stsp
2810 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2811 fa3cef63 2020-07-23 stsp ret="$?"
2812 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2813 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2814 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2815 fa3cef63 2020-07-23 stsp return 1
2816 fa3cef63 2020-07-23 stsp fi
2817 fa3cef63 2020-07-23 stsp
2818 fa3cef63 2020-07-23 stsp (cd $testroot/wt && got commit -m "staged symlink" \
2819 fa3cef63 2020-07-23 stsp > $testroot/stdout)
2820 fa3cef63 2020-07-23 stsp ret="$?"
2821 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2822 fa3cef63 2020-07-23 stsp echo "got commit command failed unexpectedly" >&2
2823 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2824 fa3cef63 2020-07-23 stsp return 1
2825 fa3cef63 2020-07-23 stsp fi
2826 fa3cef63 2020-07-23 stsp
2827 fa3cef63 2020-07-23 stsp local commit_id=`git_show_head $testroot/repo`
2828 fa3cef63 2020-07-23 stsp echo "A dotgotfoo.link" > $testroot/stdout.expected
2829 fa3cef63 2020-07-23 stsp echo "A zeta.link" >> $testroot/stdout.expected
2830 fa3cef63 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
2831 fa3cef63 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
2832 fa3cef63 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
2833 fa3cef63 2020-07-23 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
2834 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2835 fa3cef63 2020-07-23 stsp ret="$?"
2836 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2837 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2838 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2839 fa3cef63 2020-07-23 stsp return 1
2840 fa3cef63 2020-07-23 stsp fi
2841 fa3cef63 2020-07-23 stsp
2842 fa3cef63 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id > $testroot/stdout
2843 fa3cef63 2020-07-23 stsp ret="$?"
2844 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2845 fa3cef63 2020-07-23 stsp echo "got tree command failed unexpectedly" >&2
2846 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2847 fa3cef63 2020-07-23 stsp return 1
2848 fa3cef63 2020-07-23 stsp fi
2849 fa3cef63 2020-07-23 stsp
2850 fa3cef63 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
2851 fa3cef63 2020-07-23 stsp alpha
2852 fa3cef63 2020-07-23 stsp alpha.link@ -> beta
2853 fa3cef63 2020-07-23 stsp beta
2854 fa3cef63 2020-07-23 stsp dotgotfoo.link
2855 fa3cef63 2020-07-23 stsp epsilon/
2856 fa3cef63 2020-07-23 stsp epsilon.link@ -> gamma
2857 fa3cef63 2020-07-23 stsp gamma/
2858 fa3cef63 2020-07-23 stsp passwd.link@ -> /etc/passwd
2859 fa3cef63 2020-07-23 stsp zeta.link@ -> gamma/delta
2860 fa3cef63 2020-07-23 stsp EOF
2861 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2862 fa3cef63 2020-07-23 stsp ret="$?"
2863 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2864 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2865 fa3cef63 2020-07-23 stsp return 1
2866 fa3cef63 2020-07-23 stsp fi
2867 fa3cef63 2020-07-23 stsp
2868 fa3cef63 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
2869 fa3cef63 2020-07-23 stsp echo "alpha.link is a symlink"
2870 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2871 fa3cef63 2020-07-23 stsp return 1
2872 fa3cef63 2020-07-23 stsp fi
2873 fa3cef63 2020-07-23 stsp
2874 fa3cef63 2020-07-23 stsp echo 'this is regular file alpha.link' > $testroot/content.expected
2875 fa3cef63 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
2876 c631b115 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2877 c631b115 2020-07-23 stsp ret="$?"
2878 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2879 c631b115 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2880 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2881 c631b115 2020-07-23 stsp return 1
2882 c631b115 2020-07-23 stsp fi
2883 c631b115 2020-07-23 stsp
2884 fa3cef63 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotbar.link ]; then
2885 fa3cef63 2020-07-23 stsp echo "dotgotbar.link is not a symlink"
2886 fa3cef63 2020-07-23 stsp test_done "$testroot" "1"
2887 fa3cef63 2020-07-23 stsp return 1
2888 fa3cef63 2020-07-23 stsp fi
2889 fa3cef63 2020-07-23 stsp readlink $testroot/wt/dotgotbar.link > $testroot/stdout
2890 fa3cef63 2020-07-23 stsp echo ".got/bar" > $testroot/stdout.expected
2891 fa3cef63 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2892 fa3cef63 2020-07-23 stsp ret="$?"
2893 fa3cef63 2020-07-23 stsp if [ "$ret" != "0" ]; then
2894 fa3cef63 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2895 fa3cef63 2020-07-23 stsp test_done "$testroot" "$ret"
2896 fa3cef63 2020-07-23 stsp return 1
2897 fa3cef63 2020-07-23 stsp fi
2898 fa3cef63 2020-07-23 stsp
2899 c631b115 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
2900 c631b115 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
2901 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2902 c631b115 2020-07-23 stsp return 1
2903 c631b115 2020-07-23 stsp fi
2904 c631b115 2020-07-23 stsp echo "this is regular file foo" > $testroot/content.expected
2905 c631b115 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
2906 c631b115 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2907 c631b115 2020-07-23 stsp ret="$?"
2908 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2909 c631b115 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2910 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2911 c631b115 2020-07-23 stsp return 1
2912 c631b115 2020-07-23 stsp fi
2913 c631b115 2020-07-23 stsp
2914 c631b115 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
2915 c631b115 2020-07-23 stsp echo "epsilon.link is not a symlink"
2916 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2917 c631b115 2020-07-23 stsp return 1
2918 c631b115 2020-07-23 stsp fi
2919 c631b115 2020-07-23 stsp
2920 c631b115 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
2921 c631b115 2020-07-23 stsp echo "gamma" > $testroot/stdout.expected
2922 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2923 c631b115 2020-07-23 stsp ret="$?"
2924 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2925 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2926 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2927 c631b115 2020-07-23 stsp return 1
2928 c631b115 2020-07-23 stsp fi
2929 c631b115 2020-07-23 stsp
2930 c631b115 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2931 c631b115 2020-07-23 stsp echo "passwd.link is a symlink"
2932 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2933 c631b115 2020-07-23 stsp return 1
2934 c631b115 2020-07-23 stsp fi
2935 c631b115 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
2936 c631b115 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
2937 c631b115 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2938 c631b115 2020-07-23 stsp ret="$?"
2939 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2940 c631b115 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2941 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2942 c631b115 2020-07-23 stsp return 1
2943 c631b115 2020-07-23 stsp fi
2944 c631b115 2020-07-23 stsp
2945 c631b115 2020-07-23 stsp if ! [ -h $testroot/wt/zeta.link ]; then
2946 c631b115 2020-07-23 stsp echo "zeta.link is not a symlink"
2947 c631b115 2020-07-23 stsp test_done "$testroot" "1"
2948 c631b115 2020-07-23 stsp return 1
2949 c631b115 2020-07-23 stsp fi
2950 c631b115 2020-07-23 stsp
2951 c631b115 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
2952 c631b115 2020-07-23 stsp echo "gamma/delta" > $testroot/stdout.expected
2953 c631b115 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2954 c631b115 2020-07-23 stsp ret="$?"
2955 c631b115 2020-07-23 stsp if [ "$ret" != "0" ]; then
2956 c631b115 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2957 c631b115 2020-07-23 stsp test_done "$testroot" "$ret"
2958 c631b115 2020-07-23 stsp return 1
2959 c631b115 2020-07-23 stsp fi
2960 c631b115 2020-07-23 stsp
2961 c631b115 2020-07-23 stsp test_done "$testroot" "0"
2962 eba70f38 2019-08-08 stsp }
2963 eba70f38 2019-08-08 stsp
2964 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2965 fccbfb98 2019-08-03 stsp run_test test_stage_basic
2966 31b20a6e 2019-08-06 stsp run_test test_stage_no_changes
2967 8b13ce36 2019-08-08 stsp run_test test_stage_unversioned
2968 8564cb21 2019-08-08 stsp run_test test_stage_nonexistent
2969 a4f692bb 2019-08-04 stsp run_test test_stage_list
2970 ebf48fd5 2019-08-03 stsp run_test test_stage_conflict
2971 735ef5ac 2019-08-03 stsp run_test test_stage_out_of_date
2972 d3e7c587 2019-08-03 stsp run_test test_double_stage
2973 c363b2c1 2019-08-03 stsp run_test test_stage_status
2974 1e1446d3 2019-08-03 stsp run_test test_stage_add_already_staged_file
2975 9acbc4fa 2019-08-03 stsp run_test test_stage_rm_already_staged_file
2976 24278f30 2019-08-03 stsp run_test test_stage_revert
2977 408b4ebc 2019-08-03 stsp run_test test_stage_diff
2978 b9622844 2019-08-03 stsp run_test test_stage_histedit
2979 243d7cf1 2019-08-03 stsp run_test test_stage_rebase
2980 a76c42e6 2019-08-03 stsp run_test test_stage_update
2981 f0b75401 2019-08-03 stsp run_test test_stage_commit_non_staged
2982 0f1cfa7f 2019-08-08 stsp run_test test_stage_commit_out_of_date
2983 5f8a88c6 2019-08-03 stsp run_test test_stage_commit
2984 dc424a06 2019-08-07 stsp run_test test_stage_patch
2985 af5a81b2 2019-08-08 stsp run_test test_stage_patch_twice
2986 dc424a06 2019-08-07 stsp run_test test_stage_patch_added
2987 e70a841e 2019-08-08 stsp run_test test_stage_patch_added_twice
2988 dc424a06 2019-08-07 stsp run_test test_stage_patch_removed
2989 e70a841e 2019-08-08 stsp run_test test_stage_patch_removed_twice
2990 b353a198 2019-08-07 stsp run_test test_stage_patch_quit
2991 eba70f38 2019-08-08 stsp run_test test_stage_patch_incomplete_script
2992 c631b115 2020-07-23 stsp run_test test_stage_symlink
2993 fa3cef63 2020-07-23 stsp run_test test_stage_patch_symlink