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 95adcdca 2019-03-27 stsp ret="$?"
25 95adcdca 2019-03-27 stsp if [ "$ret" != "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 95adcdca 2019-03-27 stsp ret="$?"
63 95adcdca 2019-03-27 stsp if [ "$ret" != "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 30f6c0c6 2021-10-08 thomas # 'got diff' in a repository without any arguments is an error
70 30f6c0c6 2021-10-08 thomas (cd $testroot/repo && got diff 2> $testroot/stderr)
71 30f6c0c6 2021-10-08 thomas echo "got: no got work tree found" > $testroot/stderr.expected
72 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stderr.expected $testroot/stderr
73 30f6c0c6 2021-10-08 thomas ret="$?"
74 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
75 30f6c0c6 2021-10-08 thomas diff -u $testroot/stderr.expected $testroot/stderr
76 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
77 30f6c0c6 2021-10-08 thomas return 1
78 30f6c0c6 2021-10-08 thomas fi
79 30f6c0c6 2021-10-08 thomas
80 30f6c0c6 2021-10-08 thomas # 'got diff' in a repository with two arguments requires that
81 30f6c0c6 2021-10-08 thomas # both named objects exist
82 30f6c0c6 2021-10-08 thomas (cd $testroot/repo && got diff $head_rev foo 2> $testroot/stderr)
83 30f6c0c6 2021-10-08 thomas echo "got: foo: object not found" > $testroot/stderr.expected
84 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stderr.expected $testroot/stderr
85 30f6c0c6 2021-10-08 thomas ret="$?"
86 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
87 30f6c0c6 2021-10-08 thomas diff -u $testroot/stderr.expected $testroot/stderr
88 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
89 30f6c0c6 2021-10-08 thomas return 1
90 30f6c0c6 2021-10-08 thomas fi
91 30f6c0c6 2021-10-08 thomas
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 2a06fe5f 2019-08-24 stsp ret="$?"
99 2a06fe5f 2019-08-24 stsp if [ "$ret" != "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 30f6c0c6 2021-10-08 thomas > $testroot/stderr.expected
107 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stderr.expected $testroot/stderr
108 30f6c0c6 2021-10-08 thomas ret="$?"
109 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
110 30f6c0c6 2021-10-08 thomas diff -u $testroot/stderr.expected $testroot/stderr
111 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
112 30f6c0c6 2021-10-08 thomas return 1
113 30f6c0c6 2021-10-08 thomas fi
114 30f6c0c6 2021-10-08 thomas
115 30f6c0c6 2021-10-08 thomas echo "modified zeta" > $testroot/wt/epsilon/zeta
116 30f6c0c6 2021-10-08 thomas
117 30f6c0c6 2021-10-08 thomas # diff several paths in a work tree
118 30f6c0c6 2021-10-08 thomas echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
119 30f6c0c6 2021-10-08 thomas echo -n 'blob - ' >> $testroot/stdout.expected
120 30f6c0c6 2021-10-08 thomas got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
121 30f6c0c6 2021-10-08 thomas >> $testroot/stdout.expected
122 30f6c0c6 2021-10-08 thomas echo 'file + alpha' >> $testroot/stdout.expected
123 30f6c0c6 2021-10-08 thomas echo '--- alpha' >> $testroot/stdout.expected
124 30f6c0c6 2021-10-08 thomas echo '+++ alpha' >> $testroot/stdout.expected
125 30f6c0c6 2021-10-08 thomas echo '@@ -1 +1 @@' >> $testroot/stdout.expected
126 30f6c0c6 2021-10-08 thomas echo '-alpha' >> $testroot/stdout.expected
127 30f6c0c6 2021-10-08 thomas echo '+modified alpha' >> $testroot/stdout.expected
128 30f6c0c6 2021-10-08 thomas echo -n 'blob - ' >> $testroot/stdout.expected
129 f1417e9f 2021-10-12 thomas got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
130 f1417e9f 2021-10-12 thomas >> $testroot/stdout.expected
131 f1417e9f 2021-10-12 thomas echo 'file + /dev/null' >> $testroot/stdout.expected
132 f1417e9f 2021-10-12 thomas echo '--- beta' >> $testroot/stdout.expected
133 f1417e9f 2021-10-12 thomas echo '+++ /dev/null' >> $testroot/stdout.expected
134 f1417e9f 2021-10-12 thomas echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
135 f1417e9f 2021-10-12 thomas echo '-beta' >> $testroot/stdout.expected
136 f1417e9f 2021-10-12 thomas echo -n 'blob - ' >> $testroot/stdout.expected
137 30f6c0c6 2021-10-08 thomas got tree -r $testroot/repo -i epsilon | grep 'zeta$' | cut -d' ' -f 1 \
138 30f6c0c6 2021-10-08 thomas >> $testroot/stdout.expected
139 30f6c0c6 2021-10-08 thomas echo 'file + epsilon/zeta' >> $testroot/stdout.expected
140 30f6c0c6 2021-10-08 thomas echo '--- epsilon/zeta' >> $testroot/stdout.expected
141 30f6c0c6 2021-10-08 thomas echo '+++ epsilon/zeta' >> $testroot/stdout.expected
142 30f6c0c6 2021-10-08 thomas echo '@@ -1 +1 @@' >> $testroot/stdout.expected
143 30f6c0c6 2021-10-08 thomas echo '-zeta' >> $testroot/stdout.expected
144 30f6c0c6 2021-10-08 thomas echo '+modified zeta' >> $testroot/stdout.expected
145 f1417e9f 2021-10-12 thomas echo 'blob - /dev/null' >> $testroot/stdout.expected
146 f1417e9f 2021-10-12 thomas echo 'file + new' >> $testroot/stdout.expected
147 f1417e9f 2021-10-12 thomas echo '--- /dev/null' >> $testroot/stdout.expected
148 f1417e9f 2021-10-12 thomas echo '+++ new' >> $testroot/stdout.expected
149 f1417e9f 2021-10-12 thomas echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
150 f1417e9f 2021-10-12 thomas echo '+new file' >> $testroot/stdout.expected
151 30f6c0c6 2021-10-08 thomas
152 30f6c0c6 2021-10-08 thomas (cd $testroot/wt && got diff new alpha epsilon beta > $testroot/stdout)
153 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
154 30f6c0c6 2021-10-08 thomas ret="$?"
155 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
156 30f6c0c6 2021-10-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
157 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
158 30f6c0c6 2021-10-08 thomas return 1
159 30f6c0c6 2021-10-08 thomas fi
160 30f6c0c6 2021-10-08 thomas
161 f1417e9f 2021-10-12 thomas # different order of arguments results in same output order
162 f1417e9f 2021-10-12 thomas (cd $testroot/wt && got diff alpha new epsilon beta \
163 30f6c0c6 2021-10-08 thomas > $testroot/stdout 2> $testroot/stderr)
164 30f6c0c6 2021-10-08 thomas ret="$?"
165 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
166 30f6c0c6 2021-10-08 thomas echo "diff failed unexpectedly" >&2
167 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
168 30f6c0c6 2021-10-08 thomas return 1
169 30f6c0c6 2021-10-08 thomas fi
170 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
171 30f6c0c6 2021-10-08 thomas ret="$?"
172 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
173 30f6c0c6 2021-10-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
174 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
175 30f6c0c6 2021-10-08 thomas return 1
176 30f6c0c6 2021-10-08 thomas fi
177 30f6c0c6 2021-10-08 thomas
178 f1417e9f 2021-10-12 thomas # a branch 'new' should not collide with path 'new' if more
179 f1417e9f 2021-10-12 thomas # than two arguments are passed
180 f1417e9f 2021-10-12 thomas got br -r $testroot/repo -c master new > /dev/null
181 f1417e9f 2021-10-12 thomas (cd $testroot/wt && got diff new alpha epsilon beta \
182 30f6c0c6 2021-10-08 thomas > $testroot/stdout 2> $testroot/stderr)
183 30f6c0c6 2021-10-08 thomas ret="$?"
184 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
185 30f6c0c6 2021-10-08 thomas echo "diff failed unexpectedly" >&2
186 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
187 30f6c0c6 2021-10-08 thomas return 1
188 30f6c0c6 2021-10-08 thomas fi
189 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
190 30f6c0c6 2021-10-08 thomas ret="$?"
191 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
192 30f6c0c6 2021-10-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
193 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
194 30f6c0c6 2021-10-08 thomas return 1
195 30f6c0c6 2021-10-08 thomas fi
196 30f6c0c6 2021-10-08 thomas
197 30f6c0c6 2021-10-08 thomas # Two arguments are interpreted as objects if a colliding path exists
198 30f6c0c6 2021-10-08 thomas echo master > $testroot/wt/master
199 30f6c0c6 2021-10-08 thomas (cd $testroot/wt && got add master > /dev/null)
200 30f6c0c6 2021-10-08 thomas (cd $testroot/wt && got diff master new > $testroot/stdout)
201 30f6c0c6 2021-10-08 thomas ret="$?"
202 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
203 30f6c0c6 2021-10-08 thomas echo "diff failed unexpectedly" >&2
204 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
205 30f6c0c6 2021-10-08 thomas return 1
206 30f6c0c6 2021-10-08 thomas fi
207 30f6c0c6 2021-10-08 thomas echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
208 30f6c0c6 2021-10-08 thomas # diff between the branches is empty
209 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
210 30f6c0c6 2021-10-08 thomas ret="$?"
211 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
212 30f6c0c6 2021-10-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
213 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
214 30f6c0c6 2021-10-08 thomas return 1
215 30f6c0c6 2021-10-08 thomas fi
216 30f6c0c6 2021-10-08 thomas # same without a work tree
217 30f6c0c6 2021-10-08 thomas (cd $testroot/repo && got diff master new > $testroot/stdout)
218 30f6c0c6 2021-10-08 thomas ret="$?"
219 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
220 30f6c0c6 2021-10-08 thomas echo "diff failed unexpectedly" >&2
221 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
222 30f6c0c6 2021-10-08 thomas return 1
223 30f6c0c6 2021-10-08 thomas fi
224 30f6c0c6 2021-10-08 thomas echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
225 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
226 30f6c0c6 2021-10-08 thomas ret="$?"
227 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
228 30f6c0c6 2021-10-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
229 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
230 30f6c0c6 2021-10-08 thomas return 1
231 30f6c0c6 2021-10-08 thomas fi
232 30f6c0c6 2021-10-08 thomas # same with -r argument
233 30f6c0c6 2021-10-08 thomas got diff -r $testroot/repo master new > $testroot/stdout
234 30f6c0c6 2021-10-08 thomas ret="$?"
235 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
236 30f6c0c6 2021-10-08 thomas echo "diff failed unexpectedly" >&2
237 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
238 30f6c0c6 2021-10-08 thomas return 1
239 30f6c0c6 2021-10-08 thomas fi
240 30f6c0c6 2021-10-08 thomas echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
241 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
242 30f6c0c6 2021-10-08 thomas ret="$?"
243 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
244 30f6c0c6 2021-10-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
245 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
246 30f6c0c6 2021-10-08 thomas return 1
247 30f6c0c6 2021-10-08 thomas fi
248 30f6c0c6 2021-10-08 thomas
249 30f6c0c6 2021-10-08 thomas # -P can be used to force use of paths
250 30f6c0c6 2021-10-08 thomas (cd $testroot/wt && got diff -P new master > $testroot/stdout)
251 30f6c0c6 2021-10-08 thomas ret="$?"
252 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
253 30f6c0c6 2021-10-08 thomas echo "diff failed unexpectedly" >&2
254 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
255 30f6c0c6 2021-10-08 thomas return 1
256 30f6c0c6 2021-10-08 thomas fi
257 30f6c0c6 2021-10-08 thomas echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
258 30f6c0c6 2021-10-08 thomas echo 'blob - /dev/null' >> $testroot/stdout.expected
259 30f6c0c6 2021-10-08 thomas echo 'file + master' >> $testroot/stdout.expected
260 30f6c0c6 2021-10-08 thomas echo '--- /dev/null' >> $testroot/stdout.expected
261 30f6c0c6 2021-10-08 thomas echo '+++ master' >> $testroot/stdout.expected
262 30f6c0c6 2021-10-08 thomas echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
263 30f6c0c6 2021-10-08 thomas echo '+master' >> $testroot/stdout.expected
264 f1417e9f 2021-10-12 thomas echo 'blob - /dev/null' >> $testroot/stdout.expected
265 f1417e9f 2021-10-12 thomas echo 'file + new' >> $testroot/stdout.expected
266 f1417e9f 2021-10-12 thomas echo '--- /dev/null' >> $testroot/stdout.expected
267 f1417e9f 2021-10-12 thomas echo '+++ new' >> $testroot/stdout.expected
268 f1417e9f 2021-10-12 thomas echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
269 f1417e9f 2021-10-12 thomas echo '+new file' >> $testroot/stdout.expected
270 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
271 30f6c0c6 2021-10-08 thomas ret="$?"
272 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
273 30f6c0c6 2021-10-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
274 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
275 30f6c0c6 2021-10-08 thomas return 1
276 30f6c0c6 2021-10-08 thomas fi
277 30f6c0c6 2021-10-08 thomas
278 30f6c0c6 2021-10-08 thomas # -P can only be used in a work tree
279 30f6c0c6 2021-10-08 thomas got diff -r $testroot/repo -P new master 2> $testroot/stderr
280 30f6c0c6 2021-10-08 thomas ret="$?"
281 30f6c0c6 2021-10-08 thomas if [ "$ret" == "0" ]; then
282 30f6c0c6 2021-10-08 thomas echo "diff succeeded unexpectedly" >&2
283 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
284 30f6c0c6 2021-10-08 thomas return 1
285 30f6c0c6 2021-10-08 thomas fi
286 30f6c0c6 2021-10-08 thomas 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 2a06fe5f 2019-08-24 stsp ret="$?"
290 2a06fe5f 2019-08-24 stsp if [ "$ret" != "0" ]; then
291 2a06fe5f 2019-08-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
292 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
293 30f6c0c6 2021-10-08 thomas return 1
294 30f6c0c6 2021-10-08 thomas fi
295 30f6c0c6 2021-10-08 thomas
296 30f6c0c6 2021-10-08 thomas # a single argument which can be resolved to a path is not ambiguous
297 30f6c0c6 2021-10-08 thomas echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
298 30f6c0c6 2021-10-08 thomas echo 'blob - /dev/null' >> $testroot/stdout.expected
299 30f6c0c6 2021-10-08 thomas echo 'file + new' >> $testroot/stdout.expected
300 30f6c0c6 2021-10-08 thomas echo '--- /dev/null' >> $testroot/stdout.expected
301 30f6c0c6 2021-10-08 thomas echo '+++ new' >> $testroot/stdout.expected
302 30f6c0c6 2021-10-08 thomas echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
303 30f6c0c6 2021-10-08 thomas echo '+new file' >> $testroot/stdout.expected
304 30f6c0c6 2021-10-08 thomas (cd $testroot/wt && got diff new > $testroot/stdout)
305 30f6c0c6 2021-10-08 thomas ret="$?"
306 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
307 30f6c0c6 2021-10-08 thomas echo "diff failed unexpectedly" >&2
308 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
309 30f6c0c6 2021-10-08 thomas return 1
310 30f6c0c6 2021-10-08 thomas fi
311 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
312 30f6c0c6 2021-10-08 thomas ret="$?"
313 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
314 30f6c0c6 2021-10-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
315 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
316 30f6c0c6 2021-10-08 thomas return 1
317 30f6c0c6 2021-10-08 thomas fi
318 30f6c0c6 2021-10-08 thomas
319 30f6c0c6 2021-10-08 thomas # diff with just one object ID argument results in
320 30f6c0c6 2021-10-08 thomas # interpretation of argument as a path
321 30f6c0c6 2021-10-08 thomas (cd $testroot/wt && got diff $head_rev 2> $testroot/stderr)
322 30f6c0c6 2021-10-08 thomas ret="$?"
323 30f6c0c6 2021-10-08 thomas if [ "$ret" = "0" ]; then
324 30f6c0c6 2021-10-08 thomas echo "diff succeeded unexpectedly" >&2
325 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
326 30f6c0c6 2021-10-08 thomas return 1
327 30f6c0c6 2021-10-08 thomas fi
328 30f6c0c6 2021-10-08 thomas echo "got: $head_rev: No such file or directory" \
329 30f6c0c6 2021-10-08 thomas > $testroot/stderr.expected
330 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stderr.expected $testroot/stderr
331 30f6c0c6 2021-10-08 thomas ret="$?"
332 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
333 30f6c0c6 2021-10-08 thomas diff -u $testroot/stderr.expected $testroot/stderr
334 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
335 30f6c0c6 2021-10-08 thomas return 1
336 30f6c0c6 2021-10-08 thomas fi
337 30f6c0c6 2021-10-08 thomas
338 30f6c0c6 2021-10-08 thomas # diff with more than two object arguments results in
339 30f6c0c6 2021-10-08 thomas # interpretation of arguments as paths
340 30f6c0c6 2021-10-08 thomas (cd $testroot/wt && got diff new $head_rev master \
341 30f6c0c6 2021-10-08 thomas > $testroot/stout 2> $testroot/stderr)
342 30f6c0c6 2021-10-08 thomas ret="$?"
343 30f6c0c6 2021-10-08 thomas if [ "$ret" = "0" ]; then
344 30f6c0c6 2021-10-08 thomas echo "diff succeeded unexpectedly" >&2
345 30f6c0c6 2021-10-08 thomas test_done "$testroot" "1"
346 30f6c0c6 2021-10-08 thomas return 1
347 30f6c0c6 2021-10-08 thomas fi
348 30f6c0c6 2021-10-08 thomas
349 30f6c0c6 2021-10-08 thomas echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
350 30f6c0c6 2021-10-08 thomas echo 'blob - /dev/null' >> $testroot/stdout.expected
351 30f6c0c6 2021-10-08 thomas echo 'file + new' >> $testroot/stdout.expected
352 30f6c0c6 2021-10-08 thomas echo '--- /dev/null' >> $testroot/stdout.expected
353 30f6c0c6 2021-10-08 thomas echo '+++ new' >> $testroot/stdout.expected
354 30f6c0c6 2021-10-08 thomas echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
355 30f6c0c6 2021-10-08 thomas echo '+new file' >> $testroot/stdout.expected
356 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stdout.expected $testroot/stdout
357 30f6c0c6 2021-10-08 thomas ret="$?"
358 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
359 30f6c0c6 2021-10-08 thomas diff -u $testroot/stdout.expected $testroot/stdout
360 30f6c0c6 2021-10-08 thomas test_done "$testroot" "$ret"
361 30f6c0c6 2021-10-08 thomas return 1
362 30f6c0c6 2021-10-08 thomas fi
363 30f6c0c6 2021-10-08 thomas
364 30f6c0c6 2021-10-08 thomas echo "got: $head_rev: No such file or directory" \
365 30f6c0c6 2021-10-08 thomas > $testroot/stderr.expected
366 30f6c0c6 2021-10-08 thomas cmp -s $testroot/stderr.expected $testroot/stderr
367 30f6c0c6 2021-10-08 thomas ret="$?"
368 30f6c0c6 2021-10-08 thomas if [ "$ret" != "0" ]; then
369 30f6c0c6 2021-10-08 thomas diff -u $testroot/stderr.expected $testroot/stderr
370 30f6c0c6 2021-10-08 thomas 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 95adcdca 2019-03-27 stsp ret="$?"
392 95adcdca 2019-03-27 stsp if [ "$ret" != "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 c206b220 2021-10-09 thomas sed -i '' -e 's/2/22/' $testroot/repo/numbers
398 c206b220 2021-10-09 thomas sed -i '' -e '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 c206b220 2021-10-09 thomas sed -i '' -e 's/2/77/' $testroot/wt/numbers
404 c206b220 2021-10-09 thomas sed -i '' -e '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 95adcdca 2019-03-27 stsp ret="$?"
416 95adcdca 2019-03-27 stsp if [ "$ret" != "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 95adcdca 2019-03-27 stsp ret="$?"
459 95adcdca 2019-03-27 stsp if [ "$ret" != "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 562580bc 2020-01-14 stsp ret="$?"
500 562580bc 2020-01-14 stsp if [ "$ret" != "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 562580bc 2020-01-14 stsp ret="$?"
520 562580bc 2020-01-14 stsp if [ "$ret" != "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 d24820bf 2019-08-11 stsp ret="$?"
561 d24820bf 2019-08-11 stsp if [ "$ret" != "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 d24820bf 2019-08-11 stsp ret="$?"
581 d24820bf 2019-08-11 stsp if [ "$ret" != "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 63035f9f 2019-10-06 stsp ret="$?"
593 63035f9f 2019-10-06 stsp if [ "$ret" != "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 63035f9f 2019-10-06 stsp ret="$?"
610 63035f9f 2019-10-06 stsp if [ "$ret" != "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 e7303626 2020-05-14 stsp ret="$?"
633 54c39596 2020-12-28 stsp if [ "$ret" = "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 e7303626 2020-05-14 stsp ret="$?"
642 e7303626 2020-05-14 stsp if [ "$ret" != "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 39449a05 2020-07-23 stsp ret="$?"
664 39449a05 2020-07-23 stsp if [ "$ret" != "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 dd6165e4 2021-09-21 thomas.ad (cd $testroot/wt && ln -sfT 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 40dde666 2020-07-23 stsp ret="$?"
747 40dde666 2020-07-23 stsp if [ "$ret" != "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 dd6165e4 2021-09-21 thomas.ad (cd $testroot/repo && ln -sfT 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 39449a05 2020-07-23 stsp ret="$?"
864 39449a05 2020-07-23 stsp if [ "$ret" != "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 dffd0deb 2020-11-20 stsp ret="$?"
876 dffd0deb 2020-11-20 stsp if [ "$ret" != "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 64453f7e 2020-11-21 stsp ret="$?"
893 64453f7e 2020-11-21 stsp if [ "$ret" != "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 dffd0deb 2020-11-20 stsp ret="$?"
911 dffd0deb 2020-11-20 stsp if [ "$ret" != "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 dffd0deb 2020-11-20 stsp ret="$?"
938 dffd0deb 2020-11-20 stsp if [ "$ret" != "0" ]; then
939 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
940 cc8021af 2021-10-12 thomas fi
941 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
942 cc8021af 2021-10-12 thomas }
943 cc8021af 2021-10-12 thomas
944 cc8021af 2021-10-12 thomas test_diff_commits() {
945 cc8021af 2021-10-12 thomas local testroot=`test_init diff_commits`
946 cc8021af 2021-10-12 thomas local commit_id0=`git_show_head $testroot/repo`
947 cc8021af 2021-10-12 thomas alpha_id0=`get_blob_id $testroot/repo "" alpha`
948 cc8021af 2021-10-12 thomas beta_id0=`get_blob_id $testroot/repo "" beta`
949 cc8021af 2021-10-12 thomas
950 cc8021af 2021-10-12 thomas got checkout $testroot/repo $testroot/wt > /dev/null
951 cc8021af 2021-10-12 thomas ret="$?"
952 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
953 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
954 cc8021af 2021-10-12 thomas return 1
955 cc8021af 2021-10-12 thomas fi
956 cc8021af 2021-10-12 thomas
957 cc8021af 2021-10-12 thomas echo "modified alpha" > $testroot/wt/alpha
958 cc8021af 2021-10-12 thomas (cd $testroot/wt && got rm beta >/dev/null)
959 cc8021af 2021-10-12 thomas echo "new file" > $testroot/wt/new
960 cc8021af 2021-10-12 thomas (cd $testroot/wt && got add new >/dev/null)
961 cc8021af 2021-10-12 thomas (cd $testroot/wt && got commit -m 'committing changes' >/dev/null)
962 cc8021af 2021-10-12 thomas local commit_id1=`git_show_head $testroot/repo`
963 cc8021af 2021-10-12 thomas
964 cc8021af 2021-10-12 thomas alpha_id1=`get_blob_id $testroot/repo "" alpha`
965 cc8021af 2021-10-12 thomas new_id1=`get_blob_id $testroot/repo "" new`
966 cc8021af 2021-10-12 thomas
967 cc8021af 2021-10-12 thomas echo "diff $commit_id0 refs/heads/master" > $testroot/stdout.expected
968 cc8021af 2021-10-12 thomas echo "blob - $alpha_id0" >> $testroot/stdout.expected
969 cc8021af 2021-10-12 thomas echo "blob + $alpha_id1" >> $testroot/stdout.expected
970 cc8021af 2021-10-12 thomas echo '--- alpha' >> $testroot/stdout.expected
971 cc8021af 2021-10-12 thomas echo '+++ alpha' >> $testroot/stdout.expected
972 cc8021af 2021-10-12 thomas echo '@@ -1 +1 @@' >> $testroot/stdout.expected
973 cc8021af 2021-10-12 thomas echo '-alpha' >> $testroot/stdout.expected
974 cc8021af 2021-10-12 thomas echo '+modified alpha' >> $testroot/stdout.expected
975 cc8021af 2021-10-12 thomas echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
976 cc8021af 2021-10-12 thomas echo 'blob + /dev/null' >> $testroot/stdout.expected
977 cc8021af 2021-10-12 thomas echo '--- beta' >> $testroot/stdout.expected
978 cc8021af 2021-10-12 thomas echo '+++ /dev/null' >> $testroot/stdout.expected
979 cc8021af 2021-10-12 thomas echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
980 cc8021af 2021-10-12 thomas echo '-beta' >> $testroot/stdout.expected
981 cc8021af 2021-10-12 thomas echo 'blob - /dev/null' >> $testroot/stdout.expected
982 cc8021af 2021-10-12 thomas echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
983 cc8021af 2021-10-12 thomas echo '--- /dev/null' >> $testroot/stdout.expected
984 cc8021af 2021-10-12 thomas echo '+++ new' >> $testroot/stdout.expected
985 cc8021af 2021-10-12 thomas echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
986 cc8021af 2021-10-12 thomas echo '+new file' >> $testroot/stdout.expected
987 cc8021af 2021-10-12 thomas
988 cc8021af 2021-10-12 thomas (cd $testroot/wt && got diff -c master > $testroot/stdout)
989 cc8021af 2021-10-12 thomas cmp -s $testroot/stdout.expected $testroot/stdout
990 cc8021af 2021-10-12 thomas ret="$?"
991 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
992 cc8021af 2021-10-12 thomas diff -u $testroot/stdout.expected $testroot/stdout
993 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
994 cc8021af 2021-10-12 thomas return 1
995 cc8021af 2021-10-12 thomas fi
996 cc8021af 2021-10-12 thomas
997 cc8021af 2021-10-12 thomas # same diff with explicit parent commit ID
998 cc8021af 2021-10-12 thomas (cd $testroot/wt && got diff -c $commit_id0 -c master \
999 cc8021af 2021-10-12 thomas > $testroot/stdout)
1000 cc8021af 2021-10-12 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1001 cc8021af 2021-10-12 thomas ret="$?"
1002 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1003 cc8021af 2021-10-12 thomas diff -u $testroot/stdout.expected $testroot/stdout
1004 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
1005 cc8021af 2021-10-12 thomas return 1
1006 cc8021af 2021-10-12 thomas fi
1007 cc8021af 2021-10-12 thomas
1008 cc8021af 2021-10-12 thomas # same diff with commit object IDs
1009 cc8021af 2021-10-12 thomas echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1010 cc8021af 2021-10-12 thomas echo "blob - $alpha_id0" >> $testroot/stdout.expected
1011 cc8021af 2021-10-12 thomas echo "blob + $alpha_id1" >> $testroot/stdout.expected
1012 cc8021af 2021-10-12 thomas echo '--- alpha' >> $testroot/stdout.expected
1013 cc8021af 2021-10-12 thomas echo '+++ alpha' >> $testroot/stdout.expected
1014 cc8021af 2021-10-12 thomas echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1015 cc8021af 2021-10-12 thomas echo '-alpha' >> $testroot/stdout.expected
1016 cc8021af 2021-10-12 thomas echo '+modified alpha' >> $testroot/stdout.expected
1017 cc8021af 2021-10-12 thomas echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1018 cc8021af 2021-10-12 thomas echo 'blob + /dev/null' >> $testroot/stdout.expected
1019 cc8021af 2021-10-12 thomas echo '--- beta' >> $testroot/stdout.expected
1020 cc8021af 2021-10-12 thomas echo '+++ /dev/null' >> $testroot/stdout.expected
1021 cc8021af 2021-10-12 thomas echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1022 cc8021af 2021-10-12 thomas echo '-beta' >> $testroot/stdout.expected
1023 cc8021af 2021-10-12 thomas echo 'blob - /dev/null' >> $testroot/stdout.expected
1024 cc8021af 2021-10-12 thomas echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1025 cc8021af 2021-10-12 thomas echo '--- /dev/null' >> $testroot/stdout.expected
1026 cc8021af 2021-10-12 thomas echo '+++ new' >> $testroot/stdout.expected
1027 cc8021af 2021-10-12 thomas echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1028 cc8021af 2021-10-12 thomas echo '+new file' >> $testroot/stdout.expected
1029 cc8021af 2021-10-12 thomas (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 \
1030 cc8021af 2021-10-12 thomas > $testroot/stdout)
1031 cc8021af 2021-10-12 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1032 cc8021af 2021-10-12 thomas ret="$?"
1033 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1034 cc8021af 2021-10-12 thomas diff -u $testroot/stdout.expected $testroot/stdout
1035 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
1036 cc8021af 2021-10-12 thomas return 1
1037 cc8021af 2021-10-12 thomas fi
1038 cc8021af 2021-10-12 thomas
1039 cc8021af 2021-10-12 thomas # same diff, filtered by paths
1040 cc8021af 2021-10-12 thomas echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1041 cc8021af 2021-10-12 thomas echo "blob - $alpha_id0" >> $testroot/stdout.expected
1042 cc8021af 2021-10-12 thomas echo "blob + $alpha_id1" >> $testroot/stdout.expected
1043 cc8021af 2021-10-12 thomas echo '--- alpha' >> $testroot/stdout.expected
1044 cc8021af 2021-10-12 thomas echo '+++ alpha' >> $testroot/stdout.expected
1045 cc8021af 2021-10-12 thomas echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1046 cc8021af 2021-10-12 thomas echo '-alpha' >> $testroot/stdout.expected
1047 cc8021af 2021-10-12 thomas echo '+modified alpha' >> $testroot/stdout.expected
1048 cc8021af 2021-10-12 thomas (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 alpha \
1049 cc8021af 2021-10-12 thomas > $testroot/stdout)
1050 cc8021af 2021-10-12 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1051 cc8021af 2021-10-12 thomas ret="$?"
1052 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1053 cc8021af 2021-10-12 thomas diff -u $testroot/stdout.expected $testroot/stdout
1054 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
1055 cc8021af 2021-10-12 thomas return 1
1056 cc8021af 2021-10-12 thomas fi
1057 cc8021af 2021-10-12 thomas # same in a work tree
1058 cc8021af 2021-10-12 thomas (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 alpha \
1059 cc8021af 2021-10-12 thomas > $testroot/stdout)
1060 cc8021af 2021-10-12 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1061 cc8021af 2021-10-12 thomas ret="$?"
1062 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1063 cc8021af 2021-10-12 thomas diff -u $testroot/stdout.expected $testroot/stdout
1064 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
1065 cc8021af 2021-10-12 thomas return 1
1066 dffd0deb 2020-11-20 stsp fi
1067 cc8021af 2021-10-12 thomas
1068 cc8021af 2021-10-12 thomas echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1069 cc8021af 2021-10-12 thomas echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1070 cc8021af 2021-10-12 thomas echo 'blob + /dev/null' >> $testroot/stdout.expected
1071 cc8021af 2021-10-12 thomas echo '--- beta' >> $testroot/stdout.expected
1072 cc8021af 2021-10-12 thomas echo '+++ /dev/null' >> $testroot/stdout.expected
1073 cc8021af 2021-10-12 thomas echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1074 cc8021af 2021-10-12 thomas echo '-beta' >> $testroot/stdout.expected
1075 cc8021af 2021-10-12 thomas echo 'blob - /dev/null' >> $testroot/stdout.expected
1076 cc8021af 2021-10-12 thomas echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1077 cc8021af 2021-10-12 thomas echo '--- /dev/null' >> $testroot/stdout.expected
1078 cc8021af 2021-10-12 thomas echo '+++ new' >> $testroot/stdout.expected
1079 cc8021af 2021-10-12 thomas echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1080 cc8021af 2021-10-12 thomas echo '+new file' >> $testroot/stdout.expected
1081 cc8021af 2021-10-12 thomas (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 \
1082 cc8021af 2021-10-12 thomas beta new > $testroot/stdout)
1083 cc8021af 2021-10-12 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1084 cc8021af 2021-10-12 thomas ret="$?"
1085 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1086 cc8021af 2021-10-12 thomas diff -u $testroot/stdout.expected $testroot/stdout
1087 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
1088 cc8021af 2021-10-12 thomas return 1
1089 cc8021af 2021-10-12 thomas fi
1090 cc8021af 2021-10-12 thomas
1091 cc8021af 2021-10-12 thomas # more than two -c options are not allowed
1092 cc8021af 2021-10-12 thomas (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 -c foo \
1093 cc8021af 2021-10-12 thomas 2> $testroot/stderr)
1094 cc8021af 2021-10-12 thomas ret="$?"
1095 cc8021af 2021-10-12 thomas if [ "$ret" == "0" ]; then
1096 cc8021af 2021-10-12 thomas echo "diff succeeded unexpectedly" >&2
1097 cc8021af 2021-10-12 thomas test_done "$testroot" "1"
1098 cc8021af 2021-10-12 thomas return 1
1099 cc8021af 2021-10-12 thomas fi
1100 cc8021af 2021-10-12 thomas echo "got: too many -c options used" > $testroot/stderr.expected
1101 cc8021af 2021-10-12 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1102 cc8021af 2021-10-12 thomas ret="$?"
1103 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1104 cc8021af 2021-10-12 thomas diff -u $testroot/stderr.expected $testroot/stderr
1105 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
1106 cc8021af 2021-10-12 thomas return 1
1107 cc8021af 2021-10-12 thomas fi
1108 cc8021af 2021-10-12 thomas
1109 cc8021af 2021-10-12 thomas # use of -c options implies a repository diff; use with -P is an error
1110 cc8021af 2021-10-12 thomas (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -P foo \
1111 cc8021af 2021-10-12 thomas 2> $testroot/stderr)
1112 cc8021af 2021-10-12 thomas ret="$?"
1113 cc8021af 2021-10-12 thomas if [ "$ret" == "0" ]; then
1114 cc8021af 2021-10-12 thomas echo "diff succeeded unexpectedly" >&2
1115 cc8021af 2021-10-12 thomas test_done "$testroot" "1"
1116 cc8021af 2021-10-12 thomas return 1
1117 cc8021af 2021-10-12 thomas fi
1118 cc8021af 2021-10-12 thomas echo "got: -P option can only be used when diffing a work tree" \
1119 cc8021af 2021-10-12 thomas > $testroot/stderr.expected
1120 cc8021af 2021-10-12 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1121 cc8021af 2021-10-12 thomas ret="$?"
1122 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1123 cc8021af 2021-10-12 thomas diff -u $testroot/stderr.expected $testroot/stderr
1124 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
1125 cc8021af 2021-10-12 thomas return 1
1126 cc8021af 2021-10-12 thomas fi
1127 cc8021af 2021-10-12 thomas
1128 cc8021af 2021-10-12 thomas # use of -c options implies a repository diff; use with -s is an error
1129 cc8021af 2021-10-12 thomas (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -s foo \
1130 cc8021af 2021-10-12 thomas 2> $testroot/stderr)
1131 cc8021af 2021-10-12 thomas ret="$?"
1132 cc8021af 2021-10-12 thomas if [ "$ret" == "0" ]; then
1133 cc8021af 2021-10-12 thomas echo "diff succeeded unexpectedly" >&2
1134 cc8021af 2021-10-12 thomas test_done "$testroot" "1"
1135 cc8021af 2021-10-12 thomas return 1
1136 cc8021af 2021-10-12 thomas fi
1137 cc8021af 2021-10-12 thomas echo "got: -s option can only be used when diffing a work tree" \
1138 cc8021af 2021-10-12 thomas > $testroot/stderr.expected
1139 cc8021af 2021-10-12 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1140 cc8021af 2021-10-12 thomas ret="$?"
1141 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1142 cc8021af 2021-10-12 thomas diff -u $testroot/stderr.expected $testroot/stderr
1143 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
1144 cc8021af 2021-10-12 thomas return 1
1145 cc8021af 2021-10-12 thomas fi
1146 cc8021af 2021-10-12 thomas
1147 cc8021af 2021-10-12 thomas # three arguments imply use of path filtering (repository case)
1148 cc8021af 2021-10-12 thomas (cd $testroot/repo && got diff $commit_id0 $commit_id1 foo \
1149 cc8021af 2021-10-12 thomas 2> $testroot/stderr)
1150 cc8021af 2021-10-12 thomas ret="$?"
1151 cc8021af 2021-10-12 thomas if [ "$ret" == "0" ]; then
1152 cc8021af 2021-10-12 thomas echo "diff succeeded unexpectedly" >&2
1153 cc8021af 2021-10-12 thomas test_done "$testroot" "1"
1154 cc8021af 2021-10-12 thomas return 1
1155 cc8021af 2021-10-12 thomas fi
1156 cc8021af 2021-10-12 thomas echo "got: specified paths cannot be resolved: no got work tree found" \
1157 cc8021af 2021-10-12 thomas > $testroot/stderr.expected
1158 cc8021af 2021-10-12 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1159 cc8021af 2021-10-12 thomas ret="$?"
1160 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1161 cc8021af 2021-10-12 thomas diff -u $testroot/stderr.expected $testroot/stderr
1162 cc8021af 2021-10-12 thomas test_done "$testroot" "$ret"
1163 cc8021af 2021-10-12 thomas return 1
1164 cc8021af 2021-10-12 thomas fi
1165 cc8021af 2021-10-12 thomas
1166 cc8021af 2021-10-12 thomas # three arguments imply use of path filtering (work tree case)
1167 f1417e9f 2021-10-12 thomas (cd $testroot/wt && got diff $commit_id0 master foo \
1168 cc8021af 2021-10-12 thomas 2> $testroot/stderr)
1169 cc8021af 2021-10-12 thomas ret="$?"
1170 cc8021af 2021-10-12 thomas if [ "$ret" == "0" ]; then
1171 cc8021af 2021-10-12 thomas echo "diff succeeded unexpectedly" >&2
1172 cc8021af 2021-10-12 thomas test_done "$testroot" "1"
1173 cc8021af 2021-10-12 thomas return 1
1174 cc8021af 2021-10-12 thomas fi
1175 cc8021af 2021-10-12 thomas echo "got: $commit_id0: No such file or directory" \
1176 cc8021af 2021-10-12 thomas > $testroot/stderr.expected
1177 cc8021af 2021-10-12 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1178 cc8021af 2021-10-12 thomas ret="$?"
1179 cc8021af 2021-10-12 thomas if [ "$ret" != "0" ]; then
1180 cc8021af 2021-10-12 thomas diff -u $testroot/stderr.expected $testroot/stderr
1181 cc8021af 2021-10-12 thomas fi
1182 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
1183 39449a05 2020-07-23 stsp }
1184 39449a05 2020-07-23 stsp
1185 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1186 95adcdca 2019-03-27 stsp run_test test_diff_basic
1187 95adcdca 2019-03-27 stsp run_test test_diff_shows_conflict
1188 d24820bf 2019-08-11 stsp run_test test_diff_tag
1189 562580bc 2020-01-14 stsp run_test test_diff_lightweight_tag
1190 63035f9f 2019-10-06 stsp run_test test_diff_ignore_whitespace
1191 e7303626 2020-05-14 stsp run_test test_diff_submodule_of_same_repo
1192 39449a05 2020-07-23 stsp run_test test_diff_symlinks_in_work_tree
1193 40dde666 2020-07-23 stsp run_test test_diff_symlinks_in_repo
1194 dffd0deb 2020-11-20 stsp run_test test_diff_binary_files
1195 cc8021af 2021-10-12 thomas run_test test_diff_commits