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 360f3aea 2022-08-30 mark 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 49c543a6 2022-03-31 naddy ret=$?
26 49c543a6 2022-03-31 naddy 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 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
37 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
38 8469d821 2022-06-25 stsp 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 c87842d5 2022-09-23 mark 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 49c543a6 2022-03-31 naddy ret=$?
66 49c543a6 2022-03-31 naddy 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 e7ffb0b0 2021-10-07 stsp # 'got diff' in a repository without any arguments is an error
73 e7ffb0b0 2021-10-07 stsp (cd $testroot/repo && got diff 2> $testroot/stderr)
74 e7ffb0b0 2021-10-07 stsp echo "got: no got work tree found" > $testroot/stderr.expected
75 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
76 49c543a6 2022-03-31 naddy ret=$?
77 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
78 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
79 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
80 e7ffb0b0 2021-10-07 stsp return 1
81 e7ffb0b0 2021-10-07 stsp fi
82 e7ffb0b0 2021-10-07 stsp
83 e7ffb0b0 2021-10-07 stsp # 'got diff' in a repository with two arguments requires that
84 e7ffb0b0 2021-10-07 stsp # both named objects exist
85 e7ffb0b0 2021-10-07 stsp (cd $testroot/repo && got diff $head_rev foo 2> $testroot/stderr)
86 e7ffb0b0 2021-10-07 stsp echo "got: foo: object not found" > $testroot/stderr.expected
87 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
88 49c543a6 2022-03-31 naddy ret=$?
89 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
90 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
91 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
92 e7ffb0b0 2021-10-07 stsp return 1
93 e7ffb0b0 2021-10-07 stsp fi
94 e7ffb0b0 2021-10-07 stsp
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 49c543a6 2022-03-31 naddy ret=$?
102 49c543a6 2022-03-31 naddy 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 e7ffb0b0 2021-10-07 stsp > $testroot/stderr.expected
110 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
111 49c543a6 2022-03-31 naddy ret=$?
112 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
113 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
114 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
115 e7ffb0b0 2021-10-07 stsp return 1
116 e7ffb0b0 2021-10-07 stsp fi
117 e7ffb0b0 2021-10-07 stsp
118 e7ffb0b0 2021-10-07 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
119 e7ffb0b0 2021-10-07 stsp
120 e7ffb0b0 2021-10-07 stsp # diff several paths in a work tree
121 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
122 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
123 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
124 e7ffb0b0 2021-10-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
125 e7ffb0b0 2021-10-07 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
126 e7ffb0b0 2021-10-07 stsp >> $testroot/stdout.expected
127 e7ffb0b0 2021-10-07 stsp echo 'file + alpha' >> $testroot/stdout.expected
128 e7ffb0b0 2021-10-07 stsp echo '--- alpha' >> $testroot/stdout.expected
129 e7ffb0b0 2021-10-07 stsp echo '+++ alpha' >> $testroot/stdout.expected
130 e7ffb0b0 2021-10-07 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
131 e7ffb0b0 2021-10-07 stsp echo '-alpha' >> $testroot/stdout.expected
132 e7ffb0b0 2021-10-07 stsp echo '+modified alpha' >> $testroot/stdout.expected
133 e7ffb0b0 2021-10-07 stsp echo -n 'blob - ' >> $testroot/stdout.expected
134 10a623df 2021-10-11 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
135 10a623df 2021-10-11 stsp >> $testroot/stdout.expected
136 10a623df 2021-10-11 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
137 10a623df 2021-10-11 stsp echo '--- beta' >> $testroot/stdout.expected
138 10a623df 2021-10-11 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
139 10a623df 2021-10-11 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
140 10a623df 2021-10-11 stsp echo '-beta' >> $testroot/stdout.expected
141 10a623df 2021-10-11 stsp echo -n 'blob - ' >> $testroot/stdout.expected
142 e7ffb0b0 2021-10-07 stsp got tree -r $testroot/repo -i epsilon | grep 'zeta$' | cut -d' ' -f 1 \
143 e7ffb0b0 2021-10-07 stsp >> $testroot/stdout.expected
144 e7ffb0b0 2021-10-07 stsp echo 'file + epsilon/zeta' >> $testroot/stdout.expected
145 e7ffb0b0 2021-10-07 stsp echo '--- epsilon/zeta' >> $testroot/stdout.expected
146 e7ffb0b0 2021-10-07 stsp echo '+++ epsilon/zeta' >> $testroot/stdout.expected
147 e7ffb0b0 2021-10-07 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
148 e7ffb0b0 2021-10-07 stsp echo '-zeta' >> $testroot/stdout.expected
149 e7ffb0b0 2021-10-07 stsp echo '+modified zeta' >> $testroot/stdout.expected
150 10a623df 2021-10-11 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
151 c87842d5 2022-09-23 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
152 10a623df 2021-10-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
153 10a623df 2021-10-11 stsp echo '+++ new' >> $testroot/stdout.expected
154 10a623df 2021-10-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
155 10a623df 2021-10-11 stsp echo '+new file' >> $testroot/stdout.expected
156 e7ffb0b0 2021-10-07 stsp
157 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new alpha epsilon beta > $testroot/stdout)
158 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
159 49c543a6 2022-03-31 naddy ret=$?
160 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
161 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
162 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
163 e7ffb0b0 2021-10-07 stsp return 1
164 e7ffb0b0 2021-10-07 stsp fi
165 e7ffb0b0 2021-10-07 stsp
166 10a623df 2021-10-11 stsp # different order of arguments results in same output order
167 10a623df 2021-10-11 stsp (cd $testroot/wt && got diff alpha new epsilon beta \
168 e7ffb0b0 2021-10-07 stsp > $testroot/stdout 2> $testroot/stderr)
169 49c543a6 2022-03-31 naddy ret=$?
170 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
171 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
172 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
173 e7ffb0b0 2021-10-07 stsp return 1
174 e7ffb0b0 2021-10-07 stsp fi
175 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
176 49c543a6 2022-03-31 naddy ret=$?
177 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
178 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
179 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
180 e7ffb0b0 2021-10-07 stsp return 1
181 e7ffb0b0 2021-10-07 stsp fi
182 e7ffb0b0 2021-10-07 stsp
183 10a623df 2021-10-11 stsp # a branch 'new' should not collide with path 'new' if more
184 10a623df 2021-10-11 stsp # than two arguments are passed
185 10a623df 2021-10-11 stsp got br -r $testroot/repo -c master new > /dev/null
186 10a623df 2021-10-11 stsp (cd $testroot/wt && got diff new alpha epsilon beta \
187 e7ffb0b0 2021-10-07 stsp > $testroot/stdout 2> $testroot/stderr)
188 49c543a6 2022-03-31 naddy ret=$?
189 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
190 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
191 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
192 e7ffb0b0 2021-10-07 stsp return 1
193 e7ffb0b0 2021-10-07 stsp fi
194 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
195 49c543a6 2022-03-31 naddy ret=$?
196 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
197 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
198 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
199 e7ffb0b0 2021-10-07 stsp return 1
200 e7ffb0b0 2021-10-07 stsp fi
201 e7ffb0b0 2021-10-07 stsp
202 e7ffb0b0 2021-10-07 stsp # Two arguments are interpreted as objects if a colliding path exists
203 e7ffb0b0 2021-10-07 stsp echo master > $testroot/wt/master
204 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got add master > /dev/null)
205 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff master new > $testroot/stdout)
206 49c543a6 2022-03-31 naddy ret=$?
207 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
208 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
209 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
210 e7ffb0b0 2021-10-07 stsp return 1
211 e7ffb0b0 2021-10-07 stsp fi
212 e7ffb0b0 2021-10-07 stsp echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
213 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
214 8469d821 2022-06-25 stsp echo "commit + $head_rev" >> $testroot/stdout.expected
215 e7ffb0b0 2021-10-07 stsp # diff between the branches is empty
216 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
217 49c543a6 2022-03-31 naddy ret=$?
218 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
219 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
220 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
221 e7ffb0b0 2021-10-07 stsp return 1
222 e7ffb0b0 2021-10-07 stsp fi
223 e7ffb0b0 2021-10-07 stsp # same without a work tree
224 e7ffb0b0 2021-10-07 stsp (cd $testroot/repo && got diff master new > $testroot/stdout)
225 49c543a6 2022-03-31 naddy ret=$?
226 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
227 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
228 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
229 e7ffb0b0 2021-10-07 stsp return 1
230 e7ffb0b0 2021-10-07 stsp fi
231 e7ffb0b0 2021-10-07 stsp echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
232 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
233 8469d821 2022-06-25 stsp echo "commit + $head_rev" >> $testroot/stdout.expected
234 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
235 49c543a6 2022-03-31 naddy ret=$?
236 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
237 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
238 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
239 e7ffb0b0 2021-10-07 stsp return 1
240 e7ffb0b0 2021-10-07 stsp fi
241 e7ffb0b0 2021-10-07 stsp # same with -r argument
242 e7ffb0b0 2021-10-07 stsp got diff -r $testroot/repo master new > $testroot/stdout
243 49c543a6 2022-03-31 naddy ret=$?
244 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
245 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
246 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
247 e7ffb0b0 2021-10-07 stsp return 1
248 e7ffb0b0 2021-10-07 stsp fi
249 e7ffb0b0 2021-10-07 stsp echo "diff refs/heads/master refs/heads/new" > $testroot/stdout.expected
250 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
251 8469d821 2022-06-25 stsp echo "commit + $head_rev" >> $testroot/stdout.expected
252 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
253 49c543a6 2022-03-31 naddy ret=$?
254 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
255 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
256 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
257 e7ffb0b0 2021-10-07 stsp return 1
258 e7ffb0b0 2021-10-07 stsp fi
259 e7ffb0b0 2021-10-07 stsp
260 e7ffb0b0 2021-10-07 stsp # -P can be used to force use of paths
261 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff -P new master > $testroot/stdout)
262 49c543a6 2022-03-31 naddy ret=$?
263 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
264 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
265 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
266 e7ffb0b0 2021-10-07 stsp return 1
267 e7ffb0b0 2021-10-07 stsp fi
268 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
269 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
270 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
271 e7ffb0b0 2021-10-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
272 c87842d5 2022-09-23 mark echo 'file + master (mode 644)' >> $testroot/stdout.expected
273 e7ffb0b0 2021-10-07 stsp echo '--- /dev/null' >> $testroot/stdout.expected
274 e7ffb0b0 2021-10-07 stsp echo '+++ master' >> $testroot/stdout.expected
275 e7ffb0b0 2021-10-07 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
276 e7ffb0b0 2021-10-07 stsp echo '+master' >> $testroot/stdout.expected
277 10a623df 2021-10-11 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
278 c87842d5 2022-09-23 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
279 10a623df 2021-10-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
280 10a623df 2021-10-11 stsp echo '+++ new' >> $testroot/stdout.expected
281 10a623df 2021-10-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
282 10a623df 2021-10-11 stsp echo '+new file' >> $testroot/stdout.expected
283 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
284 49c543a6 2022-03-31 naddy ret=$?
285 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
286 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
287 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
288 e7ffb0b0 2021-10-07 stsp return 1
289 e7ffb0b0 2021-10-07 stsp fi
290 e7ffb0b0 2021-10-07 stsp
291 e7ffb0b0 2021-10-07 stsp # -P can only be used in a work tree
292 e7ffb0b0 2021-10-07 stsp got diff -r $testroot/repo -P new master 2> $testroot/stderr
293 49c543a6 2022-03-31 naddy ret=$?
294 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
295 e7ffb0b0 2021-10-07 stsp echo "diff succeeded unexpectedly" >&2
296 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
297 e7ffb0b0 2021-10-07 stsp return 1
298 e7ffb0b0 2021-10-07 stsp fi
299 e7ffb0b0 2021-10-07 stsp 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 49c543a6 2022-03-31 naddy ret=$?
303 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
304 2a06fe5f 2019-08-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
305 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
306 e7ffb0b0 2021-10-07 stsp return 1
307 e7ffb0b0 2021-10-07 stsp fi
308 e7ffb0b0 2021-10-07 stsp
309 e7ffb0b0 2021-10-07 stsp # a single argument which can be resolved to a path is not ambiguous
310 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
311 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
312 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
313 e7ffb0b0 2021-10-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
314 c87842d5 2022-09-23 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
315 e7ffb0b0 2021-10-07 stsp echo '--- /dev/null' >> $testroot/stdout.expected
316 e7ffb0b0 2021-10-07 stsp echo '+++ new' >> $testroot/stdout.expected
317 e7ffb0b0 2021-10-07 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
318 e7ffb0b0 2021-10-07 stsp echo '+new file' >> $testroot/stdout.expected
319 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new > $testroot/stdout)
320 49c543a6 2022-03-31 naddy ret=$?
321 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
322 e7ffb0b0 2021-10-07 stsp echo "diff failed unexpectedly" >&2
323 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
324 e7ffb0b0 2021-10-07 stsp return 1
325 e7ffb0b0 2021-10-07 stsp fi
326 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
327 49c543a6 2022-03-31 naddy ret=$?
328 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
329 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
330 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
331 e7ffb0b0 2021-10-07 stsp return 1
332 e7ffb0b0 2021-10-07 stsp fi
333 e7ffb0b0 2021-10-07 stsp
334 e7ffb0b0 2021-10-07 stsp # diff with just one object ID argument results in
335 e7ffb0b0 2021-10-07 stsp # interpretation of argument as a path
336 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff $head_rev 2> $testroot/stderr)
337 49c543a6 2022-03-31 naddy ret=$?
338 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
339 e7ffb0b0 2021-10-07 stsp echo "diff succeeded unexpectedly" >&2
340 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
341 e7ffb0b0 2021-10-07 stsp return 1
342 e7ffb0b0 2021-10-07 stsp fi
343 e7ffb0b0 2021-10-07 stsp echo "got: $head_rev: No such file or directory" \
344 e7ffb0b0 2021-10-07 stsp > $testroot/stderr.expected
345 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
346 49c543a6 2022-03-31 naddy ret=$?
347 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
348 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
349 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
350 e7ffb0b0 2021-10-07 stsp return 1
351 e7ffb0b0 2021-10-07 stsp fi
352 e7ffb0b0 2021-10-07 stsp
353 e7ffb0b0 2021-10-07 stsp # diff with more than two object arguments results in
354 e7ffb0b0 2021-10-07 stsp # interpretation of arguments as paths
355 e7ffb0b0 2021-10-07 stsp (cd $testroot/wt && got diff new $head_rev master \
356 e7ffb0b0 2021-10-07 stsp > $testroot/stout 2> $testroot/stderr)
357 49c543a6 2022-03-31 naddy ret=$?
358 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
359 e7ffb0b0 2021-10-07 stsp echo "diff succeeded unexpectedly" >&2
360 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "1"
361 e7ffb0b0 2021-10-07 stsp return 1
362 e7ffb0b0 2021-10-07 stsp fi
363 e7ffb0b0 2021-10-07 stsp
364 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
365 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
366 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
367 e7ffb0b0 2021-10-07 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
368 c87842d5 2022-09-23 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
369 e7ffb0b0 2021-10-07 stsp echo '--- /dev/null' >> $testroot/stdout.expected
370 e7ffb0b0 2021-10-07 stsp echo '+++ new' >> $testroot/stdout.expected
371 e7ffb0b0 2021-10-07 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
372 e7ffb0b0 2021-10-07 stsp echo '+new file' >> $testroot/stdout.expected
373 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
374 49c543a6 2022-03-31 naddy ret=$?
375 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
376 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
377 e7ffb0b0 2021-10-07 stsp test_done "$testroot" "$ret"
378 e7ffb0b0 2021-10-07 stsp return 1
379 e7ffb0b0 2021-10-07 stsp fi
380 e7ffb0b0 2021-10-07 stsp
381 e7ffb0b0 2021-10-07 stsp echo "got: $head_rev: No such file or directory" \
382 e7ffb0b0 2021-10-07 stsp > $testroot/stderr.expected
383 e7ffb0b0 2021-10-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
384 49c543a6 2022-03-31 naddy ret=$?
385 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
386 e7ffb0b0 2021-10-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
387 360f3aea 2022-08-30 mark return 1
388 360f3aea 2022-08-30 mark fi
389 360f3aea 2022-08-30 mark
390 360f3aea 2022-08-30 mark # diff two blob ids
391 360f3aea 2022-08-30 mark (cd $testroot/wt && got commit -m 'edit' alpha >/dev/null)
392 360f3aea 2022-08-30 mark local alpha_new_blobid=`get_blob_id $testroot/repo "" alpha`
393 d4f2833a 2022-08-31 op (cd $testroot/wt && got diff $alpha_blobid $alpha_new_blobid) \
394 d4f2833a 2022-08-31 op > $testroot/diff
395 360f3aea 2022-08-30 mark ret=$?
396 360f3aea 2022-08-30 mark if [ $ret -ne 0 ]; then
397 360f3aea 2022-08-30 mark echo "diff failed unexpectedly" >&2
398 360f3aea 2022-08-30 mark test_done "$testroot" "$ret"
399 360f3aea 2022-08-30 mark return 1
400 360f3aea 2022-08-30 mark fi
401 360f3aea 2022-08-30 mark
402 360f3aea 2022-08-30 mark cat <<EOF >$testroot/diff.expected
403 360f3aea 2022-08-30 mark blob - $alpha_blobid
404 360f3aea 2022-08-30 mark blob + $alpha_new_blobid
405 360f3aea 2022-08-30 mark --- $alpha_blobid
406 360f3aea 2022-08-30 mark +++ $alpha_new_blobid
407 360f3aea 2022-08-30 mark @@ -1 +1 @@
408 360f3aea 2022-08-30 mark -alpha
409 360f3aea 2022-08-30 mark +modified alpha
410 360f3aea 2022-08-30 mark EOF
411 360f3aea 2022-08-30 mark
412 360f3aea 2022-08-30 mark cmp -s $testroot/diff.expected $testroot/diff
413 360f3aea 2022-08-30 mark ret=$?
414 360f3aea 2022-08-30 mark if [ $ret -ne 0 ]; then
415 360f3aea 2022-08-30 mark echo
416 360f3aea 2022-08-30 mark diff -u $testroot/diff.expected $testroot/diff
417 360f3aea 2022-08-30 mark test_done "$testroot" "$ret"
418 e7ffb0b0 2021-10-07 stsp return 1
419 2a06fe5f 2019-08-24 stsp fi
420 360f3aea 2022-08-30 mark
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 49c543a6 2022-03-31 naddy ret=$?
441 49c543a6 2022-03-31 naddy 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 95adcdca 2019-03-27 stsp sed -i 's/2/22/' $testroot/repo/numbers
447 d136cfcb 2019-10-12 stsp sed -i '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 95adcdca 2019-03-27 stsp sed -i 's/2/77/' $testroot/wt/numbers
453 d136cfcb 2019-10-12 stsp sed -i '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 49c543a6 2022-03-31 naddy ret=$?
465 49c543a6 2022-03-31 naddy 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 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
472 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
473 8469d821 2022-06-25 stsp 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 49c543a6 2022-03-31 naddy ret=$?
510 49c543a6 2022-03-31 naddy 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 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
537 8469d821 2022-06-25 stsp 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 49c543a6 2022-03-31 naddy ret=$?
553 49c543a6 2022-03-31 naddy 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 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
561 8469d821 2022-06-25 stsp 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 49c543a6 2022-03-31 naddy ret=$?
575 49c543a6 2022-03-31 naddy 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 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
602 8469d821 2022-06-25 stsp 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 49c543a6 2022-03-31 naddy ret=$?
618 49c543a6 2022-03-31 naddy 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 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
626 8469d821 2022-06-25 stsp 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 49c543a6 2022-03-31 naddy ret=$?
640 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy ret=$?
652 49c543a6 2022-03-31 naddy 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 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
662 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
663 8469d821 2022-06-25 stsp 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 49c543a6 2022-03-31 naddy ret=$?
671 49c543a6 2022-03-31 naddy 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 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
682 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
683 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
684 e7303626 2020-05-14 stsp
685 e7303626 2020-05-14 stsp epsilon_id=$(got tree -r $testroot/repo -i | grep 'epsilon/$' | \
686 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
687 e7303626 2020-05-14 stsp submodule_id=$(got tree -r $testroot/repo -i | grep 'repo2\$$' | \
688 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
689 e7303626 2020-05-14 stsp
690 e7303626 2020-05-14 stsp # Attempt a (nonsensical) diff between a tree object and a submodule.
691 e7303626 2020-05-14 stsp # Currently fails with "wrong type of object" error
692 e7303626 2020-05-14 stsp got diff -r $testroot/repo $epsilon_id $submodule_id \
693 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
694 49c543a6 2022-03-31 naddy ret=$?
695 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
696 e7303626 2020-05-14 stsp echo "diff command succeeded unexpectedly" >&2
697 e7303626 2020-05-14 stsp test_done "$testroot" "1"
698 e7303626 2020-05-14 stsp return 1
699 63035f9f 2019-10-06 stsp fi
700 e7303626 2020-05-14 stsp echo "got: wrong type of object" > $testroot/stderr.expected
701 e7303626 2020-05-14 stsp
702 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
703 49c543a6 2022-03-31 naddy ret=$?
704 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
705 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
706 e7303626 2020-05-14 stsp return 1
707 e7303626 2020-05-14 stsp fi
708 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
709 63035f9f 2019-10-06 stsp }
710 39449a05 2020-07-23 stsp
711 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_work_tree() {
712 39449a05 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_work_tree`
713 39449a05 2020-07-23 stsp
714 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
715 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
716 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
717 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
718 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
719 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
720 39449a05 2020-07-23 stsp (cd $testroot/repo && git add .)
721 39449a05 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
722 39449a05 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
723 39449a05 2020-07-23 stsp
724 39449a05 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
725 49c543a6 2022-03-31 naddy ret=$?
726 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
727 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
728 39449a05 2020-07-23 stsp return 1
729 39449a05 2020-07-23 stsp fi
730 39449a05 2020-07-23 stsp
731 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
732 4135d7d0 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
733 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
734 39449a05 2020-07-23 stsp echo -n '.got/bar' > $testroot/wt/dotgotfoo.link
735 39449a05 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
736 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf epsilon/zeta zeta.link)
737 39449a05 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
738 39449a05 2020-07-23 stsp (cd $testroot/wt && got diff > $testroot/stdout)
739 63035f9f 2019-10-06 stsp
740 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
741 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
742 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
743 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
744 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
745 39449a05 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
746 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
747 39449a05 2020-07-23 stsp echo 'file + alpha.link' >> $testroot/stdout.expected
748 39449a05 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
749 39449a05 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
750 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
751 39449a05 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
752 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
753 39449a05 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
754 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
755 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
756 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
757 39449a05 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
758 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
759 39449a05 2020-07-23 stsp echo 'file + dotgotfoo.link' >> $testroot/stdout.expected
760 39449a05 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
761 39449a05 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
762 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
763 39449a05 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
764 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
765 39449a05 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
766 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
767 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
768 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
769 39449a05 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
770 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
771 39449a05 2020-07-23 stsp echo 'file + 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 '+++ epsilon/beta.link' >> $testroot/stdout.expected
774 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
775 39449a05 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
776 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
777 39449a05 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
778 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
779 4135d7d0 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
780 4135d7d0 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
781 4135d7d0 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
782 4135d7d0 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
783 4135d7d0 2020-07-23 stsp echo 'file + epsilon.link' >> $testroot/stdout.expected
784 4135d7d0 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
785 4135d7d0 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
786 4135d7d0 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
787 4135d7d0 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
788 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
789 4135d7d0 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
790 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
791 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
792 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
793 39449a05 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
794 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
795 39449a05 2020-07-23 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
796 39449a05 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
797 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
798 39449a05 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
799 39449a05 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
800 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
801 39449a05 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
802 c87842d5 2022-09-23 mark echo 'file + zeta.link (mode 120000)' >> $testroot/stdout.expected
803 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
804 40dde666 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
805 40dde666 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
806 40dde666 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
807 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
808 40dde666 2020-07-23 stsp
809 40dde666 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
810 49c543a6 2022-03-31 naddy ret=$?
811 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
812 40dde666 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
813 40dde666 2020-07-23 stsp fi
814 40dde666 2020-07-23 stsp test_done "$testroot" "$ret"
815 40dde666 2020-07-23 stsp }
816 40dde666 2020-07-23 stsp
817 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_repo() {
818 40dde666 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_repo`
819 40dde666 2020-07-23 stsp
820 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
821 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
822 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
823 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
824 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
825 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
826 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
827 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
828 40dde666 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
829 40dde666 2020-07-23 stsp
830 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
831 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sfh gamma epsilon.link)
832 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
833 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar $testroot/repo/dotgotfoo.link)
834 40dde666 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
835 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
836 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
837 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
838 40dde666 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
839 40dde666 2020-07-23 stsp
840 40dde666 2020-07-23 stsp got diff -r $testroot/repo $commit_id1 $commit_id2 > $testroot/stdout
841 40dde666 2020-07-23 stsp
842 40dde666 2020-07-23 stsp echo "diff $commit_id1 $commit_id2" > $testroot/stdout.expected
843 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
844 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
845 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
846 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
847 40dde666 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
848 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
849 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
850 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
851 40dde666 2020-07-23 stsp grep 'alpha.link@ -> beta$' | \
852 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
853 40dde666 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
854 40dde666 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
855 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
856 40dde666 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
857 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
858 40dde666 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
859 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
860 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
861 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
862 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
863 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
864 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
865 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
866 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/bar$' | \
867 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
868 40dde666 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
869 40dde666 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
870 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
871 40dde666 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
872 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
873 40dde666 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
874 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
875 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
876 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
877 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
878 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
879 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
880 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i epsilon | \
881 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../gamma/delta$' | \
882 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
883 40dde666 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
884 40dde666 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
885 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
886 40dde666 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
887 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
888 40dde666 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
889 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
890 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
891 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
892 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
893 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
894 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
895 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
896 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> gamma$' | \
897 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
898 40dde666 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
899 40dde666 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
900 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
901 40dde666 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
902 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
903 40dde666 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
904 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
905 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
906 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
907 40dde666 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
908 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
909 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
910 40dde666 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
911 40dde666 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
912 40dde666 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
913 40dde666 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
914 40dde666 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
915 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
916 40dde666 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
917 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
918 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
919 40dde666 2020-07-23 stsp grep 'zeta.link@ -> epsilon/zeta$' | \
920 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
921 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
922 40dde666 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
923 39449a05 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
924 39449a05 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
925 39449a05 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
926 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
927 39449a05 2020-07-23 stsp
928 39449a05 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
929 49c543a6 2022-03-31 naddy ret=$?
930 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
931 39449a05 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
932 dffd0deb 2020-11-20 stsp fi
933 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
934 dffd0deb 2020-11-20 stsp }
935 dffd0deb 2020-11-20 stsp
936 dffd0deb 2020-11-20 stsp test_diff_binary_files() {
937 dffd0deb 2020-11-20 stsp local testroot=`test_init diff_binary_files`
938 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
939 dffd0deb 2020-11-20 stsp
940 dffd0deb 2020-11-20 stsp got checkout $testroot/repo $testroot/wt > /dev/null
941 49c543a6 2022-03-31 naddy ret=$?
942 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
943 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
944 dffd0deb 2020-11-20 stsp return 1
945 dffd0deb 2020-11-20 stsp fi
946 dffd0deb 2020-11-20 stsp
947 dffd0deb 2020-11-20 stsp printf '\377\377\0\0\377\377\0\0' > $testroot/wt/foo
948 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got add foo >/dev/null)
949 64453f7e 2020-11-21 stsp
950 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
951 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
952 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
953 64453f7e 2020-11-21 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
954 c87842d5 2022-09-23 mark echo 'file + foo (mode 644)' >> $testroot/stdout.expected
955 1cb46f00 2020-11-21 stsp echo "Binary files /dev/null and foo differ" \
956 1cb46f00 2020-11-21 stsp >> $testroot/stdout.expected
957 64453f7e 2020-11-21 stsp
958 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff > $testroot/stdout)
959 64453f7e 2020-11-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
960 49c543a6 2022-03-31 naddy ret=$?
961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
962 64453f7e 2020-11-21 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
963 64453f7e 2020-11-21 stsp test_done "$testroot" "$ret"
964 64453f7e 2020-11-21 stsp return 1
965 64453f7e 2020-11-21 stsp fi
966 dffd0deb 2020-11-20 stsp
967 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
968 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
969 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
970 dffd0deb 2020-11-20 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
971 c87842d5 2022-09-23 mark echo 'file + foo (mode 644)' >> $testroot/stdout.expected
972 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
973 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
974 dffd0deb 2020-11-20 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
975 dffd0deb 2020-11-20 stsp printf '+\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
976 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
977 dffd0deb 2020-11-20 stsp
978 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
979 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
980 49c543a6 2022-03-31 naddy ret=$?
981 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
982 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
983 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
984 dffd0deb 2020-11-20 stsp return 1
985 39449a05 2020-07-23 stsp fi
986 dffd0deb 2020-11-20 stsp
987 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
988 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
989 dffd0deb 2020-11-20 stsp
990 dffd0deb 2020-11-20 stsp printf '\377\200\0\0\377\200\0\0' > $testroot/wt/foo
991 dffd0deb 2020-11-20 stsp
992 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
993 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
994 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
995 dffd0deb 2020-11-20 stsp echo -n 'blob - ' >> $testroot/stdout.expected
996 dffd0deb 2020-11-20 stsp got tree -r $testroot/repo -i | grep 'foo$' | cut -d' ' -f 1 \
997 dffd0deb 2020-11-20 stsp >> $testroot/stdout.expected
998 dffd0deb 2020-11-20 stsp echo 'file + foo' >> $testroot/stdout.expected
999 dffd0deb 2020-11-20 stsp echo '--- foo' >> $testroot/stdout.expected
1000 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
1001 dffd0deb 2020-11-20 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1002 578133c9 2020-11-28 naddy printf -- '-\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
1003 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
1004 dffd0deb 2020-11-20 stsp printf '+\377\200\0\0\377\200\0\0\n' >> $testroot/stdout.expected
1005 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
1006 dffd0deb 2020-11-20 stsp
1007 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
1008 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1009 49c543a6 2022-03-31 naddy ret=$?
1010 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1011 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
1012 67b631c9 2021-10-10 stsp fi
1013 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1014 67b631c9 2021-10-10 stsp }
1015 67b631c9 2021-10-10 stsp
1016 67b631c9 2021-10-10 stsp test_diff_commits() {
1017 67b631c9 2021-10-10 stsp local testroot=`test_init diff_commits`
1018 67b631c9 2021-10-10 stsp local commit_id0=`git_show_head $testroot/repo`
1019 67b631c9 2021-10-10 stsp alpha_id0=`get_blob_id $testroot/repo "" alpha`
1020 67b631c9 2021-10-10 stsp beta_id0=`get_blob_id $testroot/repo "" beta`
1021 67b631c9 2021-10-10 stsp
1022 67b631c9 2021-10-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1023 49c543a6 2022-03-31 naddy ret=$?
1024 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1025 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1026 67b631c9 2021-10-10 stsp return 1
1027 67b631c9 2021-10-10 stsp fi
1028 67b631c9 2021-10-10 stsp
1029 67b631c9 2021-10-10 stsp echo "modified alpha" > $testroot/wt/alpha
1030 67b631c9 2021-10-10 stsp (cd $testroot/wt && got rm beta >/dev/null)
1031 67b631c9 2021-10-10 stsp echo "new file" > $testroot/wt/new
1032 67b631c9 2021-10-10 stsp (cd $testroot/wt && got add new >/dev/null)
1033 67b631c9 2021-10-10 stsp (cd $testroot/wt && got commit -m 'committing changes' >/dev/null)
1034 67b631c9 2021-10-10 stsp local commit_id1=`git_show_head $testroot/repo`
1035 67b631c9 2021-10-10 stsp
1036 67b631c9 2021-10-10 stsp alpha_id1=`get_blob_id $testroot/repo "" alpha`
1037 67b631c9 2021-10-10 stsp new_id1=`get_blob_id $testroot/repo "" new`
1038 67b631c9 2021-10-10 stsp
1039 67b631c9 2021-10-10 stsp echo "diff $commit_id0 refs/heads/master" > $testroot/stdout.expected
1040 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1041 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1042 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1043 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1044 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1045 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1046 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1047 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1048 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1049 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1050 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1051 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1052 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1053 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1054 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1055 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1056 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1057 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1058 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1059 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1060 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1061 67b631c9 2021-10-10 stsp
1062 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c master > $testroot/stdout)
1063 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1064 49c543a6 2022-03-31 naddy ret=$?
1065 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1066 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1067 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1068 67b631c9 2021-10-10 stsp return 1
1069 67b631c9 2021-10-10 stsp fi
1070 67b631c9 2021-10-10 stsp
1071 67b631c9 2021-10-10 stsp # same diff with explicit parent commit ID
1072 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c master \
1073 67b631c9 2021-10-10 stsp > $testroot/stdout)
1074 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1075 49c543a6 2022-03-31 naddy ret=$?
1076 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1077 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1078 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1079 67b631c9 2021-10-10 stsp return 1
1080 67b631c9 2021-10-10 stsp fi
1081 67b631c9 2021-10-10 stsp
1082 67b631c9 2021-10-10 stsp # same diff with commit object IDs
1083 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1084 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1085 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1086 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1087 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1088 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1089 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1090 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1091 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1092 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1093 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1094 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1095 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1096 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1097 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1098 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1099 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1100 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1101 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1102 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1103 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1104 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1105 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 \
1106 67b631c9 2021-10-10 stsp > $testroot/stdout)
1107 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1108 49c543a6 2022-03-31 naddy ret=$?
1109 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1110 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1111 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1112 67b631c9 2021-10-10 stsp return 1
1113 67b631c9 2021-10-10 stsp fi
1114 67b631c9 2021-10-10 stsp
1115 67b631c9 2021-10-10 stsp # same diff, filtered by paths
1116 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1117 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1118 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1119 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1120 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1121 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1122 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1123 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1124 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1125 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1126 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 alpha \
1127 67b631c9 2021-10-10 stsp > $testroot/stdout)
1128 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1129 49c543a6 2022-03-31 naddy ret=$?
1130 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1131 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1132 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1133 67b631c9 2021-10-10 stsp return 1
1134 67b631c9 2021-10-10 stsp fi
1135 67b631c9 2021-10-10 stsp # same in a work tree
1136 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 alpha \
1137 67b631c9 2021-10-10 stsp > $testroot/stdout)
1138 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1139 49c543a6 2022-03-31 naddy ret=$?
1140 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1141 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1142 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1143 67b631c9 2021-10-10 stsp return 1
1144 dffd0deb 2020-11-20 stsp fi
1145 67b631c9 2021-10-10 stsp
1146 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1147 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1148 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1149 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1150 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1151 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1152 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1153 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1154 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1155 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1156 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1157 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1158 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1159 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1160 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1161 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 \
1162 67b631c9 2021-10-10 stsp beta new > $testroot/stdout)
1163 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1164 49c543a6 2022-03-31 naddy ret=$?
1165 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1166 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1167 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1168 67b631c9 2021-10-10 stsp return 1
1169 67b631c9 2021-10-10 stsp fi
1170 67b631c9 2021-10-10 stsp
1171 67b631c9 2021-10-10 stsp # more than two -c options are not allowed
1172 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 -c foo \
1173 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1174 49c543a6 2022-03-31 naddy ret=$?
1175 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1176 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1177 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1178 67b631c9 2021-10-10 stsp return 1
1179 67b631c9 2021-10-10 stsp fi
1180 67b631c9 2021-10-10 stsp echo "got: too many -c options used" > $testroot/stderr.expected
1181 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1182 49c543a6 2022-03-31 naddy ret=$?
1183 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1184 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1185 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1186 67b631c9 2021-10-10 stsp return 1
1187 67b631c9 2021-10-10 stsp fi
1188 67b631c9 2021-10-10 stsp
1189 67b631c9 2021-10-10 stsp # use of -c options implies a repository diff; use with -P is an error
1190 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -P foo \
1191 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1192 49c543a6 2022-03-31 naddy ret=$?
1193 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1194 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1195 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1196 67b631c9 2021-10-10 stsp return 1
1197 67b631c9 2021-10-10 stsp fi
1198 67b631c9 2021-10-10 stsp echo "got: -P option can only be used when diffing a work tree" \
1199 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1200 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1201 49c543a6 2022-03-31 naddy ret=$?
1202 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1203 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1204 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1205 67b631c9 2021-10-10 stsp return 1
1206 67b631c9 2021-10-10 stsp fi
1207 67b631c9 2021-10-10 stsp
1208 67b631c9 2021-10-10 stsp # use of -c options implies a repository diff; use with -s is an error
1209 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -s foo \
1210 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1211 49c543a6 2022-03-31 naddy ret=$?
1212 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1213 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1214 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1215 67b631c9 2021-10-10 stsp return 1
1216 67b631c9 2021-10-10 stsp fi
1217 67b631c9 2021-10-10 stsp echo "got: -s option can only be used when diffing a work tree" \
1218 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1219 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1220 49c543a6 2022-03-31 naddy ret=$?
1221 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1222 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1223 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1224 67b631c9 2021-10-10 stsp return 1
1225 67b631c9 2021-10-10 stsp fi
1226 67b631c9 2021-10-10 stsp
1227 67b631c9 2021-10-10 stsp # three arguments imply use of path filtering (repository case)
1228 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff $commit_id0 $commit_id1 foo \
1229 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1230 49c543a6 2022-03-31 naddy ret=$?
1231 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1232 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1233 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1234 67b631c9 2021-10-10 stsp return 1
1235 67b631c9 2021-10-10 stsp fi
1236 67b631c9 2021-10-10 stsp echo "got: specified paths cannot be resolved: no got work tree found" \
1237 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1238 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1239 49c543a6 2022-03-31 naddy ret=$?
1240 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1241 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1242 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1243 67b631c9 2021-10-10 stsp return 1
1244 67b631c9 2021-10-10 stsp fi
1245 67b631c9 2021-10-10 stsp
1246 67b631c9 2021-10-10 stsp # three arguments imply use of path filtering (work tree case)
1247 10a623df 2021-10-11 stsp (cd $testroot/wt && got diff $commit_id0 master foo \
1248 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1249 49c543a6 2022-03-31 naddy ret=$?
1250 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1251 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1252 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1253 67b631c9 2021-10-10 stsp return 1
1254 67b631c9 2021-10-10 stsp fi
1255 67b631c9 2021-10-10 stsp echo "got: $commit_id0: No such file or directory" \
1256 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1257 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1258 49c543a6 2022-03-31 naddy ret=$?
1259 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1260 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1261 67b631c9 2021-10-10 stsp fi
1262 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
1263 39449a05 2020-07-23 stsp }
1264 39449a05 2020-07-23 stsp
1265 32b5305f 2022-02-12 op test_diff_ignored_file() {
1266 32b5305f 2022-02-12 op local testroot=`test_init diff_ignored_file`
1267 32b5305f 2022-02-12 op
1268 32b5305f 2022-02-12 op got checkout $testroot/repo $testroot/wt > /dev/null
1269 32b5305f 2022-02-12 op ret=$?
1270 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1271 32b5305f 2022-02-12 op test_done "$testroot" "$ret"
1272 32b5305f 2022-02-12 op return 1
1273 32b5305f 2022-02-12 op fi
1274 32b5305f 2022-02-12 op
1275 32b5305f 2022-02-12 op echo 1 > $testroot/wt/number
1276 32b5305f 2022-02-12 op (cd $testroot/wt && got add number >/dev/null)
1277 32b5305f 2022-02-12 op (cd $testroot/wt && got commit -m 'add number' >/dev/null)
1278 32b5305f 2022-02-12 op
1279 32b5305f 2022-02-12 op echo "**/number" > $testroot/wt/.gitignore
1280 32b5305f 2022-02-12 op
1281 32b5305f 2022-02-12 op echo 2 > $testroot/wt/number
1282 32b5305f 2022-02-12 op (cd $testroot/wt && got diff number | sed '1,/^@@/d' > $testroot/stdout)
1283 32b5305f 2022-02-12 op
1284 32b5305f 2022-02-12 op echo "-1" > $testroot/stdout.expected
1285 32b5305f 2022-02-12 op echo "+2" >> $testroot/stdout.expected
1286 32b5305f 2022-02-12 op
1287 32b5305f 2022-02-12 op cmp -s $testroot/stdout.expected $testroot/stdout
1288 32b5305f 2022-02-12 op ret=$?
1289 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1290 32b5305f 2022-02-12 op diff -u $testroot/stdout.expected $testroot/stdout
1291 32b5305f 2022-02-12 op fi
1292 32b5305f 2022-02-12 op test_done "$testroot" "$ret"
1293 32b5305f 2022-02-12 op }
1294 0543436d 2022-07-26 op
1295 0543436d 2022-07-26 op test_diff_crlf() {
1296 0543436d 2022-07-26 op local testroot=`test_init diff_crlf`
1297 0543436d 2022-07-26 op
1298 0543436d 2022-07-26 op got checkout $testroot/repo $testroot/wt > /dev/null
1299 0543436d 2022-07-26 op ret=$?
1300 0543436d 2022-07-26 op if [ $ret -ne 0 ]; then
1301 0543436d 2022-07-26 op test_done "$testroot" $ret
1302 0543436d 2022-07-26 op return 1
1303 0543436d 2022-07-26 op fi
1304 32b5305f 2022-02-12 op
1305 0543436d 2022-07-26 op printf 'test\r\n' > $testroot/wt/crlf
1306 0543436d 2022-07-26 op (cd $testroot/wt && got add crlf && got commit -m +crlf) >/dev/null
1307 0543436d 2022-07-26 op ret=$?
1308 0543436d 2022-07-26 op if [ $ret -ne 0 ]; then
1309 0543436d 2022-07-26 op test_done "$testroot" $ret
1310 0543436d 2022-07-26 op return 1
1311 0543436d 2022-07-26 op fi
1312 0543436d 2022-07-26 op
1313 0543436d 2022-07-26 op printf 'test 2\r\n' > $testroot/wt/crlf
1314 0543436d 2022-07-26 op (cd $testroot/wt && got diff | sed -n '/^---/,$p' > $testroot/stdout)
1315 0543436d 2022-07-26 op cat <<EOF > $testroot/stdout.expected
1316 0543436d 2022-07-26 op --- crlf
1317 0543436d 2022-07-26 op +++ crlf
1318 0543436d 2022-07-26 op @@ -1 +1 @@
1319 0543436d 2022-07-26 op -test
1320 0543436d 2022-07-26 op +test 2
1321 c87842d5 2022-09-23 mark EOF
1322 c87842d5 2022-09-23 mark
1323 c87842d5 2022-09-23 mark cmp -s $testroot/stdout.expected $testroot/stdout
1324 c87842d5 2022-09-23 mark ret=$?
1325 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1326 c87842d5 2022-09-23 mark diff -u $testroot/stdout.expected $testroot/stdout
1327 c87842d5 2022-09-23 mark fi
1328 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1329 c87842d5 2022-09-23 mark }
1330 c87842d5 2022-09-23 mark
1331 c87842d5 2022-09-23 mark test_diff_worktree_newfile_xbit() {
1332 c87842d5 2022-09-23 mark local testroot=`test_init diff_worktree_newfile_xbit`
1333 c87842d5 2022-09-23 mark
1334 c87842d5 2022-09-23 mark got checkout $testroot/repo $testroot/wt > /dev/null
1335 c87842d5 2022-09-23 mark ret=$?
1336 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1337 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1338 c87842d5 2022-09-23 mark return 1
1339 c87842d5 2022-09-23 mark fi
1340 c87842d5 2022-09-23 mark
1341 c87842d5 2022-09-23 mark echo xfile > $testroot/wt/xfile
1342 c87842d5 2022-09-23 mark chmod +x $testroot/wt/xfile
1343 c87842d5 2022-09-23 mark (cd $testroot/wt && got add xfile) > /dev/null
1344 c87842d5 2022-09-23 mark ret=$?
1345 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1346 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1347 c87842d5 2022-09-23 mark return 1
1348 c87842d5 2022-09-23 mark fi
1349 c87842d5 2022-09-23 mark (cd $testroot/wt && got diff) > $testroot/stdout
1350 c87842d5 2022-09-23 mark ret=$?
1351 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1352 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1353 c87842d5 2022-09-23 mark return 1
1354 c87842d5 2022-09-23 mark fi
1355 c87842d5 2022-09-23 mark
1356 c87842d5 2022-09-23 mark local commit_id=`git_show_head $testroot/repo`
1357 c87842d5 2022-09-23 mark cat <<EOF > $testroot/stdout.expected
1358 c87842d5 2022-09-23 mark diff $testroot/wt
1359 c87842d5 2022-09-23 mark commit - $commit_id
1360 c87842d5 2022-09-23 mark path + $testroot/wt
1361 c87842d5 2022-09-23 mark blob - /dev/null
1362 c87842d5 2022-09-23 mark file + xfile (mode 755)
1363 c87842d5 2022-09-23 mark --- /dev/null
1364 c87842d5 2022-09-23 mark +++ xfile
1365 c87842d5 2022-09-23 mark @@ -0,0 +1 @@
1366 c87842d5 2022-09-23 mark +xfile
1367 0543436d 2022-07-26 op EOF
1368 0543436d 2022-07-26 op
1369 0543436d 2022-07-26 op cmp -s $testroot/stdout.expected $testroot/stdout
1370 0543436d 2022-07-26 op ret=$?
1371 0543436d 2022-07-26 op if [ $ret -ne 0 ]; then
1372 c87842d5 2022-09-23 mark echo "failed to record mode 755"
1373 0543436d 2022-07-26 op diff -u $testroot/stdout.expected $testroot/stdout
1374 0543436d 2022-07-26 op fi
1375 0543436d 2022-07-26 op test_done "$testroot" $ret
1376 0543436d 2022-07-26 op }
1377 0543436d 2022-07-26 op
1378 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1379 95adcdca 2019-03-27 stsp run_test test_diff_basic
1380 95adcdca 2019-03-27 stsp run_test test_diff_shows_conflict
1381 d24820bf 2019-08-11 stsp run_test test_diff_tag
1382 562580bc 2020-01-14 stsp run_test test_diff_lightweight_tag
1383 63035f9f 2019-10-06 stsp run_test test_diff_ignore_whitespace
1384 e7303626 2020-05-14 stsp run_test test_diff_submodule_of_same_repo
1385 39449a05 2020-07-23 stsp run_test test_diff_symlinks_in_work_tree
1386 40dde666 2020-07-23 stsp run_test test_diff_symlinks_in_repo
1387 dffd0deb 2020-11-20 stsp run_test test_diff_binary_files
1388 67b631c9 2021-10-10 stsp run_test test_diff_commits
1389 32b5305f 2022-02-12 op run_test test_diff_ignored_file
1390 0543436d 2022-07-26 op run_test test_diff_crlf
1391 c87842d5 2022-09-23 mark run_test test_diff_worktree_newfile_xbit