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