Blame


1 95adcdca 2019-03-27 stsp #!/bin/sh
2 95adcdca 2019-03-27 stsp #
3 95adcdca 2019-03-27 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 95adcdca 2019-03-27 stsp #
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.
8 95adcdca 2019-03-27 stsp #
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.
16 95adcdca 2019-03-27 stsp
17 95adcdca 2019-03-27 stsp . ./common.sh
18 95adcdca 2019-03-27 stsp
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 95adcdca 2019-03-27 stsp
23 95adcdca 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 49c543a6 2022-03-31 naddy ret=$?
25 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
26 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
27 95adcdca 2019-03-27 stsp return 1
28 95adcdca 2019-03-27 stsp fi
29 95adcdca 2019-03-27 stsp
30 95adcdca 2019-03-27 stsp echo "modified alpha" > $testroot/wt/alpha
31 95adcdca 2019-03-27 stsp (cd $testroot/wt && got rm beta >/dev/null)
32 95adcdca 2019-03-27 stsp echo "new file" > $testroot/wt/new
33 95adcdca 2019-03-27 stsp (cd $testroot/wt && got add new >/dev/null)
34 95adcdca 2019-03-27 stsp
35 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
36 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
37 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
38 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
39 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
40 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
41 95adcdca 2019-03-27 stsp echo 'file + alpha' >> $testroot/stdout.expected
42 95adcdca 2019-03-27 stsp echo '--- alpha' >> $testroot/stdout.expected
43 95adcdca 2019-03-27 stsp echo '+++ alpha' >> $testroot/stdout.expected
44 95adcdca 2019-03-27 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
45 95adcdca 2019-03-27 stsp echo '-alpha' >> $testroot/stdout.expected
46 95adcdca 2019-03-27 stsp echo '+modified alpha' >> $testroot/stdout.expected
47 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
48 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
49 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
50 95adcdca 2019-03-27 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
51 95adcdca 2019-03-27 stsp echo '--- beta' >> $testroot/stdout.expected
52 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
53 95adcdca 2019-03-27 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
54 95adcdca 2019-03-27 stsp echo '-beta' >> $testroot/stdout.expected
55 95adcdca 2019-03-27 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
56 95adcdca 2019-03-27 stsp echo 'file + new' >> $testroot/stdout.expected
57 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
58 95adcdca 2019-03-27 stsp echo '+++ new' >> $testroot/stdout.expected
59 95adcdca 2019-03-27 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
60 95adcdca 2019-03-27 stsp echo '+new file' >> $testroot/stdout.expected
61 95adcdca 2019-03-27 stsp
62 95adcdca 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
63 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
64 49c543a6 2022-03-31 naddy ret=$?
65 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
66 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
67 2a06fe5f 2019-08-24 stsp test_done "$testroot" "$ret"
68 2a06fe5f 2019-08-24 stsp return 1
69 95adcdca 2019-03-27 stsp fi
70 2a06fe5f 2019-08-24 stsp
71 e7ffb0b0 2021-10-07 stsp # 'got diff' in a repository without any arguments is an error
72 e7ffb0b0 2021-10-07 stsp (cd $testroot/repo && got diff 2> $testroot/stderr)
73 e7ffb0b0 2021-10-07 stsp echo "got: no got work tree found" > $testroot/stderr.expected
74 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
75 49c543a6 2022-03-31 naddy ret=$?
76 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
77 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
78 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
79 e7ffb0b0 2021-10-07 stsp return 1
80 e7ffb0b0 2021-10-07 stsp fi
81 e7ffb0b0 2021-10-07 stsp
82 e7ffb0b0 2021-10-07 stsp # 'got diff' in a repository with two arguments requires that
83 e7ffb0b0 2021-10-07 stsp # both named objects exist
84 e7ffb0b0 2021-10-07 stsp (cd $testroot/repo && got diff $head_rev foo 2> $testroot/stderr)
85 e7ffb0b0 2021-10-07 stsp echo "got: foo: object not found" > $testroot/stderr.expected
86 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
87 49c543a6 2022-03-31 naddy ret=$?
88 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
89 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
90 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
91 e7ffb0b0 2021-10-07 stsp return 1
92 e7ffb0b0 2021-10-07 stsp fi
93 e7ffb0b0 2021-10-07 stsp
94 2a06fe5f 2019-08-24 stsp # diff non-existent path
95 2a06fe5f 2019-08-24 stsp (cd $testroot/wt && got diff nonexistent > $testroot/stdout \
96 2a06fe5f 2019-08-24 stsp 2> $testroot/stderr)
97 2a06fe5f 2019-08-24 stsp
98 2a06fe5f 2019-08-24 stsp echo -n > $testroot/stdout.expected
99 2a06fe5f 2019-08-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
100 49c543a6 2022-03-31 naddy ret=$?
101 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
102 2a06fe5f 2019-08-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
103 2a06fe5f 2019-08-24 stsp test_done "$testroot" "$ret"
104 2a06fe5f 2019-08-24 stsp return 1
105 2a06fe5f 2019-08-24 stsp fi
106 2a06fe5f 2019-08-24 stsp
107 2a06fe5f 2019-08-24 stsp echo "got: nonexistent: No such file or directory" \
108 e7ffb0b0 2021-10-07 stsp > $testroot/stderr.expected
109 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
110 49c543a6 2022-03-31 naddy ret=$?
111 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
112 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
113 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
114 e7ffb0b0 2021-10-07 stsp return 1
115 e7ffb0b0 2021-10-07 stsp fi
116 e7ffb0b0 2021-10-07 stsp
117 e7ffb0b0 2021-10-07 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
118 e7ffb0b0 2021-10-07 stsp
119 e7ffb0b0 2021-10-07 stsp # diff several paths in a work tree
120 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
121 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
122 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
123 e7ffb0b0 2021-10-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
124 e7ffb0b0 2021-10-07 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
125 e7ffb0b0 2021-10-07 stsp >> $testroot/stdout.expected
126 e7ffb0b0 2021-10-07 stsp echo 'file + alpha' >> $testroot/stdout.expected
127 e7ffb0b0 2021-10-07 stsp echo '--- alpha' >> $testroot/stdout.expected
128 e7ffb0b0 2021-10-07 stsp echo '+++ alpha' >> $testroot/stdout.expected
129 e7ffb0b0 2021-10-07 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
130 e7ffb0b0 2021-10-07 stsp echo '-alpha' >> $testroot/stdout.expected
131 e7ffb0b0 2021-10-07 stsp echo '+modified alpha' >> $testroot/stdout.expected
132 e7ffb0b0 2021-10-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
133 10a623df 2021-10-11 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
134 10a623df 2021-10-11 stsp >> $testroot/stdout.expected
135 10a623df 2021-10-11 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
136 10a623df 2021-10-11 stsp echo '--- beta' >> $testroot/stdout.expected
137 10a623df 2021-10-11 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
138 10a623df 2021-10-11 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
139 10a623df 2021-10-11 stsp echo '-beta' >> $testroot/stdout.expected
140 10a623df 2021-10-11 stsp echo -n 'blob - ' >> $testroot/stdout.expected
141 e7ffb0b0 2021-10-07 stsp got tree -r $testroot/repo -i epsilon | grep 'zeta$' | cut -d' ' -f 1 \
142 e7ffb0b0 2021-10-07 stsp >> $testroot/stdout.expected
143 e7ffb0b0 2021-10-07 stsp echo 'file + epsilon/zeta' >> $testroot/stdout.expected
144 e7ffb0b0 2021-10-07 stsp echo '--- epsilon/zeta' >> $testroot/stdout.expected
145 e7ffb0b0 2021-10-07 stsp echo '+++ epsilon/zeta' >> $testroot/stdout.expected
146 e7ffb0b0 2021-10-07 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
147 e7ffb0b0 2021-10-07 stsp echo '-zeta' >> $testroot/stdout.expected
148 e7ffb0b0 2021-10-07 stsp echo '+modified zeta' >> $testroot/stdout.expected
149 10a623df 2021-10-11 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
150 10a623df 2021-10-11 stsp echo 'file + new' >> $testroot/stdout.expected
151 10a623df 2021-10-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
152 10a623df 2021-10-11 stsp echo '+++ new' >> $testroot/stdout.expected
153 10a623df 2021-10-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
154 10a623df 2021-10-11 stsp echo '+new file' >> $testroot/stdout.expected
155 e7ffb0b0 2021-10-07 stsp
156 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new alpha epsilon beta > $testroot/stdout)
157 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
158 49c543a6 2022-03-31 naddy ret=$?
159 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
160 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
161 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
162 e7ffb0b0 2021-10-07 stsp return 1
163 e7ffb0b0 2021-10-07 stsp fi
164 e7ffb0b0 2021-10-07 stsp
165 10a623df 2021-10-11 stsp # different order of arguments results in same output order
166 10a623df 2021-10-11 stsp (cd $testroot/wt && got diff alpha new epsilon beta \
167 e7ffb0b0 2021-10-07 stsp > $testroot/stdout 2> $testroot/stderr)
168 49c543a6 2022-03-31 naddy ret=$?
169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
170 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
171 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
172 e7ffb0b0 2021-10-07 stsp return 1
173 e7ffb0b0 2021-10-07 stsp fi
174 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
175 49c543a6 2022-03-31 naddy ret=$?
176 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
177 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
178 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
179 e7ffb0b0 2021-10-07 stsp return 1
180 e7ffb0b0 2021-10-07 stsp fi
181 e7ffb0b0 2021-10-07 stsp
182 10a623df 2021-10-11 stsp # a branch 'new' should not collide with path 'new' if more
183 10a623df 2021-10-11 stsp # than two arguments are passed
184 10a623df 2021-10-11 stsp got br -r $testroot/repo -c master new > /dev/null
185 10a623df 2021-10-11 stsp (cd $testroot/wt && got diff new alpha epsilon beta \
186 e7ffb0b0 2021-10-07 stsp > $testroot/stdout 2> $testroot/stderr)
187 49c543a6 2022-03-31 naddy ret=$?
188 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
189 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
190 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
191 e7ffb0b0 2021-10-07 stsp return 1
192 e7ffb0b0 2021-10-07 stsp fi
193 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
194 49c543a6 2022-03-31 naddy ret=$?
195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
196 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
197 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
198 e7ffb0b0 2021-10-07 stsp return 1
199 e7ffb0b0 2021-10-07 stsp fi
200 e7ffb0b0 2021-10-07 stsp
201 e7ffb0b0 2021-10-07 stsp # Two arguments are interpreted as objects if a colliding path exists
202 e7ffb0b0 2021-10-07 stsp echo master > $testroot/wt/master
203 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got add master > /dev/null)
204 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff master new > $testroot/stdout)
205 49c543a6 2022-03-31 naddy ret=$?
206 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
207 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
208 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
209 e7ffb0b0 2021-10-07 stsp return 1
210 e7ffb0b0 2021-10-07 stsp fi
211 e7ffb0b0 2021-10-07 stsp echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
212 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
213 8469d821 2022-06-25 stsp echo "commit + $head_rev" >> $testroot/stdout.expected
214 e7ffb0b0 2021-10-07 stsp # diff between the branches is empty
215 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
216 49c543a6 2022-03-31 naddy ret=$?
217 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
218 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
219 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
220 e7ffb0b0 2021-10-07 stsp return 1
221 e7ffb0b0 2021-10-07 stsp fi
222 e7ffb0b0 2021-10-07 stsp # same without a work tree
223 e7ffb0b0 2021-10-07 stsp (cd $testroot/repo && got diff master new > $testroot/stdout)
224 49c543a6 2022-03-31 naddy ret=$?
225 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
226 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
227 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
228 e7ffb0b0 2021-10-07 stsp return 1
229 e7ffb0b0 2021-10-07 stsp fi
230 e7ffb0b0 2021-10-07 stsp echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
231 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
232 8469d821 2022-06-25 stsp echo "commit + $head_rev" >> $testroot/stdout.expected
233 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
234 49c543a6 2022-03-31 naddy ret=$?
235 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
236 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
237 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
238 e7ffb0b0 2021-10-07 stsp return 1
239 e7ffb0b0 2021-10-07 stsp fi
240 e7ffb0b0 2021-10-07 stsp # same with -r argument
241 e7ffb0b0 2021-10-07 stsp got diff -r $testroot/repo master new > $testroot/stdout
242 49c543a6 2022-03-31 naddy ret=$?
243 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
244 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
245 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
246 e7ffb0b0 2021-10-07 stsp return 1
247 e7ffb0b0 2021-10-07 stsp fi
248 e7ffb0b0 2021-10-07 stsp echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
249 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
250 8469d821 2022-06-25 stsp echo "commit + $head_rev" >> $testroot/stdout.expected
251 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
252 49c543a6 2022-03-31 naddy ret=$?
253 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
254 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
255 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
256 e7ffb0b0 2021-10-07 stsp return 1
257 e7ffb0b0 2021-10-07 stsp fi
258 e7ffb0b0 2021-10-07 stsp
259 e7ffb0b0 2021-10-07 stsp # -P can be used to force use of paths
260 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff -P new master > $testroot/stdout)
261 49c543a6 2022-03-31 naddy ret=$?
262 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
263 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
264 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
265 e7ffb0b0 2021-10-07 stsp return 1
266 e7ffb0b0 2021-10-07 stsp fi
267 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
268 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
269 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
270 e7ffb0b0 2021-10-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
271 e7ffb0b0 2021-10-07 stsp echo 'file + master' >> $testroot/stdout.expected
272 e7ffb0b0 2021-10-07 stsp echo '--- /dev/null' >> $testroot/stdout.expected
273 e7ffb0b0 2021-10-07 stsp echo '+++ master' >> $testroot/stdout.expected
274 e7ffb0b0 2021-10-07 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
275 e7ffb0b0 2021-10-07 stsp echo '+master' >> $testroot/stdout.expected
276 10a623df 2021-10-11 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
277 10a623df 2021-10-11 stsp echo 'file + new' >> $testroot/stdout.expected
278 10a623df 2021-10-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
279 10a623df 2021-10-11 stsp echo '+++ new' >> $testroot/stdout.expected
280 10a623df 2021-10-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
281 10a623df 2021-10-11 stsp echo '+new file' >> $testroot/stdout.expected
282 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
283 49c543a6 2022-03-31 naddy ret=$?
284 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
285 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
286 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
287 e7ffb0b0 2021-10-07 stsp return 1
288 e7ffb0b0 2021-10-07 stsp fi
289 e7ffb0b0 2021-10-07 stsp
290 e7ffb0b0 2021-10-07 stsp # -P can only be used in a work tree
291 e7ffb0b0 2021-10-07 stsp got diff -r $testroot/repo -P new master 2> $testroot/stderr
292 49c543a6 2022-03-31 naddy ret=$?
293 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
294 e7ffb0b0 2021-10-07 stsp echo "diff succeeded unexpectedly" >&2
295 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
296 e7ffb0b0 2021-10-07 stsp return 1
297 e7ffb0b0 2021-10-07 stsp fi
298 e7ffb0b0 2021-10-07 stsp echo "got: -P option can only be used when diffing a work tree" \
299 2a06fe5f 2019-08-24 stsp > $testroot/stderr.expected
300 2a06fe5f 2019-08-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
301 49c543a6 2022-03-31 naddy ret=$?
302 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
303 2a06fe5f 2019-08-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
304 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
305 e7ffb0b0 2021-10-07 stsp return 1
306 e7ffb0b0 2021-10-07 stsp fi
307 e7ffb0b0 2021-10-07 stsp
308 e7ffb0b0 2021-10-07 stsp # a single argument which can be resolved to a path is not ambiguous
309 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
310 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
311 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
312 e7ffb0b0 2021-10-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
313 e7ffb0b0 2021-10-07 stsp echo 'file + new' >> $testroot/stdout.expected
314 e7ffb0b0 2021-10-07 stsp echo '--- /dev/null' >> $testroot/stdout.expected
315 e7ffb0b0 2021-10-07 stsp echo '+++ new' >> $testroot/stdout.expected
316 e7ffb0b0 2021-10-07 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
317 e7ffb0b0 2021-10-07 stsp echo '+new file' >> $testroot/stdout.expected
318 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new > $testroot/stdout)
319 49c543a6 2022-03-31 naddy ret=$?
320 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
321 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
322 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
323 e7ffb0b0 2021-10-07 stsp return 1
324 e7ffb0b0 2021-10-07 stsp fi
325 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
326 49c543a6 2022-03-31 naddy ret=$?
327 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
328 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
329 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
330 e7ffb0b0 2021-10-07 stsp return 1
331 e7ffb0b0 2021-10-07 stsp fi
332 e7ffb0b0 2021-10-07 stsp
333 e7ffb0b0 2021-10-07 stsp # diff with just one object ID argument results in
334 e7ffb0b0 2021-10-07 stsp # interpretation of argument as a path
335 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff $head_rev 2> $testroot/stderr)
336 49c543a6 2022-03-31 naddy ret=$?
337 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
338 e7ffb0b0 2021-10-07 stsp echo "diff succeeded unexpectedly" >&2
339 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
340 e7ffb0b0 2021-10-07 stsp return 1
341 e7ffb0b0 2021-10-07 stsp fi
342 e7ffb0b0 2021-10-07 stsp echo "got: $head_rev: No such file or directory" \
343 e7ffb0b0 2021-10-07 stsp > $testroot/stderr.expected
344 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
345 49c543a6 2022-03-31 naddy ret=$?
346 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
347 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
348 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
349 e7ffb0b0 2021-10-07 stsp return 1
350 e7ffb0b0 2021-10-07 stsp fi
351 e7ffb0b0 2021-10-07 stsp
352 e7ffb0b0 2021-10-07 stsp # diff with more than two object arguments results in
353 e7ffb0b0 2021-10-07 stsp # interpretation of arguments as paths
354 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new $head_rev master \
355 e7ffb0b0 2021-10-07 stsp > $testroot/stout 2> $testroot/stderr)
356 49c543a6 2022-03-31 naddy ret=$?
357 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
358 e7ffb0b0 2021-10-07 stsp echo "diff succeeded unexpectedly" >&2
359 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
360 e7ffb0b0 2021-10-07 stsp return 1
361 e7ffb0b0 2021-10-07 stsp fi
362 e7ffb0b0 2021-10-07 stsp
363 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
364 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
365 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
366 e7ffb0b0 2021-10-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
367 e7ffb0b0 2021-10-07 stsp echo 'file + new' >> $testroot/stdout.expected
368 e7ffb0b0 2021-10-07 stsp echo '--- /dev/null' >> $testroot/stdout.expected
369 e7ffb0b0 2021-10-07 stsp echo '+++ new' >> $testroot/stdout.expected
370 e7ffb0b0 2021-10-07 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
371 e7ffb0b0 2021-10-07 stsp echo '+new file' >> $testroot/stdout.expected
372 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
373 49c543a6 2022-03-31 naddy ret=$?
374 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
375 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
376 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
377 e7ffb0b0 2021-10-07 stsp return 1
378 e7ffb0b0 2021-10-07 stsp fi
379 e7ffb0b0 2021-10-07 stsp
380 e7ffb0b0 2021-10-07 stsp echo "got: $head_rev: No such file or directory" \
381 e7ffb0b0 2021-10-07 stsp > $testroot/stderr.expected
382 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
383 49c543a6 2022-03-31 naddy ret=$?
384 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
385 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
386 e7ffb0b0 2021-10-07 stsp return 1
387 2a06fe5f 2019-08-24 stsp fi
388 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
389 95adcdca 2019-03-27 stsp }
390 95adcdca 2019-03-27 stsp
391 f6cae3ed 2020-09-13 naddy test_diff_shows_conflict() {
392 95adcdca 2019-03-27 stsp local testroot=`test_init diff_shows_conflict 1`
393 95adcdca 2019-03-27 stsp
394 95adcdca 2019-03-27 stsp echo "1" > $testroot/repo/numbers
395 95adcdca 2019-03-27 stsp echo "2" >> $testroot/repo/numbers
396 95adcdca 2019-03-27 stsp echo "3" >> $testroot/repo/numbers
397 95adcdca 2019-03-27 stsp echo "4" >> $testroot/repo/numbers
398 95adcdca 2019-03-27 stsp echo "5" >> $testroot/repo/numbers
399 95adcdca 2019-03-27 stsp echo "6" >> $testroot/repo/numbers
400 95adcdca 2019-03-27 stsp echo "7" >> $testroot/repo/numbers
401 95adcdca 2019-03-27 stsp echo "8" >> $testroot/repo/numbers
402 95adcdca 2019-03-27 stsp (cd $testroot/repo && git add numbers)
403 95adcdca 2019-03-27 stsp git_commit $testroot/repo -m "added numbers file"
404 f69721c3 2019-10-21 stsp local base_commit=`git_show_head $testroot/repo`
405 95adcdca 2019-03-27 stsp
406 95adcdca 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
407 49c543a6 2022-03-31 naddy ret=$?
408 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
409 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
410 95adcdca 2019-03-27 stsp return 1
411 95adcdca 2019-03-27 stsp fi
412 95adcdca 2019-03-27 stsp
413 95adcdca 2019-03-27 stsp sed -i 's/2/22/' $testroot/repo/numbers
414 d136cfcb 2019-10-12 stsp sed -i 's/8/33/' $testroot/repo/numbers
415 95adcdca 2019-03-27 stsp git_commit $testroot/repo -m "modified line 2"
416 95adcdca 2019-03-27 stsp local head_rev=`git_show_head $testroot/repo`
417 95adcdca 2019-03-27 stsp
418 d136cfcb 2019-10-12 stsp # modify lines 2 and 8 in conflicting ways
419 95adcdca 2019-03-27 stsp sed -i 's/2/77/' $testroot/wt/numbers
420 d136cfcb 2019-10-12 stsp sed -i 's/8/88/' $testroot/wt/numbers
421 95adcdca 2019-03-27 stsp
422 95adcdca 2019-03-27 stsp echo "C numbers" > $testroot/stdout.expected
423 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: $head_rev" \
424 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
425 95adcdca 2019-03-27 stsp echo >> $testroot/stdout.expected
426 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
427 95adcdca 2019-03-27 stsp
428 95adcdca 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
429 95adcdca 2019-03-27 stsp
430 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
431 49c543a6 2022-03-31 naddy ret=$?
432 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
433 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
434 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
435 95adcdca 2019-03-27 stsp return 1
436 95adcdca 2019-03-27 stsp fi
437 95adcdca 2019-03-27 stsp
438 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
439 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
440 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
441 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
442 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'numbers$' | cut -d' ' -f 1 \
443 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
444 95adcdca 2019-03-27 stsp echo 'file + numbers' >> $testroot/stdout.expected
445 95adcdca 2019-03-27 stsp echo '--- numbers' >> $testroot/stdout.expected
446 95adcdca 2019-03-27 stsp echo '+++ numbers' >> $testroot/stdout.expected
447 d136cfcb 2019-10-12 stsp echo '@@ -1,8 +1,20 @@' >> $testroot/stdout.expected
448 95adcdca 2019-03-27 stsp echo ' 1' >> $testroot/stdout.expected
449 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
450 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
451 95adcdca 2019-03-27 stsp echo ' 22' >> $testroot/stdout.expected
452 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
453 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
454 d136cfcb 2019-10-12 stsp echo '+2' >> $testroot/stdout.expected
455 95adcdca 2019-03-27 stsp echo '+=======' >> $testroot/stdout.expected
456 95adcdca 2019-03-27 stsp echo '+77' >> $testroot/stdout.expected
457 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
458 95adcdca 2019-03-27 stsp echo ' 3' >> $testroot/stdout.expected
459 95adcdca 2019-03-27 stsp echo ' 4' >> $testroot/stdout.expected
460 95adcdca 2019-03-27 stsp echo ' 5' >> $testroot/stdout.expected
461 d136cfcb 2019-10-12 stsp echo ' 6' >> $testroot/stdout.expected
462 d136cfcb 2019-10-12 stsp echo ' 7' >> $testroot/stdout.expected
463 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
464 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
465 d136cfcb 2019-10-12 stsp echo ' 33' >> $testroot/stdout.expected
466 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
467 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
468 d136cfcb 2019-10-12 stsp echo '+8' >> $testroot/stdout.expected
469 d136cfcb 2019-10-12 stsp echo '+=======' >> $testroot/stdout.expected
470 d136cfcb 2019-10-12 stsp echo '+88' >> $testroot/stdout.expected
471 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
472 95adcdca 2019-03-27 stsp
473 95adcdca 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
474 95adcdca 2019-03-27 stsp
475 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
476 49c543a6 2022-03-31 naddy ret=$?
477 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
478 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
479 95adcdca 2019-03-27 stsp fi
480 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
481 95adcdca 2019-03-27 stsp }
482 95adcdca 2019-03-27 stsp
483 f6cae3ed 2020-09-13 naddy test_diff_tag() {
484 d24820bf 2019-08-11 stsp local testroot=`test_init diff_tag`
485 d24820bf 2019-08-11 stsp local commit_id0=`git_show_head $testroot/repo`
486 d24820bf 2019-08-11 stsp local tag1=1.0.0
487 d24820bf 2019-08-11 stsp local tag2=2.0.0
488 d24820bf 2019-08-11 stsp
489 d24820bf 2019-08-11 stsp echo "modified alpha" > $testroot/repo/alpha
490 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "changed alpha"
491 d24820bf 2019-08-11 stsp local commit_id1=`git_show_head $testroot/repo`
492 d24820bf 2019-08-11 stsp
493 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag1)
494 d24820bf 2019-08-11 stsp
495 d24820bf 2019-08-11 stsp echo "new file" > $testroot/repo/new
496 d24820bf 2019-08-11 stsp (cd $testroot/repo && git add new)
497 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "new file"
498 d24820bf 2019-08-11 stsp local commit_id2=`git_show_head $testroot/repo`
499 d24820bf 2019-08-11 stsp
500 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag2)
501 562580bc 2020-01-14 stsp
502 562580bc 2020-01-14 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
503 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
504 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
505 562580bc 2020-01-14 stsp echo -n 'blob - ' >> $testroot/stdout.expected
506 562580bc 2020-01-14 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
507 562580bc 2020-01-14 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
508 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
509 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
510 562580bc 2020-01-14 stsp >> $testroot/stdout.expected
511 562580bc 2020-01-14 stsp echo '--- alpha' >> $testroot/stdout.expected
512 562580bc 2020-01-14 stsp echo '+++ alpha' >> $testroot/stdout.expected
513 562580bc 2020-01-14 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
514 562580bc 2020-01-14 stsp echo '-alpha' >> $testroot/stdout.expected
515 562580bc 2020-01-14 stsp echo '+modified alpha' >> $testroot/stdout.expected
516 562580bc 2020-01-14 stsp
517 562580bc 2020-01-14 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
518 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
519 49c543a6 2022-03-31 naddy ret=$?
520 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
521 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
522 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
523 562580bc 2020-01-14 stsp return 1
524 562580bc 2020-01-14 stsp fi
525 562580bc 2020-01-14 stsp
526 562580bc 2020-01-14 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
527 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
528 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
529 562580bc 2020-01-14 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
530 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
531 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
532 562580bc 2020-01-14 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
533 562580bc 2020-01-14 stsp echo " (mode 644)" >> $testroot/stdout.expected
534 562580bc 2020-01-14 stsp echo '--- /dev/null' >> $testroot/stdout.expected
535 562580bc 2020-01-14 stsp echo '+++ new' >> $testroot/stdout.expected
536 562580bc 2020-01-14 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
537 562580bc 2020-01-14 stsp echo '+new file' >> $testroot/stdout.expected
538 d24820bf 2019-08-11 stsp
539 562580bc 2020-01-14 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
540 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
541 49c543a6 2022-03-31 naddy ret=$?
542 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
543 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
544 562580bc 2020-01-14 stsp fi
545 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
546 562580bc 2020-01-14 stsp }
547 562580bc 2020-01-14 stsp
548 f6cae3ed 2020-09-13 naddy test_diff_lightweight_tag() {
549 562580bc 2020-01-14 stsp local testroot=`test_init diff_tag`
550 562580bc 2020-01-14 stsp local commit_id0=`git_show_head $testroot/repo`
551 562580bc 2020-01-14 stsp local tag1=1.0.0
552 562580bc 2020-01-14 stsp local tag2=2.0.0
553 562580bc 2020-01-14 stsp
554 562580bc 2020-01-14 stsp echo "modified alpha" > $testroot/repo/alpha
555 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "changed alpha"
556 562580bc 2020-01-14 stsp local commit_id1=`git_show_head $testroot/repo`
557 562580bc 2020-01-14 stsp
558 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag1)
559 562580bc 2020-01-14 stsp
560 562580bc 2020-01-14 stsp echo "new file" > $testroot/repo/new
561 562580bc 2020-01-14 stsp (cd $testroot/repo && git add new)
562 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "new file"
563 562580bc 2020-01-14 stsp local commit_id2=`git_show_head $testroot/repo`
564 562580bc 2020-01-14 stsp
565 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag2)
566 562580bc 2020-01-14 stsp
567 d24820bf 2019-08-11 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
568 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
569 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
570 d24820bf 2019-08-11 stsp echo -n 'blob - ' >> $testroot/stdout.expected
571 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
572 d24820bf 2019-08-11 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
573 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
574 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
575 d24820bf 2019-08-11 stsp >> $testroot/stdout.expected
576 d24820bf 2019-08-11 stsp echo '--- alpha' >> $testroot/stdout.expected
577 d24820bf 2019-08-11 stsp echo '+++ alpha' >> $testroot/stdout.expected
578 d24820bf 2019-08-11 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
579 d24820bf 2019-08-11 stsp echo '-alpha' >> $testroot/stdout.expected
580 d24820bf 2019-08-11 stsp echo '+modified alpha' >> $testroot/stdout.expected
581 d24820bf 2019-08-11 stsp
582 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
583 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
584 49c543a6 2022-03-31 naddy ret=$?
585 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
586 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
587 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
588 d24820bf 2019-08-11 stsp return 1
589 d24820bf 2019-08-11 stsp fi
590 d24820bf 2019-08-11 stsp
591 d24820bf 2019-08-11 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
592 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
593 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
594 d24820bf 2019-08-11 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
595 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
596 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
597 46f68b20 2019-10-19 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
598 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
599 d24820bf 2019-08-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
600 d24820bf 2019-08-11 stsp echo '+++ new' >> $testroot/stdout.expected
601 d24820bf 2019-08-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
602 d24820bf 2019-08-11 stsp echo '+new file' >> $testroot/stdout.expected
603 d24820bf 2019-08-11 stsp
604 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
605 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
606 49c543a6 2022-03-31 naddy ret=$?
607 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
608 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
609 d24820bf 2019-08-11 stsp fi
610 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
611 d24820bf 2019-08-11 stsp }
612 d24820bf 2019-08-11 stsp
613 f6cae3ed 2020-09-13 naddy test_diff_ignore_whitespace() {
614 63035f9f 2019-10-06 stsp local testroot=`test_init diff_ignore_whitespace`
615 63035f9f 2019-10-06 stsp local commit_id0=`git_show_head $testroot/repo`
616 63035f9f 2019-10-06 stsp
617 63035f9f 2019-10-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
618 49c543a6 2022-03-31 naddy ret=$?
619 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
620 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
621 63035f9f 2019-10-06 stsp return 1
622 63035f9f 2019-10-06 stsp fi
623 63035f9f 2019-10-06 stsp
624 63035f9f 2019-10-06 stsp echo "alpha " > $testroot/wt/alpha
625 63035f9f 2019-10-06 stsp
626 63035f9f 2019-10-06 stsp (cd $testroot/wt && got diff -w > $testroot/stdout)
627 63035f9f 2019-10-06 stsp
628 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
629 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
630 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
631 63035f9f 2019-10-06 stsp echo -n 'blob - ' >> $testroot/stdout.expected
632 63035f9f 2019-10-06 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
633 63035f9f 2019-10-06 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
634 63035f9f 2019-10-06 stsp echo 'file + alpha' >> $testroot/stdout.expected
635 63035f9f 2019-10-06 stsp
636 63035f9f 2019-10-06 stsp cmp -s $testroot/stdout.expected $testroot/stdout
637 49c543a6 2022-03-31 naddy ret=$?
638 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
639 63035f9f 2019-10-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
640 e7303626 2020-05-14 stsp fi
641 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
642 e7303626 2020-05-14 stsp }
643 e7303626 2020-05-14 stsp
644 f6cae3ed 2020-09-13 naddy test_diff_submodule_of_same_repo() {
645 e7303626 2020-05-14 stsp local testroot=`test_init diff_submodule_of_same_repo`
646 e7303626 2020-05-14 stsp
647 e7303626 2020-05-14 stsp (cd $testroot && git clone -q repo repo2 >/dev/null)
648 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
649 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
650 e7303626 2020-05-14 stsp
651 e7303626 2020-05-14 stsp epsilon_id=$(got tree -r $testroot/repo -i | grep 'epsilon/$' | \
652 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
653 e7303626 2020-05-14 stsp submodule_id=$(got tree -r $testroot/repo -i | grep 'repo2\$$' | \
654 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
655 e7303626 2020-05-14 stsp
656 e7303626 2020-05-14 stsp # Attempt a (nonsensical) diff between a tree object and a submodule.
657 e7303626 2020-05-14 stsp # Currently fails with "wrong type of object" error
658 e7303626 2020-05-14 stsp got diff -r $testroot/repo $epsilon_id $submodule_id \
659 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
660 49c543a6 2022-03-31 naddy ret=$?
661 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
662 e7303626 2020-05-14 stsp echo "diff command succeeded unexpectedly" >&2
663 e7303626 2020-05-14 stsp test_done "$testroot" "1"
664 e7303626 2020-05-14 stsp return 1
665 63035f9f 2019-10-06 stsp fi
666 e7303626 2020-05-14 stsp echo "got: wrong type of object" > $testroot/stderr.expected
667 e7303626 2020-05-14 stsp
668 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
669 49c543a6 2022-03-31 naddy ret=$?
670 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
671 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
672 e7303626 2020-05-14 stsp return 1
673 e7303626 2020-05-14 stsp fi
674 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
675 63035f9f 2019-10-06 stsp }
676 39449a05 2020-07-23 stsp
677 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_work_tree() {
678 39449a05 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_work_tree`
679 39449a05 2020-07-23 stsp
680 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
681 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
682 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
683 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
684 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
685 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
686 39449a05 2020-07-23 stsp (cd $testroot/repo && git add .)
687 39449a05 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
688 39449a05 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
689 39449a05 2020-07-23 stsp
690 39449a05 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
691 49c543a6 2022-03-31 naddy ret=$?
692 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
693 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
694 39449a05 2020-07-23 stsp return 1
695 39449a05 2020-07-23 stsp fi
696 39449a05 2020-07-23 stsp
697 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
698 4135d7d0 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
699 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
700 39449a05 2020-07-23 stsp echo -n '.got/bar' > $testroot/wt/dotgotfoo.link
701 39449a05 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
702 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf epsilon/zeta zeta.link)
703 39449a05 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
704 39449a05 2020-07-23 stsp (cd $testroot/wt && got diff > $testroot/stdout)
705 63035f9f 2019-10-06 stsp
706 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
707 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
708 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
709 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
710 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
711 39449a05 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
712 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
713 39449a05 2020-07-23 stsp echo 'file + alpha.link' >> $testroot/stdout.expected
714 39449a05 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
715 39449a05 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
716 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
717 39449a05 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
718 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
719 39449a05 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
720 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
721 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
722 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
723 39449a05 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
724 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
725 39449a05 2020-07-23 stsp echo 'file + dotgotfoo.link' >> $testroot/stdout.expected
726 39449a05 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
727 39449a05 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
728 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
729 39449a05 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
730 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
731 39449a05 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
732 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
733 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
734 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
735 39449a05 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
736 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
737 39449a05 2020-07-23 stsp echo 'file + epsilon/beta.link' >> $testroot/stdout.expected
738 39449a05 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
739 39449a05 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
740 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
741 39449a05 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
742 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
743 39449a05 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
744 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
745 4135d7d0 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
746 4135d7d0 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
747 4135d7d0 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
748 4135d7d0 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
749 4135d7d0 2020-07-23 stsp echo 'file + epsilon.link' >> $testroot/stdout.expected
750 4135d7d0 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
751 4135d7d0 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
752 4135d7d0 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
753 4135d7d0 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
754 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
755 4135d7d0 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
756 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
757 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
758 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
759 39449a05 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
760 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
761 39449a05 2020-07-23 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
762 39449a05 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
763 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
764 39449a05 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
765 39449a05 2020-07-23 stsp echo '-nonexistent' >> $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 'blob - /dev/null' >> $testroot/stdout.expected
768 39449a05 2020-07-23 stsp echo 'file + zeta.link' >> $testroot/stdout.expected
769 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
770 40dde666 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
771 40dde666 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
772 40dde666 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
773 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
774 40dde666 2020-07-23 stsp
775 40dde666 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
776 49c543a6 2022-03-31 naddy ret=$?
777 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
778 40dde666 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
779 40dde666 2020-07-23 stsp fi
780 40dde666 2020-07-23 stsp test_done "$testroot" "$ret"
781 40dde666 2020-07-23 stsp }
782 40dde666 2020-07-23 stsp
783 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_repo() {
784 40dde666 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_repo`
785 40dde666 2020-07-23 stsp
786 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
787 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
788 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
789 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
790 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
791 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
792 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
793 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
794 40dde666 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
795 40dde666 2020-07-23 stsp
796 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
797 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sfh gamma epsilon.link)
798 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
799 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar $testroot/repo/dotgotfoo.link)
800 40dde666 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
801 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
802 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
803 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
804 40dde666 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
805 40dde666 2020-07-23 stsp
806 40dde666 2020-07-23 stsp got diff -r $testroot/repo $commit_id1 $commit_id2 > $testroot/stdout
807 40dde666 2020-07-23 stsp
808 40dde666 2020-07-23 stsp echo "diff $commit_id1 $commit_id2" > $testroot/stdout.expected
809 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
810 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
811 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
812 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
813 40dde666 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
814 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
815 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
816 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
817 40dde666 2020-07-23 stsp grep 'alpha.link@ -> beta$' | \
818 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
819 40dde666 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
820 40dde666 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
821 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
822 40dde666 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
823 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
824 40dde666 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
825 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
826 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
827 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
828 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
829 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
830 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
831 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
832 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/bar$' | \
833 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
834 40dde666 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
835 40dde666 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
836 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
837 40dde666 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
838 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
839 40dde666 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
840 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
841 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
842 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
843 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
844 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $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_id2 -i epsilon | \
847 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../gamma/delta$' | \
848 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
849 40dde666 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
850 40dde666 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
851 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
852 40dde666 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
853 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
854 40dde666 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
855 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
856 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
857 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
858 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
859 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $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_id2 -i | \
862 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> gamma$' | \
863 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
864 40dde666 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
865 40dde666 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
866 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
867 40dde666 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
868 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
869 40dde666 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
870 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
871 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
872 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
873 40dde666 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
874 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
875 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
876 40dde666 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
877 40dde666 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
878 40dde666 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
879 40dde666 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
880 40dde666 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
881 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
882 40dde666 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
883 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
884 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
885 40dde666 2020-07-23 stsp grep 'zeta.link@ -> epsilon/zeta$' | \
886 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
887 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
888 40dde666 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
889 39449a05 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
890 39449a05 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
891 39449a05 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
892 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
893 39449a05 2020-07-23 stsp
894 39449a05 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
895 49c543a6 2022-03-31 naddy ret=$?
896 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
897 39449a05 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
898 dffd0deb 2020-11-20 stsp fi
899 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
900 dffd0deb 2020-11-20 stsp }
901 dffd0deb 2020-11-20 stsp
902 dffd0deb 2020-11-20 stsp test_diff_binary_files() {
903 dffd0deb 2020-11-20 stsp local testroot=`test_init diff_binary_files`
904 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
905 dffd0deb 2020-11-20 stsp
906 dffd0deb 2020-11-20 stsp got checkout $testroot/repo $testroot/wt > /dev/null
907 49c543a6 2022-03-31 naddy ret=$?
908 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
909 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
910 dffd0deb 2020-11-20 stsp return 1
911 dffd0deb 2020-11-20 stsp fi
912 dffd0deb 2020-11-20 stsp
913 dffd0deb 2020-11-20 stsp printf '\377\377\0\0\377\377\0\0' > $testroot/wt/foo
914 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got add foo >/dev/null)
915 64453f7e 2020-11-21 stsp
916 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
917 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
918 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
919 64453f7e 2020-11-21 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
920 64453f7e 2020-11-21 stsp echo 'file + foo' >> $testroot/stdout.expected
921 1cb46f00 2020-11-21 stsp echo "Binary files /dev/null and foo differ" \
922 1cb46f00 2020-11-21 stsp >> $testroot/stdout.expected
923 64453f7e 2020-11-21 stsp
924 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff > $testroot/stdout)
925 64453f7e 2020-11-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
926 49c543a6 2022-03-31 naddy ret=$?
927 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
928 64453f7e 2020-11-21 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
929 64453f7e 2020-11-21 stsp test_done "$testroot" "$ret"
930 64453f7e 2020-11-21 stsp return 1
931 64453f7e 2020-11-21 stsp fi
932 dffd0deb 2020-11-20 stsp
933 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
934 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
935 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
936 dffd0deb 2020-11-20 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
937 dffd0deb 2020-11-20 stsp echo 'file + foo' >> $testroot/stdout.expected
938 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
939 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
940 dffd0deb 2020-11-20 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
941 dffd0deb 2020-11-20 stsp printf '+\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
942 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
943 dffd0deb 2020-11-20 stsp
944 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
945 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
946 49c543a6 2022-03-31 naddy ret=$?
947 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
948 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
949 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
950 dffd0deb 2020-11-20 stsp return 1
951 39449a05 2020-07-23 stsp fi
952 dffd0deb 2020-11-20 stsp
953 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
954 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
955 dffd0deb 2020-11-20 stsp
956 dffd0deb 2020-11-20 stsp printf '\377\200\0\0\377\200\0\0' > $testroot/wt/foo
957 dffd0deb 2020-11-20 stsp
958 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
959 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
960 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
961 dffd0deb 2020-11-20 stsp echo -n 'blob - ' >> $testroot/stdout.expected
962 dffd0deb 2020-11-20 stsp got tree -r $testroot/repo -i | grep 'foo$' | cut -d' ' -f 1 \
963 dffd0deb 2020-11-20 stsp >> $testroot/stdout.expected
964 dffd0deb 2020-11-20 stsp echo 'file + foo' >> $testroot/stdout.expected
965 dffd0deb 2020-11-20 stsp echo '--- foo' >> $testroot/stdout.expected
966 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
967 dffd0deb 2020-11-20 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
968 578133c9 2020-11-28 naddy printf -- '-\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
969 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
970 dffd0deb 2020-11-20 stsp printf '+\377\200\0\0\377\200\0\0\n' >> $testroot/stdout.expected
971 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
972 dffd0deb 2020-11-20 stsp
973 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
974 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
975 49c543a6 2022-03-31 naddy ret=$?
976 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
977 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
978 67b631c9 2021-10-10 stsp fi
979 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
980 67b631c9 2021-10-10 stsp }
981 67b631c9 2021-10-10 stsp
982 67b631c9 2021-10-10 stsp test_diff_commits() {
983 67b631c9 2021-10-10 stsp local testroot=`test_init diff_commits`
984 67b631c9 2021-10-10 stsp local commit_id0=`git_show_head $testroot/repo`
985 67b631c9 2021-10-10 stsp alpha_id0=`get_blob_id $testroot/repo "" alpha`
986 67b631c9 2021-10-10 stsp beta_id0=`get_blob_id $testroot/repo "" beta`
987 67b631c9 2021-10-10 stsp
988 67b631c9 2021-10-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
989 49c543a6 2022-03-31 naddy ret=$?
990 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
991 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
992 67b631c9 2021-10-10 stsp return 1
993 67b631c9 2021-10-10 stsp fi
994 67b631c9 2021-10-10 stsp
995 67b631c9 2021-10-10 stsp echo "modified alpha" > $testroot/wt/alpha
996 67b631c9 2021-10-10 stsp (cd $testroot/wt && got rm beta >/dev/null)
997 67b631c9 2021-10-10 stsp echo "new file" > $testroot/wt/new
998 67b631c9 2021-10-10 stsp (cd $testroot/wt && got add new >/dev/null)
999 67b631c9 2021-10-10 stsp (cd $testroot/wt && got commit -m 'committing changes' >/dev/null)
1000 67b631c9 2021-10-10 stsp local commit_id1=`git_show_head $testroot/repo`
1001 67b631c9 2021-10-10 stsp
1002 67b631c9 2021-10-10 stsp alpha_id1=`get_blob_id $testroot/repo "" alpha`
1003 67b631c9 2021-10-10 stsp new_id1=`get_blob_id $testroot/repo "" new`
1004 67b631c9 2021-10-10 stsp
1005 67b631c9 2021-10-10 stsp echo "diff $commit_id0 refs/heads/master" > $testroot/stdout.expected
1006 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1007 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1008 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1009 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1010 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1011 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1012 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1013 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1014 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1015 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1016 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1017 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1018 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1019 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1020 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1021 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1022 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1023 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1024 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1025 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1026 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1027 67b631c9 2021-10-10 stsp
1028 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c master > $testroot/stdout)
1029 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1030 49c543a6 2022-03-31 naddy ret=$?
1031 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1032 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1033 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1034 67b631c9 2021-10-10 stsp return 1
1035 67b631c9 2021-10-10 stsp fi
1036 67b631c9 2021-10-10 stsp
1037 67b631c9 2021-10-10 stsp # same diff with explicit parent commit ID
1038 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c master \
1039 67b631c9 2021-10-10 stsp > $testroot/stdout)
1040 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1041 49c543a6 2022-03-31 naddy ret=$?
1042 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1043 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1044 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1045 67b631c9 2021-10-10 stsp return 1
1046 67b631c9 2021-10-10 stsp fi
1047 67b631c9 2021-10-10 stsp
1048 67b631c9 2021-10-10 stsp # same diff with commit object IDs
1049 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1050 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1051 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1052 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1053 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1054 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1055 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1056 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1057 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1058 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1059 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1060 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1061 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1062 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1063 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1064 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1065 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1066 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1067 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1068 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1069 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1070 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1071 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 \
1072 67b631c9 2021-10-10 stsp > $testroot/stdout)
1073 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1074 49c543a6 2022-03-31 naddy ret=$?
1075 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1076 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1077 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1078 67b631c9 2021-10-10 stsp return 1
1079 67b631c9 2021-10-10 stsp fi
1080 67b631c9 2021-10-10 stsp
1081 67b631c9 2021-10-10 stsp # same diff, filtered by paths
1082 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1083 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1084 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1085 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1086 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1087 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1088 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1089 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1090 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1091 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1092 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 alpha \
1093 67b631c9 2021-10-10 stsp > $testroot/stdout)
1094 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1095 49c543a6 2022-03-31 naddy ret=$?
1096 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1097 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1098 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1099 67b631c9 2021-10-10 stsp return 1
1100 67b631c9 2021-10-10 stsp fi
1101 67b631c9 2021-10-10 stsp # same in a work tree
1102 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 alpha \
1103 67b631c9 2021-10-10 stsp > $testroot/stdout)
1104 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1105 49c543a6 2022-03-31 naddy ret=$?
1106 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1107 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1108 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1109 67b631c9 2021-10-10 stsp return 1
1110 dffd0deb 2020-11-20 stsp fi
1111 67b631c9 2021-10-10 stsp
1112 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1113 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1114 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1115 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1116 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1117 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1118 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1119 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1120 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1121 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1122 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1123 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1124 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1125 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1126 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1127 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 \
1128 67b631c9 2021-10-10 stsp beta new > $testroot/stdout)
1129 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1130 49c543a6 2022-03-31 naddy ret=$?
1131 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1132 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1133 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1134 67b631c9 2021-10-10 stsp return 1
1135 67b631c9 2021-10-10 stsp fi
1136 67b631c9 2021-10-10 stsp
1137 67b631c9 2021-10-10 stsp # more than two -c options are not allowed
1138 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 -c foo \
1139 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1140 49c543a6 2022-03-31 naddy ret=$?
1141 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1142 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1143 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1144 67b631c9 2021-10-10 stsp return 1
1145 67b631c9 2021-10-10 stsp fi
1146 67b631c9 2021-10-10 stsp echo "got: too many -c options used" > $testroot/stderr.expected
1147 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1148 49c543a6 2022-03-31 naddy ret=$?
1149 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1150 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1151 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1152 67b631c9 2021-10-10 stsp return 1
1153 67b631c9 2021-10-10 stsp fi
1154 67b631c9 2021-10-10 stsp
1155 67b631c9 2021-10-10 stsp # use of -c options implies a repository diff; use with -P is an error
1156 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -P foo \
1157 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1158 49c543a6 2022-03-31 naddy ret=$?
1159 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1160 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1161 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1162 67b631c9 2021-10-10 stsp return 1
1163 67b631c9 2021-10-10 stsp fi
1164 67b631c9 2021-10-10 stsp echo "got: -P option can only be used when diffing a work tree" \
1165 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1166 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1167 49c543a6 2022-03-31 naddy ret=$?
1168 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1169 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1170 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1171 67b631c9 2021-10-10 stsp return 1
1172 67b631c9 2021-10-10 stsp fi
1173 67b631c9 2021-10-10 stsp
1174 67b631c9 2021-10-10 stsp # use of -c options implies a repository diff; use with -s is an error
1175 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -s foo \
1176 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1177 49c543a6 2022-03-31 naddy ret=$?
1178 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1179 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1180 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1181 67b631c9 2021-10-10 stsp return 1
1182 67b631c9 2021-10-10 stsp fi
1183 67b631c9 2021-10-10 stsp echo "got: -s option can only be used when diffing a work tree" \
1184 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1185 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1186 49c543a6 2022-03-31 naddy ret=$?
1187 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1188 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1189 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1190 67b631c9 2021-10-10 stsp return 1
1191 67b631c9 2021-10-10 stsp fi
1192 67b631c9 2021-10-10 stsp
1193 67b631c9 2021-10-10 stsp # three arguments imply use of path filtering (repository case)
1194 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff $commit_id0 $commit_id1 foo \
1195 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1196 49c543a6 2022-03-31 naddy ret=$?
1197 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1198 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1199 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1200 67b631c9 2021-10-10 stsp return 1
1201 67b631c9 2021-10-10 stsp fi
1202 67b631c9 2021-10-10 stsp echo "got: specified paths cannot be resolved: no got work tree found" \
1203 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1204 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1205 49c543a6 2022-03-31 naddy ret=$?
1206 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1207 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1208 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1209 67b631c9 2021-10-10 stsp return 1
1210 67b631c9 2021-10-10 stsp fi
1211 67b631c9 2021-10-10 stsp
1212 67b631c9 2021-10-10 stsp # three arguments imply use of path filtering (work tree case)
1213 10a623df 2021-10-11 stsp (cd $testroot/wt && got diff $commit_id0 master foo \
1214 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1215 49c543a6 2022-03-31 naddy ret=$?
1216 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1217 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1218 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1219 67b631c9 2021-10-10 stsp return 1
1220 67b631c9 2021-10-10 stsp fi
1221 67b631c9 2021-10-10 stsp echo "got: $commit_id0: No such file or directory" \
1222 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1223 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1224 49c543a6 2022-03-31 naddy ret=$?
1225 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1226 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1227 67b631c9 2021-10-10 stsp fi
1228 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
1229 39449a05 2020-07-23 stsp }
1230 39449a05 2020-07-23 stsp
1231 32b5305f 2022-02-12 op test_diff_ignored_file() {
1232 32b5305f 2022-02-12 op local testroot=`test_init diff_ignored_file`
1233 32b5305f 2022-02-12 op
1234 32b5305f 2022-02-12 op got checkout $testroot/repo $testroot/wt > /dev/null
1235 32b5305f 2022-02-12 op ret=$?
1236 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1237 32b5305f 2022-02-12 op test_done "$testroot" "$ret"
1238 32b5305f 2022-02-12 op return 1
1239 32b5305f 2022-02-12 op fi
1240 32b5305f 2022-02-12 op
1241 32b5305f 2022-02-12 op echo 1 > $testroot/wt/number
1242 32b5305f 2022-02-12 op (cd $testroot/wt && got add number >/dev/null)
1243 32b5305f 2022-02-12 op (cd $testroot/wt && got commit -m 'add number' >/dev/null)
1244 32b5305f 2022-02-12 op
1245 32b5305f 2022-02-12 op echo "**/number" > $testroot/wt/.gitignore
1246 32b5305f 2022-02-12 op
1247 32b5305f 2022-02-12 op echo 2 > $testroot/wt/number
1248 32b5305f 2022-02-12 op (cd $testroot/wt && got diff number | sed '1,/^@@/d' > $testroot/stdout)
1249 32b5305f 2022-02-12 op
1250 32b5305f 2022-02-12 op echo "-1" > $testroot/stdout.expected
1251 32b5305f 2022-02-12 op echo "+2" >> $testroot/stdout.expected
1252 32b5305f 2022-02-12 op
1253 32b5305f 2022-02-12 op cmp -s $testroot/stdout.expected $testroot/stdout
1254 32b5305f 2022-02-12 op ret=$?
1255 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1256 32b5305f 2022-02-12 op diff -u $testroot/stdout.expected $testroot/stdout
1257 32b5305f 2022-02-12 op fi
1258 32b5305f 2022-02-12 op test_done "$testroot" "$ret"
1259 32b5305f 2022-02-12 op }
1260 32b5305f 2022-02-12 op
1261 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1262 95adcdca 2019-03-27 stsp run_test test_diff_basic
1263 95adcdca 2019-03-27 stsp run_test test_diff_shows_conflict
1264 d24820bf 2019-08-11 stsp run_test test_diff_tag
1265 562580bc 2020-01-14 stsp run_test test_diff_lightweight_tag
1266 63035f9f 2019-10-06 stsp run_test test_diff_ignore_whitespace
1267 e7303626 2020-05-14 stsp run_test test_diff_submodule_of_same_repo
1268 39449a05 2020-07-23 stsp run_test test_diff_symlinks_in_work_tree
1269 40dde666 2020-07-23 stsp run_test test_diff_symlinks_in_repo
1270 dffd0deb 2020-11-20 stsp run_test test_diff_binary_files
1271 67b631c9 2021-10-10 stsp run_test test_diff_commits
1272 32b5305f 2022-02-12 op run_test test_diff_ignored_file