3 95adcdca 2019-03-27 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 95adcdca 2019-03-27 stsp # Permission to use, copy, modify, and distribute this software for any
6 95adcdca 2019-03-27 stsp # purpose with or without fee is hereby granted, provided that the above
7 95adcdca 2019-03-27 stsp # copyright notice and this permission notice appear in all copies.
9 95adcdca 2019-03-27 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 95adcdca 2019-03-27 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 95adcdca 2019-03-27 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 95adcdca 2019-03-27 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 95adcdca 2019-03-27 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 95adcdca 2019-03-27 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 95adcdca 2019-03-27 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 95adcdca 2019-03-27 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_diff_basic() {
20 95adcdca 2019-03-27 stsp local testroot=`test_init diff_basic`
21 95adcdca 2019-03-27 stsp local head_rev=`git_show_head $testroot/repo`
22 360f3aea 2022-08-30 mark local alpha_blobid=`get_blob_id $testroot/repo "" alpha`
24 95adcdca 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
26 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
27 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
31 95adcdca 2019-03-27 stsp echo "modified alpha" > $testroot/wt/alpha
32 95adcdca 2019-03-27 stsp (cd $testroot/wt && got rm beta >/dev/null)
33 95adcdca 2019-03-27 stsp echo "new file" > $testroot/wt/new
34 95adcdca 2019-03-27 stsp (cd $testroot/wt && got add new >/dev/null)
36 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
37 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
38 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
39 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
40 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
41 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
42 95adcdca 2019-03-27 stsp echo 'file + alpha' >> $testroot/stdout.expected
43 95adcdca 2019-03-27 stsp echo '--- alpha' >> $testroot/stdout.expected
44 95adcdca 2019-03-27 stsp echo '+++ alpha' >> $testroot/stdout.expected
45 95adcdca 2019-03-27 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
46 95adcdca 2019-03-27 stsp echo '-alpha' >> $testroot/stdout.expected
47 95adcdca 2019-03-27 stsp echo '+modified alpha' >> $testroot/stdout.expected
48 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
49 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
50 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
51 95adcdca 2019-03-27 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
52 95adcdca 2019-03-27 stsp echo '--- beta' >> $testroot/stdout.expected
53 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
54 95adcdca 2019-03-27 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
55 95adcdca 2019-03-27 stsp echo '-beta' >> $testroot/stdout.expected
56 95adcdca 2019-03-27 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
57 c87842d5 2022-09-23 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
58 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
59 95adcdca 2019-03-27 stsp echo '+++ new' >> $testroot/stdout.expected
60 95adcdca 2019-03-27 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
61 95adcdca 2019-03-27 stsp echo '+new file' >> $testroot/stdout.expected
63 95adcdca 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
64 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
66 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
67 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
68 2a06fe5f 2019-08-24 stsp test_done "$testroot" "$ret"
72 e7ffb0b0 2021-10-07 stsp # 'got diff' in a repository without any arguments is an error
73 e7ffb0b0 2021-10-07 stsp (cd $testroot/repo && got diff 2> $testroot/stderr)
74 e7ffb0b0 2021-10-07 stsp echo "got: no got work tree found" > $testroot/stderr.expected
75 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
77 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
78 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
79 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
83 e7ffb0b0 2021-10-07 stsp # 'got diff' in a repository with two arguments requires that
84 e7ffb0b0 2021-10-07 stsp # both named objects exist
85 e7ffb0b0 2021-10-07 stsp (cd $testroot/repo && got diff $head_rev foo 2> $testroot/stderr)
86 e7ffb0b0 2021-10-07 stsp echo "got: foo: object not found" > $testroot/stderr.expected
87 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
89 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
90 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
91 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
95 2a06fe5f 2019-08-24 stsp # diff non-existent path
96 2a06fe5f 2019-08-24 stsp (cd $testroot/wt && got diff nonexistent > $testroot/stdout \
97 2a06fe5f 2019-08-24 stsp 2> $testroot/stderr)
99 2a06fe5f 2019-08-24 stsp echo -n > $testroot/stdout.expected
100 2a06fe5f 2019-08-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
102 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
103 2a06fe5f 2019-08-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
104 2a06fe5f 2019-08-24 stsp test_done "$testroot" "$ret"
108 2a06fe5f 2019-08-24 stsp echo "got: nonexistent: No such file or directory" \
109 2a06fe5f 2019-08-24 stsp > $testroot/stderr.expected
110 2a06fe5f 2019-08-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
112 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
113 2a06fe5f 2019-08-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
114 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
118 e7ffb0b0 2021-10-07 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
120 e7ffb0b0 2021-10-07 stsp # diff several paths in a work tree
121 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
122 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
123 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
124 e7ffb0b0 2021-10-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
125 e7ffb0b0 2021-10-07 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
126 e7ffb0b0 2021-10-07 stsp >> $testroot/stdout.expected
127 e7ffb0b0 2021-10-07 stsp echo 'file + alpha' >> $testroot/stdout.expected
128 e7ffb0b0 2021-10-07 stsp echo '--- alpha' >> $testroot/stdout.expected
129 e7ffb0b0 2021-10-07 stsp echo '+++ alpha' >> $testroot/stdout.expected
130 e7ffb0b0 2021-10-07 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
131 e7ffb0b0 2021-10-07 stsp echo '-alpha' >> $testroot/stdout.expected
132 e7ffb0b0 2021-10-07 stsp echo '+modified alpha' >> $testroot/stdout.expected
133 e7ffb0b0 2021-10-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
134 e7ffb0b0 2021-10-07 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
135 e7ffb0b0 2021-10-07 stsp >> $testroot/stdout.expected
136 e7ffb0b0 2021-10-07 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
137 e7ffb0b0 2021-10-07 stsp echo '--- beta' >> $testroot/stdout.expected
138 e7ffb0b0 2021-10-07 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
139 e7ffb0b0 2021-10-07 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
140 e7ffb0b0 2021-10-07 stsp echo '-beta' >> $testroot/stdout.expected
141 10a623df 2021-10-11 stsp echo -n 'blob - ' >> $testroot/stdout.expected
142 10a623df 2021-10-11 stsp got tree -r $testroot/repo -i epsilon | grep 'zeta$' | cut -d' ' -f 1 \
143 10a623df 2021-10-11 stsp >> $testroot/stdout.expected
144 10a623df 2021-10-11 stsp echo 'file + epsilon/zeta' >> $testroot/stdout.expected
145 10a623df 2021-10-11 stsp echo '--- epsilon/zeta' >> $testroot/stdout.expected
146 10a623df 2021-10-11 stsp echo '+++ epsilon/zeta' >> $testroot/stdout.expected
147 10a623df 2021-10-11 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
148 10a623df 2021-10-11 stsp echo '-zeta' >> $testroot/stdout.expected
149 10a623df 2021-10-11 stsp echo '+modified zeta' >> $testroot/stdout.expected
150 10a623df 2021-10-11 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
151 c87842d5 2022-09-23 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
152 10a623df 2021-10-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
153 10a623df 2021-10-11 stsp echo '+++ new' >> $testroot/stdout.expected
154 10a623df 2021-10-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
155 10a623df 2021-10-11 stsp echo '+new file' >> $testroot/stdout.expected
157 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new alpha epsilon beta > $testroot/stdout)
158 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
160 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
161 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
162 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
166 10a623df 2021-10-11 stsp # different order of arguments results in same output order
167 10a623df 2021-10-11 stsp (cd $testroot/wt && got diff alpha new epsilon beta \
168 10a623df 2021-10-11 stsp > $testroot/stdout 2> $testroot/stderr)
170 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
171 10a623df 2021-10-11 stsp echo "diff failed unexpectedly" >&2
172 10a623df 2021-10-11 stsp test_done "$testroot" "1"
175 10a623df 2021-10-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
177 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
178 10a623df 2021-10-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
179 10a623df 2021-10-11 stsp test_done "$testroot" "$ret"
183 e7ffb0b0 2021-10-07 stsp # a branch 'new' should not collide with path 'new' if more
184 e7ffb0b0 2021-10-07 stsp # than two arguments are passed
185 e7ffb0b0 2021-10-07 stsp got br -r $testroot/repo -c master new > /dev/null
186 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new alpha epsilon beta \
187 e7ffb0b0 2021-10-07 stsp > $testroot/stdout 2> $testroot/stderr)
189 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
190 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
191 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
194 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
196 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
197 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
198 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
202 e7ffb0b0 2021-10-07 stsp # Two arguments are interpreted as objects if a colliding path exists
203 e7ffb0b0 2021-10-07 stsp echo master > $testroot/wt/master
204 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got add master > /dev/null)
205 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff master new > $testroot/stdout)
207 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
208 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
209 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
212 e7ffb0b0 2021-10-07 stsp echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
213 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
214 8469d821 2022-06-25 stsp echo "commit + $head_rev" >> $testroot/stdout.expected
215 e7ffb0b0 2021-10-07 stsp # diff between the branches is empty
216 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
218 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
219 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
220 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
223 e7ffb0b0 2021-10-07 stsp # same without a work tree
224 e7ffb0b0 2021-10-07 stsp (cd $testroot/repo && got diff master new > $testroot/stdout)
226 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
227 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
228 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
231 e7ffb0b0 2021-10-07 stsp echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
232 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
233 8469d821 2022-06-25 stsp echo "commit + $head_rev" >> $testroot/stdout.expected
234 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
236 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
237 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
238 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
241 e7ffb0b0 2021-10-07 stsp # same with -r argument
242 e7ffb0b0 2021-10-07 stsp got diff -r $testroot/repo master new > $testroot/stdout
244 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
245 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
246 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
249 e7ffb0b0 2021-10-07 stsp echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
250 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
251 8469d821 2022-06-25 stsp echo "commit + $head_rev" >> $testroot/stdout.expected
252 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
254 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
255 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
256 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
260 e7ffb0b0 2021-10-07 stsp # -P can be used to force use of paths
261 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff -P new master > $testroot/stdout)
263 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
264 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
265 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
268 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
269 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
270 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
271 e7ffb0b0 2021-10-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
272 c87842d5 2022-09-23 mark echo 'file + master (mode 644)' >> $testroot/stdout.expected
273 e7ffb0b0 2021-10-07 stsp echo '--- /dev/null' >> $testroot/stdout.expected
274 e7ffb0b0 2021-10-07 stsp echo '+++ master' >> $testroot/stdout.expected
275 e7ffb0b0 2021-10-07 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
276 e7ffb0b0 2021-10-07 stsp echo '+master' >> $testroot/stdout.expected
277 10a623df 2021-10-11 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
278 c87842d5 2022-09-23 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
279 10a623df 2021-10-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
280 10a623df 2021-10-11 stsp echo '+++ new' >> $testroot/stdout.expected
281 10a623df 2021-10-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
282 10a623df 2021-10-11 stsp echo '+new file' >> $testroot/stdout.expected
283 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
285 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
286 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
287 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
291 e7ffb0b0 2021-10-07 stsp # -P can only be used in a work tree
292 e7ffb0b0 2021-10-07 stsp got diff -r $testroot/repo -P new master 2> $testroot/stderr
294 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
295 e7ffb0b0 2021-10-07 stsp echo "diff succeeded unexpectedly" >&2
296 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
299 e7ffb0b0 2021-10-07 stsp echo "got: -P option can only be used when diffing a work tree" \
300 e7ffb0b0 2021-10-07 stsp > $testroot/stderr.expected
301 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
303 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
304 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
305 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
309 e7ffb0b0 2021-10-07 stsp # a single argument which can be resolved to a path is not ambiguous
310 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
311 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
312 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
313 e7ffb0b0 2021-10-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
314 c87842d5 2022-09-23 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
315 e7ffb0b0 2021-10-07 stsp echo '--- /dev/null' >> $testroot/stdout.expected
316 e7ffb0b0 2021-10-07 stsp echo '+++ new' >> $testroot/stdout.expected
317 e7ffb0b0 2021-10-07 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
318 e7ffb0b0 2021-10-07 stsp echo '+new file' >> $testroot/stdout.expected
319 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new > $testroot/stdout)
321 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
322 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
323 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
326 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
328 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
329 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
330 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
334 e7ffb0b0 2021-10-07 stsp # diff with just one object ID argument results in
335 e7ffb0b0 2021-10-07 stsp # interpretation of argument as a path
336 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff $head_rev 2> $testroot/stderr)
338 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
339 e7ffb0b0 2021-10-07 stsp echo "diff succeeded unexpectedly" >&2
340 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
343 e7ffb0b0 2021-10-07 stsp echo "got: $head_rev: No such file or directory" \
344 e7ffb0b0 2021-10-07 stsp > $testroot/stderr.expected
345 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
347 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
348 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
349 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
353 e7ffb0b0 2021-10-07 stsp # diff with more than two object arguments results in
354 e7ffb0b0 2021-10-07 stsp # interpretation of arguments as paths
355 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new $head_rev master \
356 e7ffb0b0 2021-10-07 stsp > $testroot/stout 2> $testroot/stderr)
358 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
359 e7ffb0b0 2021-10-07 stsp echo "diff succeeded unexpectedly" >&2
360 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
364 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
365 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
366 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
367 e7ffb0b0 2021-10-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
368 c87842d5 2022-09-23 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
369 e7ffb0b0 2021-10-07 stsp echo '--- /dev/null' >> $testroot/stdout.expected
370 e7ffb0b0 2021-10-07 stsp echo '+++ new' >> $testroot/stdout.expected
371 e7ffb0b0 2021-10-07 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
372 e7ffb0b0 2021-10-07 stsp echo '+new file' >> $testroot/stdout.expected
373 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
375 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
376 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
377 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
381 e7ffb0b0 2021-10-07 stsp echo "got: $head_rev: No such file or directory" \
382 e7ffb0b0 2021-10-07 stsp > $testroot/stderr.expected
383 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
385 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
386 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
390 360f3aea 2022-08-30 mark # diff two blob ids
391 360f3aea 2022-08-30 mark (cd $testroot/wt && got commit -m 'edit' alpha >/dev/null)
392 360f3aea 2022-08-30 mark local alpha_new_blobid=`get_blob_id $testroot/repo "" alpha`
393 d4f2833a 2022-08-31 op (cd $testroot/wt && got diff $alpha_blobid $alpha_new_blobid) \
394 d4f2833a 2022-08-31 op > $testroot/diff
396 360f3aea 2022-08-30 mark if [ $ret -ne 0 ]; then
397 360f3aea 2022-08-30 mark echo "diff failed unexpectedly" >&2
398 360f3aea 2022-08-30 mark test_done "$testroot" "$ret"
402 360f3aea 2022-08-30 mark cat <<EOF >$testroot/diff.expected
403 360f3aea 2022-08-30 mark blob - $alpha_blobid
404 360f3aea 2022-08-30 mark blob + $alpha_new_blobid
405 360f3aea 2022-08-30 mark --- $alpha_blobid
406 360f3aea 2022-08-30 mark +++ $alpha_new_blobid
407 360f3aea 2022-08-30 mark @@ -1 +1 @@
409 360f3aea 2022-08-30 mark +modified alpha
412 360f3aea 2022-08-30 mark cmp -s $testroot/diff.expected $testroot/diff
414 360f3aea 2022-08-30 mark if [ $ret -ne 0 ]; then
416 360f3aea 2022-08-30 mark diff -u $testroot/diff.expected $testroot/diff
417 360f3aea 2022-08-30 mark test_done "$testroot" "$ret"
421 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
424 f6cae3ed 2020-09-13 naddy test_diff_shows_conflict() {
425 95adcdca 2019-03-27 stsp local testroot=`test_init diff_shows_conflict 1`
427 95adcdca 2019-03-27 stsp echo "1" > $testroot/repo/numbers
428 95adcdca 2019-03-27 stsp echo "2" >> $testroot/repo/numbers
429 95adcdca 2019-03-27 stsp echo "3" >> $testroot/repo/numbers
430 95adcdca 2019-03-27 stsp echo "4" >> $testroot/repo/numbers
431 95adcdca 2019-03-27 stsp echo "5" >> $testroot/repo/numbers
432 95adcdca 2019-03-27 stsp echo "6" >> $testroot/repo/numbers
433 95adcdca 2019-03-27 stsp echo "7" >> $testroot/repo/numbers
434 95adcdca 2019-03-27 stsp echo "8" >> $testroot/repo/numbers
435 95adcdca 2019-03-27 stsp (cd $testroot/repo && git add numbers)
436 95adcdca 2019-03-27 stsp git_commit $testroot/repo -m "added numbers file"
437 f69721c3 2019-10-21 stsp local base_commit=`git_show_head $testroot/repo`
439 95adcdca 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
441 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
442 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
446 95adcdca 2019-03-27 stsp sed -i 's/2/22/' $testroot/repo/numbers
447 d136cfcb 2019-10-12 stsp sed -i 's/8/33/' $testroot/repo/numbers
448 95adcdca 2019-03-27 stsp git_commit $testroot/repo -m "modified line 2"
449 95adcdca 2019-03-27 stsp local head_rev=`git_show_head $testroot/repo`
451 d136cfcb 2019-10-12 stsp # modify lines 2 and 8 in conflicting ways
452 95adcdca 2019-03-27 stsp sed -i 's/2/77/' $testroot/wt/numbers
453 d136cfcb 2019-10-12 stsp sed -i 's/8/88/' $testroot/wt/numbers
455 95adcdca 2019-03-27 stsp echo "C numbers" > $testroot/stdout.expected
456 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: $head_rev" \
457 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
458 95adcdca 2019-03-27 stsp echo >> $testroot/stdout.expected
459 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
461 95adcdca 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
463 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
465 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
466 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
467 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
471 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
472 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
473 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
474 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
475 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'numbers$' | cut -d' ' -f 1 \
476 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
477 95adcdca 2019-03-27 stsp echo 'file + numbers' >> $testroot/stdout.expected
478 95adcdca 2019-03-27 stsp echo '--- numbers' >> $testroot/stdout.expected
479 95adcdca 2019-03-27 stsp echo '+++ numbers' >> $testroot/stdout.expected
480 d136cfcb 2019-10-12 stsp echo '@@ -1,8 +1,20 @@' >> $testroot/stdout.expected
481 95adcdca 2019-03-27 stsp echo ' 1' >> $testroot/stdout.expected
482 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
483 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
484 95adcdca 2019-03-27 stsp echo ' 22' >> $testroot/stdout.expected
485 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
486 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
487 d136cfcb 2019-10-12 stsp echo '+2' >> $testroot/stdout.expected
488 95adcdca 2019-03-27 stsp echo '+=======' >> $testroot/stdout.expected
489 95adcdca 2019-03-27 stsp echo '+77' >> $testroot/stdout.expected
490 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
491 95adcdca 2019-03-27 stsp echo ' 3' >> $testroot/stdout.expected
492 95adcdca 2019-03-27 stsp echo ' 4' >> $testroot/stdout.expected
493 95adcdca 2019-03-27 stsp echo ' 5' >> $testroot/stdout.expected
494 d136cfcb 2019-10-12 stsp echo ' 6' >> $testroot/stdout.expected
495 d136cfcb 2019-10-12 stsp echo ' 7' >> $testroot/stdout.expected
496 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
497 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
498 d136cfcb 2019-10-12 stsp echo ' 33' >> $testroot/stdout.expected
499 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
500 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
501 d136cfcb 2019-10-12 stsp echo '+8' >> $testroot/stdout.expected
502 d136cfcb 2019-10-12 stsp echo '+=======' >> $testroot/stdout.expected
503 d136cfcb 2019-10-12 stsp echo '+88' >> $testroot/stdout.expected
504 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
506 95adcdca 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
508 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
510 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
511 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
513 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
516 f6cae3ed 2020-09-13 naddy test_diff_tag() {
517 d24820bf 2019-08-11 stsp local testroot=`test_init diff_tag`
518 d24820bf 2019-08-11 stsp local commit_id0=`git_show_head $testroot/repo`
519 d24820bf 2019-08-11 stsp local tag1=1.0.0
520 d24820bf 2019-08-11 stsp local tag2=2.0.0
522 d24820bf 2019-08-11 stsp echo "modified alpha" > $testroot/repo/alpha
523 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "changed alpha"
524 d24820bf 2019-08-11 stsp local commit_id1=`git_show_head $testroot/repo`
526 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag1)
528 d24820bf 2019-08-11 stsp echo "new file" > $testroot/repo/new
529 d24820bf 2019-08-11 stsp (cd $testroot/repo && git add new)
530 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "new file"
531 d24820bf 2019-08-11 stsp local commit_id2=`git_show_head $testroot/repo`
533 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag2)
535 d24820bf 2019-08-11 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
536 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
537 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
538 d24820bf 2019-08-11 stsp echo -n 'blob - ' >> $testroot/stdout.expected
539 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
540 d24820bf 2019-08-11 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
541 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
542 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
543 d24820bf 2019-08-11 stsp >> $testroot/stdout.expected
544 d24820bf 2019-08-11 stsp echo '--- alpha' >> $testroot/stdout.expected
545 d24820bf 2019-08-11 stsp echo '+++ alpha' >> $testroot/stdout.expected
546 d24820bf 2019-08-11 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
547 d24820bf 2019-08-11 stsp echo '-alpha' >> $testroot/stdout.expected
548 d24820bf 2019-08-11 stsp echo '+modified alpha' >> $testroot/stdout.expected
550 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
551 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
553 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
554 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
555 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
559 d24820bf 2019-08-11 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
560 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
561 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
562 d24820bf 2019-08-11 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
563 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
564 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
565 46f68b20 2019-10-19 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
566 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
567 d24820bf 2019-08-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
568 d24820bf 2019-08-11 stsp echo '+++ new' >> $testroot/stdout.expected
569 d24820bf 2019-08-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
570 d24820bf 2019-08-11 stsp echo '+new file' >> $testroot/stdout.expected
572 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
573 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
575 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
576 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
578 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
581 f6cae3ed 2020-09-13 naddy test_diff_lightweight_tag() {
582 562580bc 2020-01-14 stsp local testroot=`test_init diff_tag`
583 562580bc 2020-01-14 stsp local commit_id0=`git_show_head $testroot/repo`
584 562580bc 2020-01-14 stsp local tag1=1.0.0
585 562580bc 2020-01-14 stsp local tag2=2.0.0
587 562580bc 2020-01-14 stsp echo "modified alpha" > $testroot/repo/alpha
588 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "changed alpha"
589 562580bc 2020-01-14 stsp local commit_id1=`git_show_head $testroot/repo`
591 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag1)
593 562580bc 2020-01-14 stsp echo "new file" > $testroot/repo/new
594 562580bc 2020-01-14 stsp (cd $testroot/repo && git add new)
595 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "new file"
596 562580bc 2020-01-14 stsp local commit_id2=`git_show_head $testroot/repo`
598 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag2)
600 562580bc 2020-01-14 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
601 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
602 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
603 562580bc 2020-01-14 stsp echo -n 'blob - ' >> $testroot/stdout.expected
604 562580bc 2020-01-14 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
605 562580bc 2020-01-14 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
606 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
607 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
608 562580bc 2020-01-14 stsp >> $testroot/stdout.expected
609 562580bc 2020-01-14 stsp echo '--- alpha' >> $testroot/stdout.expected
610 562580bc 2020-01-14 stsp echo '+++ alpha' >> $testroot/stdout.expected
611 562580bc 2020-01-14 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
612 562580bc 2020-01-14 stsp echo '-alpha' >> $testroot/stdout.expected
613 562580bc 2020-01-14 stsp echo '+modified alpha' >> $testroot/stdout.expected
615 562580bc 2020-01-14 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
616 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
618 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
619 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
620 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
624 562580bc 2020-01-14 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
625 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
626 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
627 562580bc 2020-01-14 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
628 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
629 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
630 562580bc 2020-01-14 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
631 562580bc 2020-01-14 stsp echo " (mode 644)" >> $testroot/stdout.expected
632 562580bc 2020-01-14 stsp echo '--- /dev/null' >> $testroot/stdout.expected
633 562580bc 2020-01-14 stsp echo '+++ new' >> $testroot/stdout.expected
634 562580bc 2020-01-14 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
635 562580bc 2020-01-14 stsp echo '+new file' >> $testroot/stdout.expected
637 562580bc 2020-01-14 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
638 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
640 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
641 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
643 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
646 f6cae3ed 2020-09-13 naddy test_diff_ignore_whitespace() {
647 63035f9f 2019-10-06 stsp local testroot=`test_init diff_ignore_whitespace`
648 63035f9f 2019-10-06 stsp local commit_id0=`git_show_head $testroot/repo`
650 63035f9f 2019-10-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
652 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
653 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
657 63035f9f 2019-10-06 stsp echo "alpha " > $testroot/wt/alpha
659 63035f9f 2019-10-06 stsp (cd $testroot/wt && got diff -w > $testroot/stdout)
661 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
662 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
663 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
664 63035f9f 2019-10-06 stsp echo -n 'blob - ' >> $testroot/stdout.expected
665 63035f9f 2019-10-06 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
666 63035f9f 2019-10-06 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
667 63035f9f 2019-10-06 stsp echo 'file + alpha' >> $testroot/stdout.expected
669 63035f9f 2019-10-06 stsp cmp -s $testroot/stdout.expected $testroot/stdout
671 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
672 63035f9f 2019-10-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
674 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
677 f6cae3ed 2020-09-13 naddy test_diff_submodule_of_same_repo() {
678 e7303626 2020-05-14 stsp local testroot=`test_init diff_submodule_of_same_repo`
680 e7303626 2020-05-14 stsp (cd $testroot && git clone -q repo repo2 >/dev/null)
681 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
682 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
683 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
685 e7303626 2020-05-14 stsp epsilon_id=$(got tree -r $testroot/repo -i | grep 'epsilon/$' | \
686 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
687 e7303626 2020-05-14 stsp submodule_id=$(got tree -r $testroot/repo -i | grep 'repo2\$$' | \
688 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
690 e7303626 2020-05-14 stsp # Attempt a (nonsensical) diff between a tree object and a submodule.
691 e7303626 2020-05-14 stsp # Currently fails with "wrong type of object" error
692 e7303626 2020-05-14 stsp got diff -r $testroot/repo $epsilon_id $submodule_id \
693 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
695 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
696 e7303626 2020-05-14 stsp echo "diff command succeeded unexpectedly" >&2
697 e7303626 2020-05-14 stsp test_done "$testroot" "1"
700 e7303626 2020-05-14 stsp echo "got: wrong type of object" > $testroot/stderr.expected
702 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
704 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
705 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
708 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
711 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_work_tree() {
712 39449a05 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_work_tree`
714 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
715 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
716 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
717 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
718 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
719 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
720 39449a05 2020-07-23 stsp (cd $testroot/repo && git add .)
721 39449a05 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
722 39449a05 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
724 39449a05 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
726 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
727 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
731 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
732 4135d7d0 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
733 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
734 39449a05 2020-07-23 stsp echo -n '.got/bar' > $testroot/wt/dotgotfoo.link
735 39449a05 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
736 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf epsilon/zeta zeta.link)
737 39449a05 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
738 39449a05 2020-07-23 stsp (cd $testroot/wt && got diff > $testroot/stdout)
740 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
741 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
742 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
743 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
744 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
745 39449a05 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
746 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
747 39449a05 2020-07-23 stsp echo 'file + alpha.link' >> $testroot/stdout.expected
748 39449a05 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
749 39449a05 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
750 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
751 39449a05 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
752 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
753 39449a05 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
754 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
755 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
756 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
757 39449a05 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
758 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
759 39449a05 2020-07-23 stsp echo 'file + dotgotfoo.link' >> $testroot/stdout.expected
760 39449a05 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
761 39449a05 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
762 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
763 39449a05 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
764 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
765 39449a05 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
766 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
767 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
768 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
769 39449a05 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
770 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
771 39449a05 2020-07-23 stsp echo 'file + epsilon/beta.link' >> $testroot/stdout.expected
772 39449a05 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
773 39449a05 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
774 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
775 39449a05 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
776 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
777 39449a05 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
778 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
779 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
780 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
781 4135d7d0 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
782 4135d7d0 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
783 4135d7d0 2020-07-23 stsp echo 'file + epsilon.link' >> $testroot/stdout.expected
784 4135d7d0 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
785 4135d7d0 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
786 4135d7d0 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
787 4135d7d0 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
788 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
789 4135d7d0 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
790 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
791 4135d7d0 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
792 4135d7d0 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
793 39449a05 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
794 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
795 39449a05 2020-07-23 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
796 39449a05 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
797 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
798 39449a05 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
799 39449a05 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
800 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
801 39449a05 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
802 c87842d5 2022-09-23 mark echo 'file + zeta.link (mode 120000)' >> $testroot/stdout.expected
803 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
804 39449a05 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
805 39449a05 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
806 39449a05 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
807 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
809 39449a05 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
811 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
812 39449a05 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
814 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
817 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_repo() {
818 40dde666 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_repo`
820 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
821 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
822 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
823 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
824 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
825 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
826 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
827 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
828 40dde666 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
830 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
831 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sfh gamma epsilon.link)
832 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
833 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar $testroot/repo/dotgotfoo.link)
834 40dde666 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
835 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
836 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
837 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
838 40dde666 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
840 40dde666 2020-07-23 stsp got diff -r $testroot/repo $commit_id1 $commit_id2 > $testroot/stdout
842 40dde666 2020-07-23 stsp echo "diff $commit_id1 $commit_id2" > $testroot/stdout.expected
843 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
844 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
845 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
846 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
847 40dde666 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
848 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
849 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
850 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
851 40dde666 2020-07-23 stsp grep 'alpha.link@ -> beta$' | \
852 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
853 40dde666 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
854 40dde666 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
855 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
856 40dde666 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
857 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
858 40dde666 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
859 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
860 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
861 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
862 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
863 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
864 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
865 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
866 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/bar$' | \
867 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
868 40dde666 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
869 40dde666 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
870 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
871 40dde666 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
872 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
873 40dde666 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
874 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
875 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
876 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
877 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
878 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
879 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
880 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i epsilon | \
881 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../gamma/delta$' | \
882 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
883 40dde666 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
884 40dde666 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
885 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
886 40dde666 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
887 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
888 40dde666 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
889 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
890 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
891 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
892 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
893 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
894 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
895 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
896 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> gamma$' | \
897 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
898 40dde666 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
899 40dde666 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
900 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
901 40dde666 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
902 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
903 40dde666 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
904 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
905 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
906 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
907 40dde666 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
908 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
909 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
910 40dde666 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
911 40dde666 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
912 40dde666 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
913 40dde666 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
914 40dde666 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
915 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
916 40dde666 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
917 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
918 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
919 40dde666 2020-07-23 stsp grep 'zeta.link@ -> epsilon/zeta$' | \
920 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
921 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
922 40dde666 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
923 40dde666 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
924 40dde666 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
925 40dde666 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
926 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
928 40dde666 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
930 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
931 40dde666 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
933 40dde666 2020-07-23 stsp test_done "$testroot" "$ret"
936 dffd0deb 2020-11-20 stsp test_diff_binary_files() {
937 dffd0deb 2020-11-20 stsp local testroot=`test_init diff_binary_files`
938 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
940 dffd0deb 2020-11-20 stsp got checkout $testroot/repo $testroot/wt > /dev/null
942 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
943 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
947 dffd0deb 2020-11-20 stsp printf '\377\377\0\0\377\377\0\0' > $testroot/wt/foo
948 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got add foo >/dev/null)
950 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
951 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
952 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
953 dffd0deb 2020-11-20 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
954 c87842d5 2022-09-23 mark echo 'file + foo (mode 644)' >> $testroot/stdout.expected
955 1cb46f00 2020-11-21 stsp echo "Binary files /dev/null and foo differ" \
956 1cb46f00 2020-11-21 stsp >> $testroot/stdout.expected
958 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff > $testroot/stdout)
959 64453f7e 2020-11-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
962 64453f7e 2020-11-21 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
963 64453f7e 2020-11-21 stsp test_done "$testroot" "$ret"
967 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
968 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
969 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
970 64453f7e 2020-11-21 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
971 c87842d5 2022-09-23 mark echo 'file + foo (mode 644)' >> $testroot/stdout.expected
972 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
973 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
974 dffd0deb 2020-11-20 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
975 dffd0deb 2020-11-20 stsp printf '+\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
976 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
978 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
979 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
981 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
982 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
983 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
987 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
988 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
990 dffd0deb 2020-11-20 stsp printf '\377\200\0\0\377\200\0\0' > $testroot/wt/foo
992 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
993 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
994 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
995 dffd0deb 2020-11-20 stsp echo -n 'blob - ' >> $testroot/stdout.expected
996 dffd0deb 2020-11-20 stsp got tree -r $testroot/repo -i | grep 'foo$' | cut -d' ' -f 1 \
997 dffd0deb 2020-11-20 stsp >> $testroot/stdout.expected
998 dffd0deb 2020-11-20 stsp echo 'file + foo' >> $testroot/stdout.expected
999 dffd0deb 2020-11-20 stsp echo '--- foo' >> $testroot/stdout.expected
1000 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
1001 dffd0deb 2020-11-20 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1002 578133c9 2020-11-28 naddy printf -- '-\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
1003 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
1004 dffd0deb 2020-11-20 stsp printf '+\377\200\0\0\377\200\0\0\n' >> $testroot/stdout.expected
1005 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
1007 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
1008 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1010 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1011 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
1013 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
1016 67b631c9 2021-10-10 stsp test_diff_commits() {
1017 67b631c9 2021-10-10 stsp local testroot=`test_init diff_commits`
1018 67b631c9 2021-10-10 stsp local commit_id0=`git_show_head $testroot/repo`
1019 67b631c9 2021-10-10 stsp alpha_id0=`get_blob_id $testroot/repo "" alpha`
1020 67b631c9 2021-10-10 stsp beta_id0=`get_blob_id $testroot/repo "" beta`
1022 67b631c9 2021-10-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1024 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1025 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1029 67b631c9 2021-10-10 stsp echo "modified alpha" > $testroot/wt/alpha
1030 67b631c9 2021-10-10 stsp (cd $testroot/wt && got rm beta >/dev/null)
1031 67b631c9 2021-10-10 stsp echo "new file" > $testroot/wt/new
1032 67b631c9 2021-10-10 stsp (cd $testroot/wt && got add new >/dev/null)
1033 67b631c9 2021-10-10 stsp (cd $testroot/wt && got commit -m 'committing changes' >/dev/null)
1034 67b631c9 2021-10-10 stsp local commit_id1=`git_show_head $testroot/repo`
1036 67b631c9 2021-10-10 stsp alpha_id1=`get_blob_id $testroot/repo "" alpha`
1037 67b631c9 2021-10-10 stsp new_id1=`get_blob_id $testroot/repo "" new`
1039 67b631c9 2021-10-10 stsp echo "diff $commit_id0 refs/heads/master" > $testroot/stdout.expected
1040 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1041 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1042 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1043 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1044 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1045 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1046 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1047 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1048 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1049 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1050 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1051 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1052 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1053 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1054 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1055 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1056 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1057 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1058 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1059 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1060 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1062 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c master > $testroot/stdout)
1063 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1065 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1066 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1067 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1071 67b631c9 2021-10-10 stsp # same diff with explicit parent commit ID
1072 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c master \
1073 67b631c9 2021-10-10 stsp > $testroot/stdout)
1074 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1076 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1077 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1078 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1082 67b631c9 2021-10-10 stsp # same diff with commit object IDs
1083 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1084 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1085 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1086 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1087 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1088 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1089 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1090 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1091 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1092 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1093 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1094 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1095 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1096 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1097 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1098 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1099 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1100 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1101 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1102 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1103 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1104 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1105 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 \
1106 67b631c9 2021-10-10 stsp > $testroot/stdout)
1107 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1109 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1110 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1111 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1115 67b631c9 2021-10-10 stsp # same diff, filtered by paths
1116 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1117 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1118 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1119 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1120 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1121 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1122 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1123 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1124 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1125 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1126 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 alpha \
1127 67b631c9 2021-10-10 stsp > $testroot/stdout)
1128 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1130 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1131 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1132 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1135 67b631c9 2021-10-10 stsp # same in a work tree
1136 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 alpha \
1137 67b631c9 2021-10-10 stsp > $testroot/stdout)
1138 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1140 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1141 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1142 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1146 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1147 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1148 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1149 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1150 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1151 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1152 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1153 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1154 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1155 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1156 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1157 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1158 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1159 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1160 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1161 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 \
1162 67b631c9 2021-10-10 stsp beta new > $testroot/stdout)
1163 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1165 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1166 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1167 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1171 67b631c9 2021-10-10 stsp # more than two -c options are not allowed
1172 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 -c foo \
1173 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1175 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1176 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1177 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1180 67b631c9 2021-10-10 stsp echo "got: too many -c options used" > $testroot/stderr.expected
1181 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1183 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1184 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1185 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1189 67b631c9 2021-10-10 stsp # use of -c options implies a repository diff; use with -P is an error
1190 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -P foo \
1191 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1193 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1194 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1195 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1198 67b631c9 2021-10-10 stsp echo "got: -P option can only be used when diffing a work tree" \
1199 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1200 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1202 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1203 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1204 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1208 67b631c9 2021-10-10 stsp # use of -c options implies a repository diff; use with -s is an error
1209 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -s foo \
1210 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1212 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1213 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1214 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1217 67b631c9 2021-10-10 stsp echo "got: -s option can only be used when diffing a work tree" \
1218 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1219 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1221 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1222 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1223 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1227 67b631c9 2021-10-10 stsp # three arguments imply use of path filtering (repository case)
1228 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff $commit_id0 $commit_id1 foo \
1229 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1231 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1232 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1233 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1236 67b631c9 2021-10-10 stsp echo "got: specified paths cannot be resolved: no got work tree found" \
1237 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1238 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1240 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1241 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1242 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1246 67b631c9 2021-10-10 stsp # three arguments imply use of path filtering (work tree case)
1247 10a623df 2021-10-11 stsp (cd $testroot/wt && got diff $commit_id0 master foo \
1248 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1250 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1251 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1252 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1255 67b631c9 2021-10-10 stsp echo "got: $commit_id0: No such file or directory" \
1256 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1257 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1259 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1260 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1262 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1265 32b5305f 2022-02-12 op test_diff_ignored_file() {
1266 32b5305f 2022-02-12 op local testroot=`test_init diff_ignored_file`
1268 32b5305f 2022-02-12 op got checkout $testroot/repo $testroot/wt > /dev/null
1270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1271 32b5305f 2022-02-12 op test_done "$testroot" "$ret"
1275 32b5305f 2022-02-12 op echo 1 > $testroot/wt/number
1276 32b5305f 2022-02-12 op (cd $testroot/wt && got add number >/dev/null)
1277 32b5305f 2022-02-12 op (cd $testroot/wt && got commit -m 'add number' >/dev/null)
1279 32b5305f 2022-02-12 op echo "**/number" > $testroot/wt/.gitignore
1281 32b5305f 2022-02-12 op echo 2 > $testroot/wt/number
1282 32b5305f 2022-02-12 op (cd $testroot/wt && got diff number | sed '1,/^@@/d' > $testroot/stdout)
1284 32b5305f 2022-02-12 op echo "-1" > $testroot/stdout.expected
1285 32b5305f 2022-02-12 op echo "+2" >> $testroot/stdout.expected
1287 32b5305f 2022-02-12 op cmp -s $testroot/stdout.expected $testroot/stdout
1289 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1290 32b5305f 2022-02-12 op diff -u $testroot/stdout.expected $testroot/stdout
1292 32b5305f 2022-02-12 op test_done "$testroot" "$ret"
1295 0543436d 2022-07-26 op test_diff_crlf() {
1296 0543436d 2022-07-26 op local testroot=`test_init diff_crlf`
1298 0543436d 2022-07-26 op got checkout $testroot/repo $testroot/wt > /dev/null
1300 0543436d 2022-07-26 op if [ $ret -ne 0 ]; then
1301 0543436d 2022-07-26 op test_done "$testroot" $ret
1305 0543436d 2022-07-26 op printf 'test\r\n' > $testroot/wt/crlf
1306 0543436d 2022-07-26 op (cd $testroot/wt && got add crlf && got commit -m +crlf) >/dev/null
1308 0543436d 2022-07-26 op if [ $ret -ne 0 ]; then
1309 0543436d 2022-07-26 op test_done "$testroot" $ret
1313 0543436d 2022-07-26 op printf 'test 2\r\n' > $testroot/wt/crlf
1314 0543436d 2022-07-26 op (cd $testroot/wt && got diff | sed -n '/^---/,$p' > $testroot/stdout)
1315 0543436d 2022-07-26 op cat <<EOF > $testroot/stdout.expected
1323 0543436d 2022-07-26 op cmp -s $testroot/stdout.expected $testroot/stdout
1325 0543436d 2022-07-26 op if [ $ret -ne 0 ]; then
1326 0543436d 2022-07-26 op diff -u $testroot/stdout.expected $testroot/stdout
1328 0543436d 2022-07-26 op test_done "$testroot" $ret
1331 c87842d5 2022-09-23 mark test_diff_worktree_newfile_xbit() {
1332 c87842d5 2022-09-23 mark local testroot=`test_init diff_worktree_newfile_xbit`
1334 c87842d5 2022-09-23 mark got checkout $testroot/repo $testroot/wt > /dev/null
1336 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1337 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1341 c87842d5 2022-09-23 mark echo xfile > $testroot/wt/xfile
1342 c87842d5 2022-09-23 mark chmod +x $testroot/wt/xfile
1343 c87842d5 2022-09-23 mark (cd $testroot/wt && got add xfile) > /dev/null
1345 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1346 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1349 c87842d5 2022-09-23 mark (cd $testroot/wt && got diff) > $testroot/stdout
1351 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1352 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1356 c87842d5 2022-09-23 mark local commit_id=`git_show_head $testroot/repo`
1357 c87842d5 2022-09-23 mark cat <<EOF > $testroot/stdout.expected
1358 c87842d5 2022-09-23 mark diff $testroot/wt
1359 c87842d5 2022-09-23 mark commit - $commit_id
1360 c87842d5 2022-09-23 mark path + $testroot/wt
1361 c87842d5 2022-09-23 mark blob - /dev/null
1362 c87842d5 2022-09-23 mark file + xfile (mode 755)
1363 c87842d5 2022-09-23 mark --- /dev/null
1365 c87842d5 2022-09-23 mark @@ -0,0 +1 @@
1369 c87842d5 2022-09-23 mark cmp -s $testroot/stdout.expected $testroot/stdout
1371 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1372 c87842d5 2022-09-23 mark echo "failed to record mode 755"
1373 c87842d5 2022-09-23 mark diff -u $testroot/stdout.expected $testroot/stdout
1375 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1378 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1379 95adcdca 2019-03-27 stsp run_test test_diff_basic
1380 95adcdca 2019-03-27 stsp run_test test_diff_shows_conflict
1381 d24820bf 2019-08-11 stsp run_test test_diff_tag
1382 562580bc 2020-01-14 stsp run_test test_diff_lightweight_tag
1383 63035f9f 2019-10-06 stsp run_test test_diff_ignore_whitespace
1384 e7303626 2020-05-14 stsp run_test test_diff_submodule_of_same_repo
1385 39449a05 2020-07-23 stsp run_test test_diff_symlinks_in_work_tree
1386 40dde666 2020-07-23 stsp run_test test_diff_symlinks_in_repo
1387 dffd0deb 2020-11-20 stsp run_test test_diff_binary_files
1388 67b631c9 2021-10-10 stsp run_test test_diff_commits
1389 32b5305f 2022-02-12 op run_test test_diff_ignored_file
1390 0543436d 2022-07-26 op run_test test_diff_crlf
1391 c87842d5 2022-09-23 mark run_test test_diff_worktree_newfile_xbit