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