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 885e96df 2023-03-06 naddy ed -s $testroot/repo/numbers <<-\EOF
447 885e96df 2023-03-06 naddy ,s/2/22/
448 885e96df 2023-03-06 naddy ,s/8/33/
449 885e96df 2023-03-06 naddy w
450 885e96df 2023-03-06 naddy EOF
451 95adcdca 2019-03-27 stsp git_commit $testroot/repo -m "modified line 2"
452 95adcdca 2019-03-27 stsp local head_rev=`git_show_head $testroot/repo`
453 95adcdca 2019-03-27 stsp
454 d136cfcb 2019-10-12 stsp # modify lines 2 and 8 in conflicting ways
455 885e96df 2023-03-06 naddy ed -s $testroot/wt/numbers <<-\EOF
456 885e96df 2023-03-06 naddy ,s/2/77/
457 885e96df 2023-03-06 naddy ,s/8/88/
458 885e96df 2023-03-06 naddy w
459 885e96df 2023-03-06 naddy EOF
460 95adcdca 2019-03-27 stsp
461 95adcdca 2019-03-27 stsp echo "C numbers" > $testroot/stdout.expected
462 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: $head_rev" \
463 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
464 95adcdca 2019-03-27 stsp echo >> $testroot/stdout.expected
465 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
466 95adcdca 2019-03-27 stsp
467 95adcdca 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
468 95adcdca 2019-03-27 stsp
469 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
470 49c543a6 2022-03-31 naddy ret=$?
471 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
472 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
473 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
474 95adcdca 2019-03-27 stsp return 1
475 95adcdca 2019-03-27 stsp fi
476 95adcdca 2019-03-27 stsp
477 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
478 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
479 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
480 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
481 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'numbers$' | cut -d' ' -f 1 \
482 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
483 95adcdca 2019-03-27 stsp echo 'file + numbers' >> $testroot/stdout.expected
484 95adcdca 2019-03-27 stsp echo '--- numbers' >> $testroot/stdout.expected
485 95adcdca 2019-03-27 stsp echo '+++ numbers' >> $testroot/stdout.expected
486 d136cfcb 2019-10-12 stsp echo '@@ -1,8 +1,20 @@' >> $testroot/stdout.expected
487 95adcdca 2019-03-27 stsp echo ' 1' >> $testroot/stdout.expected
488 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
489 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
490 95adcdca 2019-03-27 stsp echo ' 22' >> $testroot/stdout.expected
491 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
492 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
493 d136cfcb 2019-10-12 stsp echo '+2' >> $testroot/stdout.expected
494 95adcdca 2019-03-27 stsp echo '+=======' >> $testroot/stdout.expected
495 95adcdca 2019-03-27 stsp echo '+77' >> $testroot/stdout.expected
496 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
497 95adcdca 2019-03-27 stsp echo ' 3' >> $testroot/stdout.expected
498 95adcdca 2019-03-27 stsp echo ' 4' >> $testroot/stdout.expected
499 95adcdca 2019-03-27 stsp echo ' 5' >> $testroot/stdout.expected
500 d136cfcb 2019-10-12 stsp echo ' 6' >> $testroot/stdout.expected
501 d136cfcb 2019-10-12 stsp echo ' 7' >> $testroot/stdout.expected
502 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
503 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
504 d136cfcb 2019-10-12 stsp echo ' 33' >> $testroot/stdout.expected
505 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
506 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
507 d136cfcb 2019-10-12 stsp echo '+8' >> $testroot/stdout.expected
508 d136cfcb 2019-10-12 stsp echo '+=======' >> $testroot/stdout.expected
509 d136cfcb 2019-10-12 stsp echo '+88' >> $testroot/stdout.expected
510 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
511 95adcdca 2019-03-27 stsp
512 95adcdca 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
513 95adcdca 2019-03-27 stsp
514 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
515 49c543a6 2022-03-31 naddy ret=$?
516 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
517 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
518 95adcdca 2019-03-27 stsp fi
519 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
520 95adcdca 2019-03-27 stsp }
521 95adcdca 2019-03-27 stsp
522 f6cae3ed 2020-09-13 naddy test_diff_tag() {
523 d24820bf 2019-08-11 stsp local testroot=`test_init diff_tag`
524 d24820bf 2019-08-11 stsp local commit_id0=`git_show_head $testroot/repo`
525 d24820bf 2019-08-11 stsp local tag1=1.0.0
526 d24820bf 2019-08-11 stsp local tag2=2.0.0
527 d24820bf 2019-08-11 stsp
528 d24820bf 2019-08-11 stsp echo "modified alpha" > $testroot/repo/alpha
529 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "changed alpha"
530 d24820bf 2019-08-11 stsp local commit_id1=`git_show_head $testroot/repo`
531 d24820bf 2019-08-11 stsp
532 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag1)
533 d24820bf 2019-08-11 stsp
534 d24820bf 2019-08-11 stsp echo "new file" > $testroot/repo/new
535 d24820bf 2019-08-11 stsp (cd $testroot/repo && git add new)
536 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "new file"
537 d24820bf 2019-08-11 stsp local commit_id2=`git_show_head $testroot/repo`
538 d24820bf 2019-08-11 stsp
539 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag2)
540 562580bc 2020-01-14 stsp
541 562580bc 2020-01-14 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
542 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
543 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
544 562580bc 2020-01-14 stsp echo -n 'blob - ' >> $testroot/stdout.expected
545 562580bc 2020-01-14 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
546 562580bc 2020-01-14 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
547 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
548 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
549 562580bc 2020-01-14 stsp >> $testroot/stdout.expected
550 562580bc 2020-01-14 stsp echo '--- alpha' >> $testroot/stdout.expected
551 562580bc 2020-01-14 stsp echo '+++ alpha' >> $testroot/stdout.expected
552 562580bc 2020-01-14 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
553 562580bc 2020-01-14 stsp echo '-alpha' >> $testroot/stdout.expected
554 562580bc 2020-01-14 stsp echo '+modified alpha' >> $testroot/stdout.expected
555 562580bc 2020-01-14 stsp
556 562580bc 2020-01-14 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
557 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
558 49c543a6 2022-03-31 naddy ret=$?
559 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
560 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
561 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
562 562580bc 2020-01-14 stsp return 1
563 562580bc 2020-01-14 stsp fi
564 562580bc 2020-01-14 stsp
565 562580bc 2020-01-14 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
566 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
567 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
568 562580bc 2020-01-14 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
569 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
570 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
571 562580bc 2020-01-14 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
572 562580bc 2020-01-14 stsp echo " (mode 644)" >> $testroot/stdout.expected
573 562580bc 2020-01-14 stsp echo '--- /dev/null' >> $testroot/stdout.expected
574 562580bc 2020-01-14 stsp echo '+++ new' >> $testroot/stdout.expected
575 562580bc 2020-01-14 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
576 562580bc 2020-01-14 stsp echo '+new file' >> $testroot/stdout.expected
577 d24820bf 2019-08-11 stsp
578 562580bc 2020-01-14 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
579 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
580 49c543a6 2022-03-31 naddy ret=$?
581 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
582 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
583 562580bc 2020-01-14 stsp fi
584 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
585 562580bc 2020-01-14 stsp }
586 562580bc 2020-01-14 stsp
587 f6cae3ed 2020-09-13 naddy test_diff_lightweight_tag() {
588 562580bc 2020-01-14 stsp local testroot=`test_init diff_tag`
589 562580bc 2020-01-14 stsp local commit_id0=`git_show_head $testroot/repo`
590 562580bc 2020-01-14 stsp local tag1=1.0.0
591 562580bc 2020-01-14 stsp local tag2=2.0.0
592 562580bc 2020-01-14 stsp
593 562580bc 2020-01-14 stsp echo "modified alpha" > $testroot/repo/alpha
594 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "changed alpha"
595 562580bc 2020-01-14 stsp local commit_id1=`git_show_head $testroot/repo`
596 562580bc 2020-01-14 stsp
597 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag1)
598 562580bc 2020-01-14 stsp
599 562580bc 2020-01-14 stsp echo "new file" > $testroot/repo/new
600 562580bc 2020-01-14 stsp (cd $testroot/repo && git add new)
601 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "new file"
602 562580bc 2020-01-14 stsp local commit_id2=`git_show_head $testroot/repo`
603 562580bc 2020-01-14 stsp
604 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag2)
605 562580bc 2020-01-14 stsp
606 d24820bf 2019-08-11 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
607 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
608 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
609 d24820bf 2019-08-11 stsp echo -n 'blob - ' >> $testroot/stdout.expected
610 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
611 d24820bf 2019-08-11 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
612 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
613 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
614 d24820bf 2019-08-11 stsp >> $testroot/stdout.expected
615 d24820bf 2019-08-11 stsp echo '--- alpha' >> $testroot/stdout.expected
616 d24820bf 2019-08-11 stsp echo '+++ alpha' >> $testroot/stdout.expected
617 d24820bf 2019-08-11 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
618 d24820bf 2019-08-11 stsp echo '-alpha' >> $testroot/stdout.expected
619 d24820bf 2019-08-11 stsp echo '+modified alpha' >> $testroot/stdout.expected
620 d24820bf 2019-08-11 stsp
621 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
622 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
623 49c543a6 2022-03-31 naddy ret=$?
624 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
625 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
626 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
627 d24820bf 2019-08-11 stsp return 1
628 d24820bf 2019-08-11 stsp fi
629 d24820bf 2019-08-11 stsp
630 d24820bf 2019-08-11 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
631 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
632 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
633 d24820bf 2019-08-11 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
634 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
635 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
636 46f68b20 2019-10-19 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
637 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
638 d24820bf 2019-08-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
639 d24820bf 2019-08-11 stsp echo '+++ new' >> $testroot/stdout.expected
640 d24820bf 2019-08-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
641 d24820bf 2019-08-11 stsp echo '+new file' >> $testroot/stdout.expected
642 d24820bf 2019-08-11 stsp
643 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
644 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
645 49c543a6 2022-03-31 naddy ret=$?
646 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
647 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
648 d24820bf 2019-08-11 stsp fi
649 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
650 d24820bf 2019-08-11 stsp }
651 d24820bf 2019-08-11 stsp
652 f6cae3ed 2020-09-13 naddy test_diff_ignore_whitespace() {
653 63035f9f 2019-10-06 stsp local testroot=`test_init diff_ignore_whitespace`
654 63035f9f 2019-10-06 stsp local commit_id0=`git_show_head $testroot/repo`
655 63035f9f 2019-10-06 stsp
656 63035f9f 2019-10-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
657 49c543a6 2022-03-31 naddy ret=$?
658 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
659 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
660 63035f9f 2019-10-06 stsp return 1
661 63035f9f 2019-10-06 stsp fi
662 63035f9f 2019-10-06 stsp
663 63035f9f 2019-10-06 stsp echo "alpha " > $testroot/wt/alpha
664 63035f9f 2019-10-06 stsp
665 63035f9f 2019-10-06 stsp (cd $testroot/wt && got diff -w > $testroot/stdout)
666 63035f9f 2019-10-06 stsp
667 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
668 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
669 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
670 63035f9f 2019-10-06 stsp echo -n 'blob - ' >> $testroot/stdout.expected
671 63035f9f 2019-10-06 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
672 63035f9f 2019-10-06 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
673 63035f9f 2019-10-06 stsp echo 'file + alpha' >> $testroot/stdout.expected
674 63035f9f 2019-10-06 stsp
675 63035f9f 2019-10-06 stsp cmp -s $testroot/stdout.expected $testroot/stdout
676 49c543a6 2022-03-31 naddy ret=$?
677 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
678 63035f9f 2019-10-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
679 e7303626 2020-05-14 stsp fi
680 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
681 e7303626 2020-05-14 stsp }
682 e7303626 2020-05-14 stsp
683 f6cae3ed 2020-09-13 naddy test_diff_submodule_of_same_repo() {
684 e7303626 2020-05-14 stsp local testroot=`test_init diff_submodule_of_same_repo`
685 e7303626 2020-05-14 stsp
686 e7303626 2020-05-14 stsp (cd $testroot && git clone -q repo repo2 >/dev/null)
687 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
688 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
689 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
690 e7303626 2020-05-14 stsp
691 e7303626 2020-05-14 stsp epsilon_id=$(got tree -r $testroot/repo -i | grep 'epsilon/$' | \
692 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
693 e7303626 2020-05-14 stsp submodule_id=$(got tree -r $testroot/repo -i | grep 'repo2\$$' | \
694 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
695 e7303626 2020-05-14 stsp
696 e7303626 2020-05-14 stsp # Attempt a (nonsensical) diff between a tree object and a submodule.
697 e7303626 2020-05-14 stsp # Currently fails with "wrong type of object" error
698 e7303626 2020-05-14 stsp got diff -r $testroot/repo $epsilon_id $submodule_id \
699 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
700 49c543a6 2022-03-31 naddy ret=$?
701 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
702 e7303626 2020-05-14 stsp echo "diff command succeeded unexpectedly" >&2
703 e7303626 2020-05-14 stsp test_done "$testroot" "1"
704 e7303626 2020-05-14 stsp return 1
705 63035f9f 2019-10-06 stsp fi
706 e7303626 2020-05-14 stsp echo "got: wrong type of object" > $testroot/stderr.expected
707 e7303626 2020-05-14 stsp
708 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
709 49c543a6 2022-03-31 naddy ret=$?
710 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
711 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
712 e7303626 2020-05-14 stsp return 1
713 e7303626 2020-05-14 stsp fi
714 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
715 63035f9f 2019-10-06 stsp }
716 39449a05 2020-07-23 stsp
717 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_work_tree() {
718 39449a05 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_work_tree`
719 39449a05 2020-07-23 stsp
720 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
721 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
722 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
723 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
724 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
725 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
726 39449a05 2020-07-23 stsp (cd $testroot/repo && git add .)
727 39449a05 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
728 39449a05 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
729 39449a05 2020-07-23 stsp
730 39449a05 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
731 49c543a6 2022-03-31 naddy ret=$?
732 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
733 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
734 39449a05 2020-07-23 stsp return 1
735 39449a05 2020-07-23 stsp fi
736 39449a05 2020-07-23 stsp
737 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
738 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon.link && ln -s gamma epsilon.link)
739 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
740 39449a05 2020-07-23 stsp echo -n '.got/bar' > $testroot/wt/dotgotfoo.link
741 39449a05 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
742 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf epsilon/zeta zeta.link)
743 39449a05 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
744 39449a05 2020-07-23 stsp (cd $testroot/wt && got diff > $testroot/stdout)
745 63035f9f 2019-10-06 stsp
746 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
747 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
748 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
749 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
750 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
751 39449a05 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
752 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
753 39449a05 2020-07-23 stsp echo 'file + alpha.link' >> $testroot/stdout.expected
754 39449a05 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
755 39449a05 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
756 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
757 39449a05 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
758 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
759 39449a05 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
760 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
761 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
762 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
763 39449a05 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
764 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
765 39449a05 2020-07-23 stsp echo 'file + dotgotfoo.link' >> $testroot/stdout.expected
766 39449a05 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
767 39449a05 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
768 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
769 39449a05 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
770 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
771 39449a05 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
772 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
773 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
774 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
775 39449a05 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
776 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
777 39449a05 2020-07-23 stsp echo 'file + epsilon/beta.link' >> $testroot/stdout.expected
778 39449a05 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
779 39449a05 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
780 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
781 39449a05 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
782 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
783 39449a05 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
784 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
785 4135d7d0 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
786 4135d7d0 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
787 4135d7d0 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
788 4135d7d0 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
789 4135d7d0 2020-07-23 stsp echo 'file + epsilon.link' >> $testroot/stdout.expected
790 4135d7d0 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
791 4135d7d0 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
792 4135d7d0 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
793 4135d7d0 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
794 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
795 4135d7d0 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
796 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
797 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
798 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
799 39449a05 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
800 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
801 39449a05 2020-07-23 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
802 39449a05 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
803 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
804 39449a05 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
805 39449a05 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
806 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
807 39449a05 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
808 c87842d5 2022-09-23 mark echo 'file + zeta.link (mode 120000)' >> $testroot/stdout.expected
809 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
810 40dde666 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
811 40dde666 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
812 40dde666 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
813 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
814 40dde666 2020-07-23 stsp
815 40dde666 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
816 49c543a6 2022-03-31 naddy ret=$?
817 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
818 40dde666 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
819 40dde666 2020-07-23 stsp fi
820 40dde666 2020-07-23 stsp test_done "$testroot" "$ret"
821 40dde666 2020-07-23 stsp }
822 40dde666 2020-07-23 stsp
823 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_repo() {
824 40dde666 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_repo`
825 40dde666 2020-07-23 stsp
826 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
827 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
828 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
829 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
830 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
831 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
832 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
833 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
834 40dde666 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
835 40dde666 2020-07-23 stsp
836 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
837 f55db25a 2023-03-03 naddy (cd $testroot/repo && rm epsilon.link && ln -s gamma epsilon.link)
838 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
839 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar $testroot/repo/dotgotfoo.link)
840 40dde666 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
841 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
842 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
843 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
844 40dde666 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
845 40dde666 2020-07-23 stsp
846 40dde666 2020-07-23 stsp got diff -r $testroot/repo $commit_id1 $commit_id2 > $testroot/stdout
847 40dde666 2020-07-23 stsp
848 40dde666 2020-07-23 stsp echo "diff $commit_id1 $commit_id2" > $testroot/stdout.expected
849 8469d821 2022-06-25 stsp echo "commit - $commit_id1" >> $testroot/stdout.expected
850 8469d821 2022-06-25 stsp echo "commit + $commit_id2" >> $testroot/stdout.expected
851 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
852 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
853 40dde666 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
854 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
855 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
856 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
857 40dde666 2020-07-23 stsp grep 'alpha.link@ -> beta$' | \
858 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
859 40dde666 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
860 40dde666 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
861 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
862 40dde666 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
863 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
864 40dde666 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
865 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
866 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
867 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
868 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
869 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
870 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
871 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
872 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/bar$' | \
873 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
874 40dde666 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
875 40dde666 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
876 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
877 40dde666 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
878 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
879 40dde666 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
880 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
881 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
882 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
883 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
884 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
885 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
886 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i epsilon | \
887 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../gamma/delta$' | \
888 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
889 40dde666 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
890 40dde666 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
891 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
892 40dde666 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
893 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
894 40dde666 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
895 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
896 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
897 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
898 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
899 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
900 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
901 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
902 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> gamma$' | \
903 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
904 40dde666 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
905 40dde666 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
906 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
907 40dde666 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
908 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
909 40dde666 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
910 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
911 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
912 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
913 40dde666 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
914 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
915 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
916 40dde666 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
917 40dde666 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
918 40dde666 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
919 40dde666 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
920 40dde666 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
921 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
922 40dde666 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
923 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
924 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
925 40dde666 2020-07-23 stsp grep 'zeta.link@ -> epsilon/zeta$' | \
926 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
927 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
928 40dde666 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
929 39449a05 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
930 39449a05 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
931 39449a05 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
932 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
933 39449a05 2020-07-23 stsp
934 39449a05 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
935 49c543a6 2022-03-31 naddy ret=$?
936 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
937 39449a05 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
938 dffd0deb 2020-11-20 stsp fi
939 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
940 dffd0deb 2020-11-20 stsp }
941 dffd0deb 2020-11-20 stsp
942 dffd0deb 2020-11-20 stsp test_diff_binary_files() {
943 dffd0deb 2020-11-20 stsp local testroot=`test_init diff_binary_files`
944 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
945 dffd0deb 2020-11-20 stsp
946 dffd0deb 2020-11-20 stsp got checkout $testroot/repo $testroot/wt > /dev/null
947 49c543a6 2022-03-31 naddy ret=$?
948 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
949 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
950 dffd0deb 2020-11-20 stsp return 1
951 dffd0deb 2020-11-20 stsp fi
952 dffd0deb 2020-11-20 stsp
953 dffd0deb 2020-11-20 stsp printf '\377\377\0\0\377\377\0\0' > $testroot/wt/foo
954 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got add foo >/dev/null)
955 64453f7e 2020-11-21 stsp
956 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
957 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
958 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
959 64453f7e 2020-11-21 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
960 c87842d5 2022-09-23 mark echo 'file + foo (mode 644)' >> $testroot/stdout.expected
961 1cb46f00 2020-11-21 stsp echo "Binary files /dev/null and foo differ" \
962 1cb46f00 2020-11-21 stsp >> $testroot/stdout.expected
963 64453f7e 2020-11-21 stsp
964 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff > $testroot/stdout)
965 64453f7e 2020-11-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
966 49c543a6 2022-03-31 naddy ret=$?
967 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
968 64453f7e 2020-11-21 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
969 64453f7e 2020-11-21 stsp test_done "$testroot" "$ret"
970 64453f7e 2020-11-21 stsp return 1
971 64453f7e 2020-11-21 stsp fi
972 dffd0deb 2020-11-20 stsp
973 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
974 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
975 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
976 dffd0deb 2020-11-20 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
977 c87842d5 2022-09-23 mark echo 'file + foo (mode 644)' >> $testroot/stdout.expected
978 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
979 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
980 dffd0deb 2020-11-20 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
981 dffd0deb 2020-11-20 stsp printf '+\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
982 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
983 dffd0deb 2020-11-20 stsp
984 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
985 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
986 49c543a6 2022-03-31 naddy ret=$?
987 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
988 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
989 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
990 dffd0deb 2020-11-20 stsp return 1
991 39449a05 2020-07-23 stsp fi
992 dffd0deb 2020-11-20 stsp
993 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
994 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
995 dffd0deb 2020-11-20 stsp
996 dffd0deb 2020-11-20 stsp printf '\377\200\0\0\377\200\0\0' > $testroot/wt/foo
997 dffd0deb 2020-11-20 stsp
998 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
999 8469d821 2022-06-25 stsp echo "commit - $head_rev" >> $testroot/stdout.expected
1000 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
1001 dffd0deb 2020-11-20 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1002 dffd0deb 2020-11-20 stsp got tree -r $testroot/repo -i | grep 'foo$' | cut -d' ' -f 1 \
1003 dffd0deb 2020-11-20 stsp >> $testroot/stdout.expected
1004 dffd0deb 2020-11-20 stsp echo 'file + foo' >> $testroot/stdout.expected
1005 dffd0deb 2020-11-20 stsp echo '--- foo' >> $testroot/stdout.expected
1006 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
1007 dffd0deb 2020-11-20 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1008 578133c9 2020-11-28 naddy printf -- '-\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
1009 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
1010 dffd0deb 2020-11-20 stsp printf '+\377\200\0\0\377\200\0\0\n' >> $testroot/stdout.expected
1011 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
1012 dffd0deb 2020-11-20 stsp
1013 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
1014 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1015 49c543a6 2022-03-31 naddy ret=$?
1016 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1017 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
1018 67b631c9 2021-10-10 stsp fi
1019 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1020 67b631c9 2021-10-10 stsp }
1021 67b631c9 2021-10-10 stsp
1022 67b631c9 2021-10-10 stsp test_diff_commits() {
1023 67b631c9 2021-10-10 stsp local testroot=`test_init diff_commits`
1024 67b631c9 2021-10-10 stsp local commit_id0=`git_show_head $testroot/repo`
1025 6b37f13a 2023-01-10 mark local alpha_id0=`get_blob_id $testroot/repo "" alpha`
1026 6b37f13a 2023-01-10 mark local beta_id0=`get_blob_id $testroot/repo "" beta`
1027 67b631c9 2021-10-10 stsp
1028 67b631c9 2021-10-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1029 49c543a6 2022-03-31 naddy ret=$?
1030 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1031 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1032 67b631c9 2021-10-10 stsp return 1
1033 67b631c9 2021-10-10 stsp fi
1034 67b631c9 2021-10-10 stsp
1035 67b631c9 2021-10-10 stsp echo "modified alpha" > $testroot/wt/alpha
1036 67b631c9 2021-10-10 stsp (cd $testroot/wt && got rm beta >/dev/null)
1037 67b631c9 2021-10-10 stsp echo "new file" > $testroot/wt/new
1038 67b631c9 2021-10-10 stsp (cd $testroot/wt && got add new >/dev/null)
1039 67b631c9 2021-10-10 stsp (cd $testroot/wt && got commit -m 'committing changes' >/dev/null)
1040 67b631c9 2021-10-10 stsp local commit_id1=`git_show_head $testroot/repo`
1041 67b631c9 2021-10-10 stsp
1042 67b631c9 2021-10-10 stsp alpha_id1=`get_blob_id $testroot/repo "" alpha`
1043 67b631c9 2021-10-10 stsp new_id1=`get_blob_id $testroot/repo "" new`
1044 67b631c9 2021-10-10 stsp
1045 67b631c9 2021-10-10 stsp echo "diff $commit_id0 refs/heads/master" > $testroot/stdout.expected
1046 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1047 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1048 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1049 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1050 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1051 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1052 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1053 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1054 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1055 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1056 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1057 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1058 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1059 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1060 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1061 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1062 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1063 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1064 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1065 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1066 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1067 67b631c9 2021-10-10 stsp
1068 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c master > $testroot/stdout)
1069 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1070 49c543a6 2022-03-31 naddy ret=$?
1071 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1072 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1073 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1074 67b631c9 2021-10-10 stsp return 1
1075 67b631c9 2021-10-10 stsp fi
1076 67b631c9 2021-10-10 stsp
1077 67b631c9 2021-10-10 stsp # same diff with explicit parent commit ID
1078 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c master \
1079 67b631c9 2021-10-10 stsp > $testroot/stdout)
1080 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1081 49c543a6 2022-03-31 naddy ret=$?
1082 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1083 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1084 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1085 67b631c9 2021-10-10 stsp return 1
1086 67b631c9 2021-10-10 stsp fi
1087 67b631c9 2021-10-10 stsp
1088 67b631c9 2021-10-10 stsp # same diff with commit object IDs
1089 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1090 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1091 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1092 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1093 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1094 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1095 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1096 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1097 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1098 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1099 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1100 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1101 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1102 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1103 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1104 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1105 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1106 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1107 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1108 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1109 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1110 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1111 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 \
1112 67b631c9 2021-10-10 stsp > $testroot/stdout)
1113 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1114 49c543a6 2022-03-31 naddy ret=$?
1115 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1116 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1117 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1118 67b631c9 2021-10-10 stsp return 1
1119 67b631c9 2021-10-10 stsp fi
1120 67b631c9 2021-10-10 stsp
1121 67b631c9 2021-10-10 stsp # same diff, filtered by paths
1122 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1123 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1124 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1125 67b631c9 2021-10-10 stsp echo "blob - $alpha_id0" >> $testroot/stdout.expected
1126 67b631c9 2021-10-10 stsp echo "blob + $alpha_id1" >> $testroot/stdout.expected
1127 67b631c9 2021-10-10 stsp echo '--- alpha' >> $testroot/stdout.expected
1128 67b631c9 2021-10-10 stsp echo '+++ alpha' >> $testroot/stdout.expected
1129 67b631c9 2021-10-10 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1130 67b631c9 2021-10-10 stsp echo '-alpha' >> $testroot/stdout.expected
1131 67b631c9 2021-10-10 stsp echo '+modified alpha' >> $testroot/stdout.expected
1132 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 alpha \
1133 67b631c9 2021-10-10 stsp > $testroot/stdout)
1134 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1135 49c543a6 2022-03-31 naddy ret=$?
1136 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1137 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1138 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1139 67b631c9 2021-10-10 stsp return 1
1140 67b631c9 2021-10-10 stsp fi
1141 67b631c9 2021-10-10 stsp # same in a work tree
1142 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 alpha \
1143 67b631c9 2021-10-10 stsp > $testroot/stdout)
1144 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1145 49c543a6 2022-03-31 naddy ret=$?
1146 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1147 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1148 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1149 67b631c9 2021-10-10 stsp return 1
1150 dffd0deb 2020-11-20 stsp fi
1151 67b631c9 2021-10-10 stsp
1152 67b631c9 2021-10-10 stsp echo "diff $commit_id0 $commit_id1" > $testroot/stdout.expected
1153 8469d821 2022-06-25 stsp echo "commit - $commit_id0" >> $testroot/stdout.expected
1154 8469d821 2022-06-25 stsp echo "commit + $commit_id1" >> $testroot/stdout.expected
1155 67b631c9 2021-10-10 stsp echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1156 67b631c9 2021-10-10 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
1157 67b631c9 2021-10-10 stsp echo '--- beta' >> $testroot/stdout.expected
1158 67b631c9 2021-10-10 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1159 67b631c9 2021-10-10 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1160 67b631c9 2021-10-10 stsp echo '-beta' >> $testroot/stdout.expected
1161 67b631c9 2021-10-10 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
1162 67b631c9 2021-10-10 stsp echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1163 67b631c9 2021-10-10 stsp echo '--- /dev/null' >> $testroot/stdout.expected
1164 67b631c9 2021-10-10 stsp echo '+++ new' >> $testroot/stdout.expected
1165 67b631c9 2021-10-10 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1166 67b631c9 2021-10-10 stsp echo '+new file' >> $testroot/stdout.expected
1167 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 \
1168 67b631c9 2021-10-10 stsp beta new > $testroot/stdout)
1169 67b631c9 2021-10-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1170 49c543a6 2022-03-31 naddy ret=$?
1171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1172 67b631c9 2021-10-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1173 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1174 67b631c9 2021-10-10 stsp return 1
1175 67b631c9 2021-10-10 stsp fi
1176 67b631c9 2021-10-10 stsp
1177 67b631c9 2021-10-10 stsp # more than two -c options are not allowed
1178 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff -c $commit_id0 -c $commit_id1 -c foo \
1179 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1180 49c543a6 2022-03-31 naddy ret=$?
1181 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1182 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1183 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1184 67b631c9 2021-10-10 stsp return 1
1185 67b631c9 2021-10-10 stsp fi
1186 67b631c9 2021-10-10 stsp echo "got: too many -c options used" > $testroot/stderr.expected
1187 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1188 49c543a6 2022-03-31 naddy ret=$?
1189 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1190 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1191 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1192 67b631c9 2021-10-10 stsp return 1
1193 67b631c9 2021-10-10 stsp fi
1194 67b631c9 2021-10-10 stsp
1195 67b631c9 2021-10-10 stsp # use of -c options implies a repository diff; use with -P is an error
1196 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -P foo \
1197 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1198 49c543a6 2022-03-31 naddy ret=$?
1199 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1200 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1201 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1202 67b631c9 2021-10-10 stsp return 1
1203 67b631c9 2021-10-10 stsp fi
1204 67b631c9 2021-10-10 stsp echo "got: -P option can only be used when diffing a work tree" \
1205 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1206 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1207 49c543a6 2022-03-31 naddy ret=$?
1208 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1209 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1210 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1211 67b631c9 2021-10-10 stsp return 1
1212 67b631c9 2021-10-10 stsp fi
1213 67b631c9 2021-10-10 stsp
1214 67b631c9 2021-10-10 stsp # use of -c options implies a repository diff; use with -s is an error
1215 67b631c9 2021-10-10 stsp (cd $testroot/wt && got diff -c $commit_id0 -c $commit_id1 -s foo \
1216 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1217 49c543a6 2022-03-31 naddy ret=$?
1218 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1219 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1220 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1221 67b631c9 2021-10-10 stsp return 1
1222 67b631c9 2021-10-10 stsp fi
1223 67b631c9 2021-10-10 stsp echo "got: -s option can only be used when diffing a work tree" \
1224 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1225 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1226 49c543a6 2022-03-31 naddy ret=$?
1227 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1228 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1229 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1230 67b631c9 2021-10-10 stsp return 1
1231 67b631c9 2021-10-10 stsp fi
1232 67b631c9 2021-10-10 stsp
1233 67b631c9 2021-10-10 stsp # three arguments imply use of path filtering (repository case)
1234 67b631c9 2021-10-10 stsp (cd $testroot/repo && got diff $commit_id0 $commit_id1 foo \
1235 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1236 49c543a6 2022-03-31 naddy ret=$?
1237 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1238 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1239 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1240 67b631c9 2021-10-10 stsp return 1
1241 67b631c9 2021-10-10 stsp fi
1242 67b631c9 2021-10-10 stsp echo "got: specified paths cannot be resolved: no got work tree found" \
1243 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1244 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1245 49c543a6 2022-03-31 naddy ret=$?
1246 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1247 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1248 67b631c9 2021-10-10 stsp test_done "$testroot" "$ret"
1249 67b631c9 2021-10-10 stsp return 1
1250 67b631c9 2021-10-10 stsp fi
1251 67b631c9 2021-10-10 stsp
1252 67b631c9 2021-10-10 stsp # three arguments imply use of path filtering (work tree case)
1253 10a623df 2021-10-11 stsp (cd $testroot/wt && got diff $commit_id0 master foo \
1254 67b631c9 2021-10-10 stsp 2> $testroot/stderr)
1255 49c543a6 2022-03-31 naddy ret=$?
1256 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1257 67b631c9 2021-10-10 stsp echo "diff succeeded unexpectedly" >&2
1258 67b631c9 2021-10-10 stsp test_done "$testroot" "1"
1259 67b631c9 2021-10-10 stsp return 1
1260 67b631c9 2021-10-10 stsp fi
1261 67b631c9 2021-10-10 stsp echo "got: $commit_id0: No such file or directory" \
1262 67b631c9 2021-10-10 stsp > $testroot/stderr.expected
1263 67b631c9 2021-10-10 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1264 49c543a6 2022-03-31 naddy ret=$?
1265 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1266 67b631c9 2021-10-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
1267 67b631c9 2021-10-10 stsp fi
1268 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
1269 39449a05 2020-07-23 stsp }
1270 39449a05 2020-07-23 stsp
1271 32b5305f 2022-02-12 op test_diff_ignored_file() {
1272 32b5305f 2022-02-12 op local testroot=`test_init diff_ignored_file`
1273 32b5305f 2022-02-12 op
1274 32b5305f 2022-02-12 op got checkout $testroot/repo $testroot/wt > /dev/null
1275 32b5305f 2022-02-12 op ret=$?
1276 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1277 32b5305f 2022-02-12 op test_done "$testroot" "$ret"
1278 32b5305f 2022-02-12 op return 1
1279 32b5305f 2022-02-12 op fi
1280 32b5305f 2022-02-12 op
1281 32b5305f 2022-02-12 op echo 1 > $testroot/wt/number
1282 32b5305f 2022-02-12 op (cd $testroot/wt && got add number >/dev/null)
1283 32b5305f 2022-02-12 op (cd $testroot/wt && got commit -m 'add number' >/dev/null)
1284 32b5305f 2022-02-12 op
1285 32b5305f 2022-02-12 op echo "**/number" > $testroot/wt/.gitignore
1286 32b5305f 2022-02-12 op
1287 32b5305f 2022-02-12 op echo 2 > $testroot/wt/number
1288 32b5305f 2022-02-12 op (cd $testroot/wt && got diff number | sed '1,/^@@/d' > $testroot/stdout)
1289 32b5305f 2022-02-12 op
1290 32b5305f 2022-02-12 op echo "-1" > $testroot/stdout.expected
1291 32b5305f 2022-02-12 op echo "+2" >> $testroot/stdout.expected
1292 32b5305f 2022-02-12 op
1293 32b5305f 2022-02-12 op cmp -s $testroot/stdout.expected $testroot/stdout
1294 32b5305f 2022-02-12 op ret=$?
1295 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1296 32b5305f 2022-02-12 op diff -u $testroot/stdout.expected $testroot/stdout
1297 32b5305f 2022-02-12 op fi
1298 32b5305f 2022-02-12 op test_done "$testroot" "$ret"
1299 32b5305f 2022-02-12 op }
1300 0543436d 2022-07-26 op
1301 0543436d 2022-07-26 op test_diff_crlf() {
1302 0543436d 2022-07-26 op local testroot=`test_init diff_crlf`
1303 0543436d 2022-07-26 op
1304 0543436d 2022-07-26 op got checkout $testroot/repo $testroot/wt > /dev/null
1305 0543436d 2022-07-26 op ret=$?
1306 0543436d 2022-07-26 op if [ $ret -ne 0 ]; then
1307 0543436d 2022-07-26 op test_done "$testroot" $ret
1308 0543436d 2022-07-26 op return 1
1309 0543436d 2022-07-26 op fi
1310 32b5305f 2022-02-12 op
1311 ba0bed23 2023-05-11 naddy printf 'one\r\ntwo\r\nthree\r\n' > $testroot/wt/crlf
1312 0543436d 2022-07-26 op (cd $testroot/wt && got add crlf && got commit -m +crlf) >/dev/null
1313 0543436d 2022-07-26 op ret=$?
1314 0543436d 2022-07-26 op if [ $ret -ne 0 ]; then
1315 0543436d 2022-07-26 op test_done "$testroot" $ret
1316 0543436d 2022-07-26 op return 1
1317 0543436d 2022-07-26 op fi
1318 0543436d 2022-07-26 op
1319 ba0bed23 2023-05-11 naddy printf 'one\r\ntwain\r\nthree\r\n' > $testroot/wt/crlf
1320 ba0bed23 2023-05-11 naddy (cd $testroot/wt && got diff | sed -n '/^---/,$l' > $testroot/stdout)
1321 ba0bed23 2023-05-11 naddy cat <<\EOF > $testroot/stdout.expected
1322 ba0bed23 2023-05-11 naddy --- crlf$
1323 ba0bed23 2023-05-11 naddy +++ crlf$
1324 ba0bed23 2023-05-11 naddy @@ -1,3 +1,3 @@$
1325 ba0bed23 2023-05-11 naddy one\r$
1326 ba0bed23 2023-05-11 naddy -two\r$
1327 ba0bed23 2023-05-11 naddy +twain\r$
1328 ba0bed23 2023-05-11 naddy three\r$
1329 c87842d5 2022-09-23 mark EOF
1330 c87842d5 2022-09-23 mark
1331 c87842d5 2022-09-23 mark cmp -s $testroot/stdout.expected $testroot/stdout
1332 c87842d5 2022-09-23 mark ret=$?
1333 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1334 c87842d5 2022-09-23 mark diff -u $testroot/stdout.expected $testroot/stdout
1335 c87842d5 2022-09-23 mark fi
1336 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1337 c87842d5 2022-09-23 mark }
1338 c87842d5 2022-09-23 mark
1339 c87842d5 2022-09-23 mark test_diff_worktree_newfile_xbit() {
1340 c87842d5 2022-09-23 mark local testroot=`test_init diff_worktree_newfile_xbit`
1341 c87842d5 2022-09-23 mark
1342 c87842d5 2022-09-23 mark got checkout $testroot/repo $testroot/wt > /dev/null
1343 c87842d5 2022-09-23 mark ret=$?
1344 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1345 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1346 c87842d5 2022-09-23 mark return 1
1347 c87842d5 2022-09-23 mark fi
1348 c87842d5 2022-09-23 mark
1349 c87842d5 2022-09-23 mark echo xfile > $testroot/wt/xfile
1350 c87842d5 2022-09-23 mark chmod +x $testroot/wt/xfile
1351 c87842d5 2022-09-23 mark (cd $testroot/wt && got add xfile) > /dev/null
1352 c87842d5 2022-09-23 mark ret=$?
1353 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1354 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1355 c87842d5 2022-09-23 mark return 1
1356 c87842d5 2022-09-23 mark fi
1357 c87842d5 2022-09-23 mark (cd $testroot/wt && got diff) > $testroot/stdout
1358 c87842d5 2022-09-23 mark ret=$?
1359 c87842d5 2022-09-23 mark if [ $ret -ne 0 ]; then
1360 c87842d5 2022-09-23 mark test_done "$testroot" $ret
1361 c87842d5 2022-09-23 mark return 1
1362 c87842d5 2022-09-23 mark fi
1363 c87842d5 2022-09-23 mark
1364 c87842d5 2022-09-23 mark local commit_id=`git_show_head $testroot/repo`
1365 c87842d5 2022-09-23 mark cat <<EOF > $testroot/stdout.expected
1366 c87842d5 2022-09-23 mark diff $testroot/wt
1367 c87842d5 2022-09-23 mark commit - $commit_id
1368 c87842d5 2022-09-23 mark path + $testroot/wt
1369 c87842d5 2022-09-23 mark blob - /dev/null
1370 c87842d5 2022-09-23 mark file + xfile (mode 755)
1371 c87842d5 2022-09-23 mark --- /dev/null
1372 c87842d5 2022-09-23 mark +++ xfile
1373 c87842d5 2022-09-23 mark @@ -0,0 +1 @@
1374 c87842d5 2022-09-23 mark +xfile
1375 0543436d 2022-07-26 op EOF
1376 0543436d 2022-07-26 op
1377 0543436d 2022-07-26 op cmp -s $testroot/stdout.expected $testroot/stdout
1378 0543436d 2022-07-26 op ret=$?
1379 0543436d 2022-07-26 op if [ $ret -ne 0 ]; then
1380 c87842d5 2022-09-23 mark echo "failed to record mode 755"
1381 0543436d 2022-07-26 op diff -u $testroot/stdout.expected $testroot/stdout
1382 0543436d 2022-07-26 op fi
1383 0543436d 2022-07-26 op test_done "$testroot" $ret
1384 6b37f13a 2023-01-10 mark }
1385 6b37f13a 2023-01-10 mark
1386 6b37f13a 2023-01-10 mark test_diff_commit_diffstat() {
1387 6b37f13a 2023-01-10 mark local testroot=`test_init diff_commit_diffstat`
1388 6b37f13a 2023-01-10 mark local commit_id0=`git_show_head $testroot/repo`
1389 6b37f13a 2023-01-10 mark local alpha_id0=`get_blob_id $testroot/repo "" alpha`
1390 6b37f13a 2023-01-10 mark local beta_id0=`get_blob_id $testroot/repo "" beta`
1391 6b37f13a 2023-01-10 mark
1392 6b37f13a 2023-01-10 mark got checkout $testroot/repo $testroot/wt > /dev/null
1393 6b37f13a 2023-01-10 mark ret=$?
1394 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1395 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1396 6b37f13a 2023-01-10 mark return 1
1397 6b37f13a 2023-01-10 mark fi
1398 6b37f13a 2023-01-10 mark
1399 6b37f13a 2023-01-10 mark echo "modified alpha" > $testroot/wt/alpha
1400 6b37f13a 2023-01-10 mark (cd $testroot/wt && got rm beta >/dev/null)
1401 6b37f13a 2023-01-10 mark echo "new file" > $testroot/wt/new
1402 6b37f13a 2023-01-10 mark (cd $testroot/wt && got add new >/dev/null)
1403 6b37f13a 2023-01-10 mark (cd $testroot/wt && got commit -m 'committing changes' >/dev/null)
1404 6b37f13a 2023-01-10 mark local commit_id1=`git_show_head $testroot/repo`
1405 6b37f13a 2023-01-10 mark
1406 34d80a0f 2023-01-10 op local alpha_id1=`get_blob_id $testroot/repo "" alpha`
1407 34d80a0f 2023-01-10 op local new_id1=`get_blob_id $testroot/repo "" new`
1408 6b37f13a 2023-01-10 mark
1409 6b37f13a 2023-01-10 mark cat <<EOF >$testroot/stdout.expected
1410 6b37f13a 2023-01-10 mark diffstat $commit_id0 refs/heads/master
1411 6b37f13a 2023-01-10 mark M alpha | 1+ 1-
1412 6b37f13a 2023-01-10 mark D beta | 0+ 1-
1413 6b37f13a 2023-01-10 mark A new | 1+ 0-
1414 6b37f13a 2023-01-10 mark
1415 6b37f13a 2023-01-10 mark 3 files changed, 2 insertions(+), 2 deletions(-)
1416 6b37f13a 2023-01-10 mark
1417 6b37f13a 2023-01-10 mark EOF
1418 6b37f13a 2023-01-10 mark
1419 6b37f13a 2023-01-10 mark echo "diff $commit_id0 refs/heads/master" >> $testroot/stdout.expected
1420 6b37f13a 2023-01-10 mark echo "commit - $commit_id0" >> $testroot/stdout.expected
1421 6b37f13a 2023-01-10 mark echo "commit + $commit_id1" >> $testroot/stdout.expected
1422 6b37f13a 2023-01-10 mark echo "blob - $alpha_id0" >> $testroot/stdout.expected
1423 6b37f13a 2023-01-10 mark echo "blob + $alpha_id1" >> $testroot/stdout.expected
1424 6b37f13a 2023-01-10 mark echo '--- alpha' >> $testroot/stdout.expected
1425 6b37f13a 2023-01-10 mark echo '+++ alpha' >> $testroot/stdout.expected
1426 6b37f13a 2023-01-10 mark echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1427 6b37f13a 2023-01-10 mark echo '-alpha' >> $testroot/stdout.expected
1428 6b37f13a 2023-01-10 mark echo '+modified alpha' >> $testroot/stdout.expected
1429 6b37f13a 2023-01-10 mark echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1430 6b37f13a 2023-01-10 mark echo 'blob + /dev/null' >> $testroot/stdout.expected
1431 6b37f13a 2023-01-10 mark echo '--- beta' >> $testroot/stdout.expected
1432 6b37f13a 2023-01-10 mark echo '+++ /dev/null' >> $testroot/stdout.expected
1433 6b37f13a 2023-01-10 mark echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1434 6b37f13a 2023-01-10 mark echo '-beta' >> $testroot/stdout.expected
1435 6b37f13a 2023-01-10 mark echo 'blob - /dev/null' >> $testroot/stdout.expected
1436 6b37f13a 2023-01-10 mark echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1437 6b37f13a 2023-01-10 mark echo '--- /dev/null' >> $testroot/stdout.expected
1438 6b37f13a 2023-01-10 mark echo '+++ new' >> $testroot/stdout.expected
1439 6b37f13a 2023-01-10 mark echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1440 6b37f13a 2023-01-10 mark echo '+new file' >> $testroot/stdout.expected
1441 6b37f13a 2023-01-10 mark
1442 6b37f13a 2023-01-10 mark (cd $testroot/wt && got diff -d -c master > $testroot/stdout)
1443 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1444 6b37f13a 2023-01-10 mark ret=$?
1445 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1446 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1447 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1448 6b37f13a 2023-01-10 mark return 1
1449 6b37f13a 2023-01-10 mark fi
1450 6b37f13a 2023-01-10 mark
1451 6b37f13a 2023-01-10 mark # same diffstat with explicit parent commit ID
1452 6b37f13a 2023-01-10 mark (cd $testroot/wt && got diff -d -c $commit_id0 -c master \
1453 6b37f13a 2023-01-10 mark > $testroot/stdout)
1454 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1455 6b37f13a 2023-01-10 mark ret=$?
1456 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1457 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1458 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1459 6b37f13a 2023-01-10 mark return 1
1460 6b37f13a 2023-01-10 mark fi
1461 6b37f13a 2023-01-10 mark
1462 6b37f13a 2023-01-10 mark cat <<EOF >$testroot/stdout.expected
1463 6b37f13a 2023-01-10 mark diffstat $commit_id0 $commit_id1
1464 6b37f13a 2023-01-10 mark M alpha | 1+ 1-
1465 6b37f13a 2023-01-10 mark D beta | 0+ 1-
1466 6b37f13a 2023-01-10 mark A new | 1+ 0-
1467 6b37f13a 2023-01-10 mark
1468 6b37f13a 2023-01-10 mark 3 files changed, 2 insertions(+), 2 deletions(-)
1469 6b37f13a 2023-01-10 mark
1470 6b37f13a 2023-01-10 mark EOF
1471 6b37f13a 2023-01-10 mark
1472 6b37f13a 2023-01-10 mark # same diffstat with commit object IDs
1473 6b37f13a 2023-01-10 mark echo "diff $commit_id0 $commit_id1" >> $testroot/stdout.expected
1474 6b37f13a 2023-01-10 mark echo "commit - $commit_id0" >> $testroot/stdout.expected
1475 6b37f13a 2023-01-10 mark echo "commit + $commit_id1" >> $testroot/stdout.expected
1476 6b37f13a 2023-01-10 mark echo "blob - $alpha_id0" >> $testroot/stdout.expected
1477 6b37f13a 2023-01-10 mark echo "blob + $alpha_id1" >> $testroot/stdout.expected
1478 6b37f13a 2023-01-10 mark echo '--- alpha' >> $testroot/stdout.expected
1479 6b37f13a 2023-01-10 mark echo '+++ alpha' >> $testroot/stdout.expected
1480 6b37f13a 2023-01-10 mark echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1481 6b37f13a 2023-01-10 mark echo '-alpha' >> $testroot/stdout.expected
1482 6b37f13a 2023-01-10 mark echo '+modified alpha' >> $testroot/stdout.expected
1483 6b37f13a 2023-01-10 mark echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1484 6b37f13a 2023-01-10 mark echo 'blob + /dev/null' >> $testroot/stdout.expected
1485 6b37f13a 2023-01-10 mark echo '--- beta' >> $testroot/stdout.expected
1486 6b37f13a 2023-01-10 mark echo '+++ /dev/null' >> $testroot/stdout.expected
1487 6b37f13a 2023-01-10 mark echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1488 6b37f13a 2023-01-10 mark echo '-beta' >> $testroot/stdout.expected
1489 6b37f13a 2023-01-10 mark echo 'blob - /dev/null' >> $testroot/stdout.expected
1490 6b37f13a 2023-01-10 mark echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1491 6b37f13a 2023-01-10 mark echo '--- /dev/null' >> $testroot/stdout.expected
1492 6b37f13a 2023-01-10 mark echo '+++ new' >> $testroot/stdout.expected
1493 6b37f13a 2023-01-10 mark echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1494 6b37f13a 2023-01-10 mark echo '+new file' >> $testroot/stdout.expected
1495 6b37f13a 2023-01-10 mark (cd $testroot/wt && got diff -d -c $commit_id0 -c $commit_id1 \
1496 6b37f13a 2023-01-10 mark > $testroot/stdout)
1497 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1498 6b37f13a 2023-01-10 mark ret=$?
1499 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1500 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1501 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1502 6b37f13a 2023-01-10 mark return 1
1503 6b37f13a 2023-01-10 mark fi
1504 6b37f13a 2023-01-10 mark
1505 6b37f13a 2023-01-10 mark cat <<EOF >$testroot/stdout.expected
1506 6b37f13a 2023-01-10 mark diffstat $commit_id0 $commit_id1
1507 6b37f13a 2023-01-10 mark M alpha | 1+ 1-
1508 6b37f13a 2023-01-10 mark
1509 4a1a7373 2023-01-16 mark 1 file changed, 1 insertion(+), 1 deletion(-)
1510 6b37f13a 2023-01-10 mark
1511 6b37f13a 2023-01-10 mark EOF
1512 6b37f13a 2023-01-10 mark
1513 6b37f13a 2023-01-10 mark # same diffstat filtered by path "alpha"
1514 6b37f13a 2023-01-10 mark echo "diff $commit_id0 $commit_id1" >> $testroot/stdout.expected
1515 6b37f13a 2023-01-10 mark echo "commit - $commit_id0" >> $testroot/stdout.expected
1516 6b37f13a 2023-01-10 mark echo "commit + $commit_id1" >> $testroot/stdout.expected
1517 6b37f13a 2023-01-10 mark echo "blob - $alpha_id0" >> $testroot/stdout.expected
1518 6b37f13a 2023-01-10 mark echo "blob + $alpha_id1" >> $testroot/stdout.expected
1519 6b37f13a 2023-01-10 mark echo '--- alpha' >> $testroot/stdout.expected
1520 6b37f13a 2023-01-10 mark echo '+++ alpha' >> $testroot/stdout.expected
1521 6b37f13a 2023-01-10 mark echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1522 6b37f13a 2023-01-10 mark echo '-alpha' >> $testroot/stdout.expected
1523 6b37f13a 2023-01-10 mark echo '+modified alpha' >> $testroot/stdout.expected
1524 6b37f13a 2023-01-10 mark (cd $testroot/repo && got diff -d -c $commit_id0 -c $commit_id1 alpha \
1525 6b37f13a 2023-01-10 mark > $testroot/stdout)
1526 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1527 6b37f13a 2023-01-10 mark ret=$?
1528 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1529 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1530 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1531 6b37f13a 2023-01-10 mark return 1
1532 6b37f13a 2023-01-10 mark fi
1533 6b37f13a 2023-01-10 mark # same diffstat in work tree
1534 6b37f13a 2023-01-10 mark (cd $testroot/wt && got diff -d -c $commit_id0 -c $commit_id1 alpha \
1535 6b37f13a 2023-01-10 mark > $testroot/stdout)
1536 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1537 6b37f13a 2023-01-10 mark ret=$?
1538 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1539 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1540 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1541 6b37f13a 2023-01-10 mark return 1
1542 6b37f13a 2023-01-10 mark fi
1543 6b37f13a 2023-01-10 mark
1544 6b37f13a 2023-01-10 mark cat <<EOF >$testroot/stdout.expected
1545 6b37f13a 2023-01-10 mark diffstat $commit_id0 $commit_id1
1546 6b37f13a 2023-01-10 mark D beta | 0+ 1-
1547 6b37f13a 2023-01-10 mark A new | 1+ 0-
1548 6b37f13a 2023-01-10 mark
1549 4a1a7373 2023-01-16 mark 2 files changed, 1 insertion(+), 1 deletion(-)
1550 6b37f13a 2023-01-10 mark
1551 6b37f13a 2023-01-10 mark EOF
1552 6b37f13a 2023-01-10 mark
1553 6b37f13a 2023-01-10 mark # same diffstat filtered by paths "beta" and "new"
1554 6b37f13a 2023-01-10 mark echo "diff $commit_id0 $commit_id1" >> $testroot/stdout.expected
1555 6b37f13a 2023-01-10 mark echo "commit - $commit_id0" >> $testroot/stdout.expected
1556 6b37f13a 2023-01-10 mark echo "commit + $commit_id1" >> $testroot/stdout.expected
1557 6b37f13a 2023-01-10 mark echo "blob - $beta_id0 (mode 644)" >> $testroot/stdout.expected
1558 6b37f13a 2023-01-10 mark echo 'blob + /dev/null' >> $testroot/stdout.expected
1559 6b37f13a 2023-01-10 mark echo '--- beta' >> $testroot/stdout.expected
1560 6b37f13a 2023-01-10 mark echo '+++ /dev/null' >> $testroot/stdout.expected
1561 6b37f13a 2023-01-10 mark echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1562 6b37f13a 2023-01-10 mark echo '-beta' >> $testroot/stdout.expected
1563 6b37f13a 2023-01-10 mark echo 'blob - /dev/null' >> $testroot/stdout.expected
1564 6b37f13a 2023-01-10 mark echo "blob + $new_id1 (mode 644)" >> $testroot/stdout.expected
1565 6b37f13a 2023-01-10 mark echo '--- /dev/null' >> $testroot/stdout.expected
1566 6b37f13a 2023-01-10 mark echo '+++ new' >> $testroot/stdout.expected
1567 6b37f13a 2023-01-10 mark echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1568 6b37f13a 2023-01-10 mark echo '+new file' >> $testroot/stdout.expected
1569 6b37f13a 2023-01-10 mark (cd $testroot/repo && got diff -d -c $commit_id0 -c $commit_id1 \
1570 6b37f13a 2023-01-10 mark beta new > $testroot/stdout)
1571 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1572 6b37f13a 2023-01-10 mark ret=$?
1573 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1574 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1575 6b37f13a 2023-01-10 mark fi
1576 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1577 6b37f13a 2023-01-10 mark }
1578 6b37f13a 2023-01-10 mark
1579 6b37f13a 2023-01-10 mark test_diff_worktree_diffstat() {
1580 6b37f13a 2023-01-10 mark local testroot=`test_init diff_worktree_diffstat`
1581 6b37f13a 2023-01-10 mark local head_rev=`git_show_head $testroot/repo`
1582 6b37f13a 2023-01-10 mark local alpha_blobid=`get_blob_id $testroot/repo "" alpha`
1583 6b37f13a 2023-01-10 mark
1584 6b37f13a 2023-01-10 mark got checkout $testroot/repo $testroot/wt > /dev/null
1585 6b37f13a 2023-01-10 mark ret=$?
1586 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1587 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1588 6b37f13a 2023-01-10 mark return 1
1589 6b37f13a 2023-01-10 mark fi
1590 6b37f13a 2023-01-10 mark
1591 6b37f13a 2023-01-10 mark echo "modified alpha" > $testroot/wt/alpha
1592 6b37f13a 2023-01-10 mark (cd $testroot/wt && got rm beta >/dev/null)
1593 6b37f13a 2023-01-10 mark echo "new file" > $testroot/wt/new
1594 6b37f13a 2023-01-10 mark (cd $testroot/wt && got add new >/dev/null)
1595 6b37f13a 2023-01-10 mark
1596 6b37f13a 2023-01-10 mark cat <<EOF >$testroot/stdout.expected
1597 6b37f13a 2023-01-10 mark diffstat $testroot/wt
1598 6b37f13a 2023-01-10 mark M alpha | 1+ 1-
1599 6b37f13a 2023-01-10 mark D beta | 0+ 1-
1600 6b37f13a 2023-01-10 mark A new | 1+ 0-
1601 6b37f13a 2023-01-10 mark
1602 6b37f13a 2023-01-10 mark 3 files changed, 2 insertions(+), 2 deletions(-)
1603 6b37f13a 2023-01-10 mark
1604 6b37f13a 2023-01-10 mark EOF
1605 6b37f13a 2023-01-10 mark
1606 6b37f13a 2023-01-10 mark echo "diff $testroot/wt" >> $testroot/stdout.expected
1607 6b37f13a 2023-01-10 mark echo "commit - $head_rev" >> $testroot/stdout.expected
1608 6b37f13a 2023-01-10 mark echo "path + $testroot/wt" >> $testroot/stdout.expected
1609 6b37f13a 2023-01-10 mark echo -n 'blob - ' >> $testroot/stdout.expected
1610 6b37f13a 2023-01-10 mark got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
1611 6b37f13a 2023-01-10 mark >> $testroot/stdout.expected
1612 6b37f13a 2023-01-10 mark echo 'file + alpha' >> $testroot/stdout.expected
1613 6b37f13a 2023-01-10 mark echo '--- alpha' >> $testroot/stdout.expected
1614 6b37f13a 2023-01-10 mark echo '+++ alpha' >> $testroot/stdout.expected
1615 6b37f13a 2023-01-10 mark echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1616 6b37f13a 2023-01-10 mark echo '-alpha' >> $testroot/stdout.expected
1617 6b37f13a 2023-01-10 mark echo '+modified alpha' >> $testroot/stdout.expected
1618 6b37f13a 2023-01-10 mark echo -n 'blob - ' >> $testroot/stdout.expected
1619 6b37f13a 2023-01-10 mark got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1620 6b37f13a 2023-01-10 mark >> $testroot/stdout.expected
1621 6b37f13a 2023-01-10 mark echo 'file + /dev/null' >> $testroot/stdout.expected
1622 6b37f13a 2023-01-10 mark echo '--- beta' >> $testroot/stdout.expected
1623 6b37f13a 2023-01-10 mark echo '+++ /dev/null' >> $testroot/stdout.expected
1624 6b37f13a 2023-01-10 mark echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1625 6b37f13a 2023-01-10 mark echo '-beta' >> $testroot/stdout.expected
1626 6b37f13a 2023-01-10 mark echo 'blob - /dev/null' >> $testroot/stdout.expected
1627 6b37f13a 2023-01-10 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
1628 6b37f13a 2023-01-10 mark echo '--- /dev/null' >> $testroot/stdout.expected
1629 6b37f13a 2023-01-10 mark echo '+++ new' >> $testroot/stdout.expected
1630 6b37f13a 2023-01-10 mark echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1631 6b37f13a 2023-01-10 mark echo '+new file' >> $testroot/stdout.expected
1632 6b37f13a 2023-01-10 mark
1633 6b37f13a 2023-01-10 mark (cd $testroot/wt && got diff -d > $testroot/stdout)
1634 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1635 6b37f13a 2023-01-10 mark ret=$?
1636 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1637 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1638 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1639 6b37f13a 2023-01-10 mark return 1
1640 6b37f13a 2023-01-10 mark fi
1641 6b37f13a 2023-01-10 mark
1642 6b37f13a 2023-01-10 mark echo "modified zeta" > $testroot/wt/epsilon/zeta
1643 6b37f13a 2023-01-10 mark
1644 6b37f13a 2023-01-10 mark cat <<EOF >$testroot/stdout.expected
1645 6b37f13a 2023-01-10 mark diffstat $testroot/wt
1646 6b37f13a 2023-01-10 mark M alpha | 1+ 1-
1647 6b37f13a 2023-01-10 mark D beta | 0+ 1-
1648 6b37f13a 2023-01-10 mark M epsilon/zeta | 1+ 1-
1649 6b37f13a 2023-01-10 mark A new | 1+ 0-
1650 6b37f13a 2023-01-10 mark
1651 6b37f13a 2023-01-10 mark 4 files changed, 3 insertions(+), 3 deletions(-)
1652 6b37f13a 2023-01-10 mark
1653 6b37f13a 2023-01-10 mark EOF
1654 6b37f13a 2023-01-10 mark
1655 6b37f13a 2023-01-10 mark # specify paths to diffstat
1656 6b37f13a 2023-01-10 mark echo "diff $testroot/wt" >> $testroot/stdout.expected
1657 6b37f13a 2023-01-10 mark echo "commit - $head_rev" >> $testroot/stdout.expected
1658 6b37f13a 2023-01-10 mark echo "path + $testroot/wt" >> $testroot/stdout.expected
1659 6b37f13a 2023-01-10 mark echo -n 'blob - ' >> $testroot/stdout.expected
1660 6b37f13a 2023-01-10 mark got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
1661 6b37f13a 2023-01-10 mark >> $testroot/stdout.expected
1662 6b37f13a 2023-01-10 mark echo 'file + alpha' >> $testroot/stdout.expected
1663 6b37f13a 2023-01-10 mark echo '--- alpha' >> $testroot/stdout.expected
1664 6b37f13a 2023-01-10 mark echo '+++ alpha' >> $testroot/stdout.expected
1665 6b37f13a 2023-01-10 mark echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1666 6b37f13a 2023-01-10 mark echo '-alpha' >> $testroot/stdout.expected
1667 6b37f13a 2023-01-10 mark echo '+modified alpha' >> $testroot/stdout.expected
1668 6b37f13a 2023-01-10 mark echo -n 'blob - ' >> $testroot/stdout.expected
1669 6b37f13a 2023-01-10 mark got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1670 6b37f13a 2023-01-10 mark >> $testroot/stdout.expected
1671 6b37f13a 2023-01-10 mark echo 'file + /dev/null' >> $testroot/stdout.expected
1672 6b37f13a 2023-01-10 mark echo '--- beta' >> $testroot/stdout.expected
1673 6b37f13a 2023-01-10 mark echo '+++ /dev/null' >> $testroot/stdout.expected
1674 6b37f13a 2023-01-10 mark echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1675 6b37f13a 2023-01-10 mark echo '-beta' >> $testroot/stdout.expected
1676 6b37f13a 2023-01-10 mark echo -n 'blob - ' >> $testroot/stdout.expected
1677 6b37f13a 2023-01-10 mark got tree -r $testroot/repo -i epsilon | grep 'zeta$' | cut -d' ' -f 1 \
1678 6b37f13a 2023-01-10 mark >> $testroot/stdout.expected
1679 6b37f13a 2023-01-10 mark echo 'file + epsilon/zeta' >> $testroot/stdout.expected
1680 6b37f13a 2023-01-10 mark echo '--- epsilon/zeta' >> $testroot/stdout.expected
1681 6b37f13a 2023-01-10 mark echo '+++ epsilon/zeta' >> $testroot/stdout.expected
1682 6b37f13a 2023-01-10 mark echo '@@ -1 +1 @@' >> $testroot/stdout.expected
1683 6b37f13a 2023-01-10 mark echo '-zeta' >> $testroot/stdout.expected
1684 6b37f13a 2023-01-10 mark echo '+modified zeta' >> $testroot/stdout.expected
1685 6b37f13a 2023-01-10 mark echo 'blob - /dev/null' >> $testroot/stdout.expected
1686 6b37f13a 2023-01-10 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
1687 6b37f13a 2023-01-10 mark echo '--- /dev/null' >> $testroot/stdout.expected
1688 6b37f13a 2023-01-10 mark echo '+++ new' >> $testroot/stdout.expected
1689 6b37f13a 2023-01-10 mark echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1690 6b37f13a 2023-01-10 mark echo '+new file' >> $testroot/stdout.expected
1691 6b37f13a 2023-01-10 mark
1692 6b37f13a 2023-01-10 mark (cd $testroot/wt && got diff -d new alpha epsilon beta > $testroot/stdout)
1693 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1694 6b37f13a 2023-01-10 mark ret=$?
1695 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1696 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1697 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1698 6b37f13a 2023-01-10 mark return 1
1699 6b37f13a 2023-01-10 mark fi
1700 6b37f13a 2023-01-10 mark
1701 6b37f13a 2023-01-10 mark # same diff irrespective of argument order
1702 6b37f13a 2023-01-10 mark (cd $testroot/wt && got diff -d alpha new epsilon beta \
1703 6b37f13a 2023-01-10 mark > $testroot/stdout 2> $testroot/stderr)
1704 6b37f13a 2023-01-10 mark ret=$?
1705 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1706 6b37f13a 2023-01-10 mark echo "diff failed unexpectedly" >&2
1707 6b37f13a 2023-01-10 mark test_done "$testroot" "1"
1708 6b37f13a 2023-01-10 mark return 1
1709 6b37f13a 2023-01-10 mark fi
1710 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1711 6b37f13a 2023-01-10 mark ret=$?
1712 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1713 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1714 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1715 6b37f13a 2023-01-10 mark return 1
1716 6b37f13a 2023-01-10 mark fi
1717 6b37f13a 2023-01-10 mark
1718 6b37f13a 2023-01-10 mark # force paths with -P
1719 6b37f13a 2023-01-10 mark echo master > $testroot/wt/master
1720 6b37f13a 2023-01-10 mark (cd $testroot/wt && got add master > /dev/null)
1721 6b37f13a 2023-01-10 mark (cd $testroot/wt && got diff -d -P new master > $testroot/stdout)
1722 6b37f13a 2023-01-10 mark ret=$?
1723 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1724 6b37f13a 2023-01-10 mark echo "diff failed unexpectedly" >&2
1725 6b37f13a 2023-01-10 mark test_done "$testroot" "1"
1726 6b37f13a 2023-01-10 mark return 1
1727 6b37f13a 2023-01-10 mark fi
1728 6b37f13a 2023-01-10 mark
1729 6b37f13a 2023-01-10 mark cat <<EOF >$testroot/stdout.expected
1730 6b37f13a 2023-01-10 mark diffstat $testroot/wt
1731 6b37f13a 2023-01-10 mark A master | 1+ 0-
1732 6b37f13a 2023-01-10 mark A new | 1+ 0-
1733 6b37f13a 2023-01-10 mark
1734 6b37f13a 2023-01-10 mark 2 files changed, 2 insertions(+), 0 deletions(-)
1735 6b37f13a 2023-01-10 mark
1736 6b37f13a 2023-01-10 mark EOF
1737 6b37f13a 2023-01-10 mark
1738 6b37f13a 2023-01-10 mark echo "diff $testroot/wt" >> $testroot/stdout.expected
1739 6b37f13a 2023-01-10 mark echo "commit - $head_rev" >> $testroot/stdout.expected
1740 6b37f13a 2023-01-10 mark echo "path + $testroot/wt" >> $testroot/stdout.expected
1741 6b37f13a 2023-01-10 mark echo 'blob - /dev/null' >> $testroot/stdout.expected
1742 6b37f13a 2023-01-10 mark echo 'file + master (mode 644)' >> $testroot/stdout.expected
1743 6b37f13a 2023-01-10 mark echo '--- /dev/null' >> $testroot/stdout.expected
1744 6b37f13a 2023-01-10 mark echo '+++ master' >> $testroot/stdout.expected
1745 6b37f13a 2023-01-10 mark echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1746 6b37f13a 2023-01-10 mark echo '+master' >> $testroot/stdout.expected
1747 6b37f13a 2023-01-10 mark echo 'blob - /dev/null' >> $testroot/stdout.expected
1748 6b37f13a 2023-01-10 mark echo 'file + new (mode 644)' >> $testroot/stdout.expected
1749 6b37f13a 2023-01-10 mark echo '--- /dev/null' >> $testroot/stdout.expected
1750 6b37f13a 2023-01-10 mark echo '+++ new' >> $testroot/stdout.expected
1751 6b37f13a 2023-01-10 mark echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
1752 6b37f13a 2023-01-10 mark echo '+new file' >> $testroot/stdout.expected
1753 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1754 6b37f13a 2023-01-10 mark ret=$?
1755 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1756 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1757 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1758 6b37f13a 2023-01-10 mark return 1
1759 6b37f13a 2023-01-10 mark fi
1760 6b37f13a 2023-01-10 mark
1761 6b37f13a 2023-01-10 mark # diff two blob ids
1762 6b37f13a 2023-01-10 mark (cd $testroot/wt && got commit -m 'edit' alpha >/dev/null)
1763 6b37f13a 2023-01-10 mark local alpha_new_blobid=`get_blob_id $testroot/repo "" alpha`
1764 6b37f13a 2023-01-10 mark (cd $testroot/wt && got diff -d $alpha_blobid $alpha_new_blobid) \
1765 6b37f13a 2023-01-10 mark > $testroot/stdout
1766 6b37f13a 2023-01-10 mark ret=$?
1767 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1768 6b37f13a 2023-01-10 mark echo "diff failed unexpectedly" >&2
1769 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1770 6b37f13a 2023-01-10 mark return 1
1771 6b37f13a 2023-01-10 mark fi
1772 6b37f13a 2023-01-10 mark
1773 05594ba5 2023-01-18 naddy short_alpha_id=$(printf '%.10s' $alpha_blobid)
1774 05594ba5 2023-01-18 naddy short_alpha_new_id=$(printf '%.10s' $alpha_new_blobid)
1775 6b37f13a 2023-01-10 mark cat <<EOF >$testroot/stdout.expected
1776 6b37f13a 2023-01-10 mark diffstat $alpha_blobid $alpha_new_blobid
1777 6b37f13a 2023-01-10 mark M $short_alpha_id -> $short_alpha_new_id | 1+ 1-
1778 6b37f13a 2023-01-10 mark
1779 4a1a7373 2023-01-16 mark 1 file changed, 1 insertion(+), 1 deletion(-)
1780 6b37f13a 2023-01-10 mark
1781 6b37f13a 2023-01-10 mark blob - $alpha_blobid
1782 6b37f13a 2023-01-10 mark blob + $alpha_new_blobid
1783 6b37f13a 2023-01-10 mark --- $alpha_blobid
1784 6b37f13a 2023-01-10 mark +++ $alpha_new_blobid
1785 6b37f13a 2023-01-10 mark @@ -1 +1 @@
1786 6b37f13a 2023-01-10 mark -alpha
1787 6b37f13a 2023-01-10 mark +modified alpha
1788 6b37f13a 2023-01-10 mark EOF
1789 6b37f13a 2023-01-10 mark
1790 6b37f13a 2023-01-10 mark cmp -s $testroot/stdout.expected $testroot/stdout
1791 6b37f13a 2023-01-10 mark ret=$?
1792 6b37f13a 2023-01-10 mark if [ $ret -ne 0 ]; then
1793 6b37f13a 2023-01-10 mark diff -u $testroot/stdout.expected $testroot/stdout
1794 9334723a 2023-02-27 naddy fi
1795 9334723a 2023-02-27 naddy test_done "$testroot" "$ret"
1796 9334723a 2023-02-27 naddy }
1797 9334723a 2023-02-27 naddy
1798 9334723a 2023-02-27 naddy test_diff_file_to_dir() {
1799 9334723a 2023-02-27 naddy local testroot=`test_init diff_file_to_dir`
1800 9334723a 2023-02-27 naddy local commit_id0=`git_show_head $testroot/repo`
1801 760a1ec3 2023-03-10 stsp local alpha_blobid=`get_blob_id $testroot/repo "" alpha`
1802 9334723a 2023-02-27 naddy
1803 9334723a 2023-02-27 naddy got checkout $testroot/repo $testroot/wt > /dev/null
1804 9334723a 2023-02-27 naddy ret=$?
1805 9334723a 2023-02-27 naddy if [ $ret -ne 0 ]; then
1806 9334723a 2023-02-27 naddy test_done "$testroot" "$ret"
1807 9334723a 2023-02-27 naddy return 1
1808 9334723a 2023-02-27 naddy fi
1809 9334723a 2023-02-27 naddy
1810 9334723a 2023-02-27 naddy git_rm $testroot/repo alpha
1811 9334723a 2023-02-27 naddy mkdir $testroot/repo/alpha
1812 9334723a 2023-02-27 naddy echo eta > $testroot/repo/alpha/eta
1813 9334723a 2023-02-27 naddy (cd $testroot/repo && git add alpha/eta)
1814 9334723a 2023-02-27 naddy git_commit $testroot/repo -m "changed alpha into directory"
1815 9334723a 2023-02-27 naddy local commit_id1=`git_show_head $testroot/repo`
1816 760a1ec3 2023-03-10 stsp local alpha_eta_blobid=`get_blob_id $testroot/repo alpha eta`
1817 9334723a 2023-02-27 naddy
1818 760a1ec3 2023-03-10 stsp cat <<EOF >$testroot/stdout.expected
1819 760a1ec3 2023-03-10 stsp diff $commit_id0 $commit_id1
1820 760a1ec3 2023-03-10 stsp commit - $commit_id0
1821 760a1ec3 2023-03-10 stsp commit + $commit_id1
1822 760a1ec3 2023-03-10 stsp blob - $alpha_blobid (mode 644)
1823 760a1ec3 2023-03-10 stsp blob + /dev/null
1824 760a1ec3 2023-03-10 stsp --- alpha
1825 760a1ec3 2023-03-10 stsp +++ /dev/null
1826 760a1ec3 2023-03-10 stsp @@ -1 +0,0 @@
1827 760a1ec3 2023-03-10 stsp -alpha
1828 760a1ec3 2023-03-10 stsp blob - /dev/null
1829 760a1ec3 2023-03-10 stsp blob + $alpha_eta_blobid (mode 644)
1830 760a1ec3 2023-03-10 stsp --- /dev/null
1831 760a1ec3 2023-03-10 stsp +++ alpha/eta
1832 760a1ec3 2023-03-10 stsp @@ -0,0 +1 @@
1833 760a1ec3 2023-03-10 stsp +eta
1834 760a1ec3 2023-03-10 stsp EOF
1835 9334723a 2023-02-27 naddy got diff -r $testroot/repo $commit_id0 $commit_id1 > $testroot/stdout
1836 760a1ec3 2023-03-10 stsp ret=$?
1837 760a1ec3 2023-03-10 stsp if [ $ret -ne 0 ]; then
1838 760a1ec3 2023-03-10 stsp echo "diff failed unexpectedly" >&2
1839 760a1ec3 2023-03-10 stsp test_done "$testroot" "1"
1840 760a1ec3 2023-03-10 stsp return 1
1841 760a1ec3 2023-03-10 stsp fi
1842 760a1ec3 2023-03-10 stsp
1843 9334723a 2023-02-27 naddy cmp -s $testroot/stdout.expected $testroot/stdout
1844 9334723a 2023-02-27 naddy ret=$?
1845 760a1ec3 2023-03-10 stsp if [ $ret -ne 0 ]; then
1846 760a1ec3 2023-03-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1847 760a1ec3 2023-03-10 stsp test_done "$testroot" "$ret"
1848 760a1ec3 2023-03-10 stsp return 1
1849 760a1ec3 2023-03-10 stsp fi
1850 760a1ec3 2023-03-10 stsp
1851 760a1ec3 2023-03-10 stsp local author_time=`git_show_author_time $testroot/repo`
1852 760a1ec3 2023-03-10 stsp d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1853 760a1ec3 2023-03-10 stsp cat <<EOF >$testroot/stdout.expected
1854 760a1ec3 2023-03-10 stsp -----------------------------------------------
1855 760a1ec3 2023-03-10 stsp commit $commit_id1 (master)
1856 760a1ec3 2023-03-10 stsp from: $GOT_AUTHOR
1857 760a1ec3 2023-03-10 stsp date: $d
1858 760a1ec3 2023-03-10 stsp
1859 760a1ec3 2023-03-10 stsp changed alpha into directory
1860 760a1ec3 2023-03-10 stsp
1861 760a1ec3 2023-03-10 stsp D alpha
1862 760a1ec3 2023-03-10 stsp A alpha/eta
1863 760a1ec3 2023-03-10 stsp
1864 760a1ec3 2023-03-10 stsp EOF
1865 760a1ec3 2023-03-10 stsp
1866 760a1ec3 2023-03-10 stsp got log -P -r $testroot/repo -l1 -c $commit_id1 > $testroot/stdout
1867 760a1ec3 2023-03-10 stsp ret=$?
1868 760a1ec3 2023-03-10 stsp if [ $ret -ne 0 ]; then
1869 760a1ec3 2023-03-10 stsp echo "diff failed unexpectedly" >&2
1870 760a1ec3 2023-03-10 stsp test_done "$testroot" "1"
1871 760a1ec3 2023-03-10 stsp return 1
1872 6b37f13a 2023-01-10 mark fi
1873 760a1ec3 2023-03-10 stsp
1874 760a1ec3 2023-03-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1875 760a1ec3 2023-03-10 stsp ret=$?
1876 760a1ec3 2023-03-10 stsp if [ $ret -ne 0 ]; then
1877 760a1ec3 2023-03-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1878 760a1ec3 2023-03-10 stsp fi
1879 6b37f13a 2023-01-10 mark test_done "$testroot" "$ret"
1880 0543436d 2022-07-26 op }
1881 0543436d 2022-07-26 op
1882 760a1ec3 2023-03-10 stsp test_diff_dir_to_file() {
1883 760a1ec3 2023-03-10 stsp local testroot=`test_init diff_file_to_dir`
1884 760a1ec3 2023-03-10 stsp local commit_id0=`git_show_head $testroot/repo`
1885 760a1ec3 2023-03-10 stsp local epsilon_zeta_blobid=`get_blob_id $testroot/repo epsilon zeta`
1886 760a1ec3 2023-03-10 stsp
1887 760a1ec3 2023-03-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1888 760a1ec3 2023-03-10 stsp ret=$?
1889 760a1ec3 2023-03-10 stsp if [ $ret -ne 0 ]; then
1890 760a1ec3 2023-03-10 stsp test_done "$testroot" "$ret"
1891 760a1ec3 2023-03-10 stsp return 1
1892 760a1ec3 2023-03-10 stsp fi
1893 760a1ec3 2023-03-10 stsp
1894 760a1ec3 2023-03-10 stsp git_rmdir $testroot/repo epsilon
1895 760a1ec3 2023-03-10 stsp echo epsilon > $testroot/repo/epsilon
1896 760a1ec3 2023-03-10 stsp (cd $testroot/repo && git add epsilon)
1897 760a1ec3 2023-03-10 stsp git_commit $testroot/repo -m "changed epsilon into file"
1898 760a1ec3 2023-03-10 stsp local commit_id1=`git_show_head $testroot/repo`
1899 760a1ec3 2023-03-10 stsp local epsilon_blobid=`get_blob_id $testroot/repo "" epsilon`
1900 760a1ec3 2023-03-10 stsp
1901 760a1ec3 2023-03-10 stsp cat <<EOF >$testroot/stdout.expected
1902 760a1ec3 2023-03-10 stsp diff $commit_id0 $commit_id1
1903 760a1ec3 2023-03-10 stsp commit - $commit_id0
1904 760a1ec3 2023-03-10 stsp commit + $commit_id1
1905 760a1ec3 2023-03-10 stsp blob - $epsilon_zeta_blobid (mode 644)
1906 760a1ec3 2023-03-10 stsp blob + /dev/null
1907 760a1ec3 2023-03-10 stsp --- epsilon/zeta
1908 760a1ec3 2023-03-10 stsp +++ /dev/null
1909 760a1ec3 2023-03-10 stsp @@ -1 +0,0 @@
1910 760a1ec3 2023-03-10 stsp -zeta
1911 760a1ec3 2023-03-10 stsp blob - /dev/null
1912 760a1ec3 2023-03-10 stsp blob + $epsilon_blobid (mode 644)
1913 760a1ec3 2023-03-10 stsp --- /dev/null
1914 760a1ec3 2023-03-10 stsp +++ epsilon
1915 760a1ec3 2023-03-10 stsp @@ -0,0 +1 @@
1916 760a1ec3 2023-03-10 stsp +epsilon
1917 760a1ec3 2023-03-10 stsp EOF
1918 760a1ec3 2023-03-10 stsp got diff -r $testroot/repo $commit_id0 $commit_id1 > $testroot/stdout
1919 760a1ec3 2023-03-10 stsp ret=$?
1920 760a1ec3 2023-03-10 stsp if [ $ret -ne 0 ]; then
1921 760a1ec3 2023-03-10 stsp echo "diff failed unexpectedly" >&2
1922 760a1ec3 2023-03-10 stsp test_done "$testroot" "1"
1923 760a1ec3 2023-03-10 stsp return 1
1924 760a1ec3 2023-03-10 stsp fi
1925 760a1ec3 2023-03-10 stsp
1926 760a1ec3 2023-03-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1927 760a1ec3 2023-03-10 stsp ret=$?
1928 760a1ec3 2023-03-10 stsp if [ $ret -ne 0 ]; then
1929 760a1ec3 2023-03-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1930 760a1ec3 2023-03-10 stsp test_done "$testroot" "$ret"
1931 760a1ec3 2023-03-10 stsp return 1
1932 760a1ec3 2023-03-10 stsp fi
1933 760a1ec3 2023-03-10 stsp
1934 760a1ec3 2023-03-10 stsp local author_time=`git_show_author_time $testroot/repo`
1935 760a1ec3 2023-03-10 stsp d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1936 760a1ec3 2023-03-10 stsp cat <<EOF >$testroot/stdout.expected
1937 760a1ec3 2023-03-10 stsp -----------------------------------------------
1938 760a1ec3 2023-03-10 stsp commit $commit_id1 (master)
1939 760a1ec3 2023-03-10 stsp from: $GOT_AUTHOR
1940 760a1ec3 2023-03-10 stsp date: $d
1941 760a1ec3 2023-03-10 stsp
1942 760a1ec3 2023-03-10 stsp changed epsilon into file
1943 760a1ec3 2023-03-10 stsp
1944 760a1ec3 2023-03-10 stsp D epsilon/zeta
1945 760a1ec3 2023-03-10 stsp A epsilon
1946 760a1ec3 2023-03-10 stsp
1947 760a1ec3 2023-03-10 stsp EOF
1948 760a1ec3 2023-03-10 stsp
1949 760a1ec3 2023-03-10 stsp got log -P -r $testroot/repo -l1 -c $commit_id1 > $testroot/stdout
1950 760a1ec3 2023-03-10 stsp ret=$?
1951 760a1ec3 2023-03-10 stsp if [ $ret -ne 0 ]; then
1952 760a1ec3 2023-03-10 stsp echo "diff failed unexpectedly" >&2
1953 760a1ec3 2023-03-10 stsp test_done "$testroot" "1"
1954 760a1ec3 2023-03-10 stsp return 1
1955 760a1ec3 2023-03-10 stsp fi
1956 760a1ec3 2023-03-10 stsp
1957 760a1ec3 2023-03-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1958 760a1ec3 2023-03-10 stsp ret=$?
1959 760a1ec3 2023-03-10 stsp if [ $ret -ne 0 ]; then
1960 760a1ec3 2023-03-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1961 760a1ec3 2023-03-10 stsp fi
1962 760a1ec3 2023-03-10 stsp test_done "$testroot" "$ret"
1963 760a1ec3 2023-03-10 stsp }
1964 760a1ec3 2023-03-10 stsp
1965 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1966 95adcdca 2019-03-27 stsp run_test test_diff_basic
1967 95adcdca 2019-03-27 stsp run_test test_diff_shows_conflict
1968 d24820bf 2019-08-11 stsp run_test test_diff_tag
1969 562580bc 2020-01-14 stsp run_test test_diff_lightweight_tag
1970 63035f9f 2019-10-06 stsp run_test test_diff_ignore_whitespace
1971 e7303626 2020-05-14 stsp run_test test_diff_submodule_of_same_repo
1972 39449a05 2020-07-23 stsp run_test test_diff_symlinks_in_work_tree
1973 40dde666 2020-07-23 stsp run_test test_diff_symlinks_in_repo
1974 dffd0deb 2020-11-20 stsp run_test test_diff_binary_files
1975 67b631c9 2021-10-10 stsp run_test test_diff_commits
1976 32b5305f 2022-02-12 op run_test test_diff_ignored_file
1977 0543436d 2022-07-26 op run_test test_diff_crlf
1978 c87842d5 2022-09-23 mark run_test test_diff_worktree_newfile_xbit
1979 6b37f13a 2023-01-10 mark run_test test_diff_commit_diffstat
1980 6b37f13a 2023-01-10 mark run_test test_diff_worktree_diffstat
1981 9334723a 2023-02-27 naddy run_test test_diff_file_to_dir
1982 760a1ec3 2023-03-10 stsp run_test test_diff_dir_to_file