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