Blame


1 95adcdca 2019-03-27 stsp #!/bin/sh
2 95adcdca 2019-03-27 stsp #
3 95adcdca 2019-03-27 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 95adcdca 2019-03-27 stsp #
5 95adcdca 2019-03-27 stsp # Permission to use, copy, modify, and distribute this software for any
6 95adcdca 2019-03-27 stsp # purpose with or without fee is hereby granted, provided that the above
7 95adcdca 2019-03-27 stsp # copyright notice and this permission notice appear in all copies.
8 95adcdca 2019-03-27 stsp #
9 95adcdca 2019-03-27 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 95adcdca 2019-03-27 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 95adcdca 2019-03-27 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 95adcdca 2019-03-27 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 95adcdca 2019-03-27 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 95adcdca 2019-03-27 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 95adcdca 2019-03-27 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 95adcdca 2019-03-27 stsp
17 95adcdca 2019-03-27 stsp . ./common.sh
18 95adcdca 2019-03-27 stsp
19 f6cae3ed 2020-09-13 naddy test_diff_basic() {
20 95adcdca 2019-03-27 stsp local testroot=`test_init diff_basic`
21 95adcdca 2019-03-27 stsp local head_rev=`git_show_head $testroot/repo`
22 95adcdca 2019-03-27 stsp
23 95adcdca 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 95adcdca 2019-03-27 stsp ret="$?"
25 95adcdca 2019-03-27 stsp if [ "$ret" != "0" ]; then
26 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
27 95adcdca 2019-03-27 stsp return 1
28 95adcdca 2019-03-27 stsp fi
29 95adcdca 2019-03-27 stsp
30 95adcdca 2019-03-27 stsp echo "modified alpha" > $testroot/wt/alpha
31 95adcdca 2019-03-27 stsp (cd $testroot/wt && got rm beta >/dev/null)
32 95adcdca 2019-03-27 stsp echo "new file" > $testroot/wt/new
33 95adcdca 2019-03-27 stsp (cd $testroot/wt && got add new >/dev/null)
34 95adcdca 2019-03-27 stsp
35 95adcdca 2019-03-27 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
36 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
37 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
38 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
39 95adcdca 2019-03-27 stsp echo 'file + alpha' >> $testroot/stdout.expected
40 95adcdca 2019-03-27 stsp echo '--- alpha' >> $testroot/stdout.expected
41 95adcdca 2019-03-27 stsp echo '+++ alpha' >> $testroot/stdout.expected
42 95adcdca 2019-03-27 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
43 95adcdca 2019-03-27 stsp echo '-alpha' >> $testroot/stdout.expected
44 95adcdca 2019-03-27 stsp echo '+modified alpha' >> $testroot/stdout.expected
45 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
46 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
47 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
48 95adcdca 2019-03-27 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
49 95adcdca 2019-03-27 stsp echo '--- beta' >> $testroot/stdout.expected
50 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
51 95adcdca 2019-03-27 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
52 95adcdca 2019-03-27 stsp echo '-beta' >> $testroot/stdout.expected
53 95adcdca 2019-03-27 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
54 95adcdca 2019-03-27 stsp echo 'file + new' >> $testroot/stdout.expected
55 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
56 95adcdca 2019-03-27 stsp echo '+++ new' >> $testroot/stdout.expected
57 95adcdca 2019-03-27 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
58 95adcdca 2019-03-27 stsp echo '+new file' >> $testroot/stdout.expected
59 95adcdca 2019-03-27 stsp
60 95adcdca 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
61 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
62 95adcdca 2019-03-27 stsp ret="$?"
63 95adcdca 2019-03-27 stsp if [ "$ret" != "0" ]; then
64 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
65 2a06fe5f 2019-08-24 stsp test_done "$testroot" "$ret"
66 2a06fe5f 2019-08-24 stsp return 1
67 95adcdca 2019-03-27 stsp fi
68 2a06fe5f 2019-08-24 stsp
69 2a06fe5f 2019-08-24 stsp # diff non-existent path
70 2a06fe5f 2019-08-24 stsp (cd $testroot/wt && got diff nonexistent > $testroot/stdout \
71 2a06fe5f 2019-08-24 stsp 2> $testroot/stderr)
72 2a06fe5f 2019-08-24 stsp
73 2a06fe5f 2019-08-24 stsp echo -n > $testroot/stdout.expected
74 2a06fe5f 2019-08-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
75 2a06fe5f 2019-08-24 stsp ret="$?"
76 2a06fe5f 2019-08-24 stsp if [ "$ret" != "0" ]; then
77 2a06fe5f 2019-08-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
78 2a06fe5f 2019-08-24 stsp test_done "$testroot" "$ret"
79 2a06fe5f 2019-08-24 stsp return 1
80 2a06fe5f 2019-08-24 stsp fi
81 2a06fe5f 2019-08-24 stsp
82 2a06fe5f 2019-08-24 stsp echo "got: nonexistent: No such file or directory" \
83 2a06fe5f 2019-08-24 stsp > $testroot/stderr.expected
84 2a06fe5f 2019-08-24 stsp cmp -s $testroot/stderr.expected $testroot/stderr
85 2a06fe5f 2019-08-24 stsp ret="$?"
86 2a06fe5f 2019-08-24 stsp if [ "$ret" != "0" ]; then
87 2a06fe5f 2019-08-24 stsp diff -u $testroot/stderr.expected $testroot/stderr
88 2a06fe5f 2019-08-24 stsp fi
89 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
90 95adcdca 2019-03-27 stsp }
91 95adcdca 2019-03-27 stsp
92 f6cae3ed 2020-09-13 naddy test_diff_shows_conflict() {
93 95adcdca 2019-03-27 stsp local testroot=`test_init diff_shows_conflict 1`
94 95adcdca 2019-03-27 stsp
95 95adcdca 2019-03-27 stsp echo "1" > $testroot/repo/numbers
96 95adcdca 2019-03-27 stsp echo "2" >> $testroot/repo/numbers
97 95adcdca 2019-03-27 stsp echo "3" >> $testroot/repo/numbers
98 95adcdca 2019-03-27 stsp echo "4" >> $testroot/repo/numbers
99 95adcdca 2019-03-27 stsp echo "5" >> $testroot/repo/numbers
100 95adcdca 2019-03-27 stsp echo "6" >> $testroot/repo/numbers
101 95adcdca 2019-03-27 stsp echo "7" >> $testroot/repo/numbers
102 95adcdca 2019-03-27 stsp echo "8" >> $testroot/repo/numbers
103 95adcdca 2019-03-27 stsp (cd $testroot/repo && git add numbers)
104 95adcdca 2019-03-27 stsp git_commit $testroot/repo -m "added numbers file"
105 f69721c3 2019-10-21 stsp local base_commit=`git_show_head $testroot/repo`
106 95adcdca 2019-03-27 stsp
107 95adcdca 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
108 95adcdca 2019-03-27 stsp ret="$?"
109 95adcdca 2019-03-27 stsp if [ "$ret" != "0" ]; then
110 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
111 95adcdca 2019-03-27 stsp return 1
112 95adcdca 2019-03-27 stsp fi
113 95adcdca 2019-03-27 stsp
114 95adcdca 2019-03-27 stsp sed -i 's/2/22/' $testroot/repo/numbers
115 d136cfcb 2019-10-12 stsp sed -i 's/8/33/' $testroot/repo/numbers
116 95adcdca 2019-03-27 stsp git_commit $testroot/repo -m "modified line 2"
117 95adcdca 2019-03-27 stsp local head_rev=`git_show_head $testroot/repo`
118 95adcdca 2019-03-27 stsp
119 d136cfcb 2019-10-12 stsp # modify lines 2 and 8 in conflicting ways
120 95adcdca 2019-03-27 stsp sed -i 's/2/77/' $testroot/wt/numbers
121 d136cfcb 2019-10-12 stsp sed -i 's/8/88/' $testroot/wt/numbers
122 95adcdca 2019-03-27 stsp
123 95adcdca 2019-03-27 stsp echo "C numbers" > $testroot/stdout.expected
124 95adcdca 2019-03-27 stsp echo -n "Updated to commit $head_rev" >> $testroot/stdout.expected
125 95adcdca 2019-03-27 stsp echo >> $testroot/stdout.expected
126 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
127 95adcdca 2019-03-27 stsp
128 95adcdca 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
129 95adcdca 2019-03-27 stsp
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
131 95adcdca 2019-03-27 stsp ret="$?"
132 95adcdca 2019-03-27 stsp if [ "$ret" != "0" ]; then
133 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
134 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
135 95adcdca 2019-03-27 stsp return 1
136 95adcdca 2019-03-27 stsp fi
137 95adcdca 2019-03-27 stsp
138 95adcdca 2019-03-27 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
139 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
140 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'numbers$' | cut -d' ' -f 1 \
141 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
142 95adcdca 2019-03-27 stsp echo 'file + numbers' >> $testroot/stdout.expected
143 95adcdca 2019-03-27 stsp echo '--- numbers' >> $testroot/stdout.expected
144 95adcdca 2019-03-27 stsp echo '+++ numbers' >> $testroot/stdout.expected
145 d136cfcb 2019-10-12 stsp echo '@@ -1,8 +1,20 @@' >> $testroot/stdout.expected
146 95adcdca 2019-03-27 stsp echo ' 1' >> $testroot/stdout.expected
147 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
148 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
149 95adcdca 2019-03-27 stsp echo ' 22' >> $testroot/stdout.expected
150 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
151 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
152 d136cfcb 2019-10-12 stsp echo '+2' >> $testroot/stdout.expected
153 95adcdca 2019-03-27 stsp echo '+=======' >> $testroot/stdout.expected
154 95adcdca 2019-03-27 stsp echo '+77' >> $testroot/stdout.expected
155 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
156 95adcdca 2019-03-27 stsp echo ' 3' >> $testroot/stdout.expected
157 95adcdca 2019-03-27 stsp echo ' 4' >> $testroot/stdout.expected
158 95adcdca 2019-03-27 stsp echo ' 5' >> $testroot/stdout.expected
159 d136cfcb 2019-10-12 stsp echo ' 6' >> $testroot/stdout.expected
160 d136cfcb 2019-10-12 stsp echo ' 7' >> $testroot/stdout.expected
161 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
162 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
163 d136cfcb 2019-10-12 stsp echo ' 33' >> $testroot/stdout.expected
164 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
165 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
166 d136cfcb 2019-10-12 stsp echo '+8' >> $testroot/stdout.expected
167 d136cfcb 2019-10-12 stsp echo '+=======' >> $testroot/stdout.expected
168 d136cfcb 2019-10-12 stsp echo '+88' >> $testroot/stdout.expected
169 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
170 95adcdca 2019-03-27 stsp
171 95adcdca 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
172 95adcdca 2019-03-27 stsp
173 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
174 95adcdca 2019-03-27 stsp ret="$?"
175 95adcdca 2019-03-27 stsp if [ "$ret" != "0" ]; then
176 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
177 95adcdca 2019-03-27 stsp fi
178 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
179 95adcdca 2019-03-27 stsp }
180 95adcdca 2019-03-27 stsp
181 f6cae3ed 2020-09-13 naddy test_diff_tag() {
182 d24820bf 2019-08-11 stsp local testroot=`test_init diff_tag`
183 d24820bf 2019-08-11 stsp local commit_id0=`git_show_head $testroot/repo`
184 d24820bf 2019-08-11 stsp local tag1=1.0.0
185 d24820bf 2019-08-11 stsp local tag2=2.0.0
186 d24820bf 2019-08-11 stsp
187 d24820bf 2019-08-11 stsp echo "modified alpha" > $testroot/repo/alpha
188 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "changed alpha"
189 d24820bf 2019-08-11 stsp local commit_id1=`git_show_head $testroot/repo`
190 d24820bf 2019-08-11 stsp
191 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag1)
192 d24820bf 2019-08-11 stsp
193 d24820bf 2019-08-11 stsp echo "new file" > $testroot/repo/new
194 d24820bf 2019-08-11 stsp (cd $testroot/repo && git add new)
195 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "new file"
196 d24820bf 2019-08-11 stsp local commit_id2=`git_show_head $testroot/repo`
197 d24820bf 2019-08-11 stsp
198 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag2)
199 562580bc 2020-01-14 stsp
200 562580bc 2020-01-14 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
201 562580bc 2020-01-14 stsp echo -n 'blob - ' >> $testroot/stdout.expected
202 562580bc 2020-01-14 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
203 562580bc 2020-01-14 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
204 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
205 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
206 562580bc 2020-01-14 stsp >> $testroot/stdout.expected
207 562580bc 2020-01-14 stsp echo '--- alpha' >> $testroot/stdout.expected
208 562580bc 2020-01-14 stsp echo '+++ alpha' >> $testroot/stdout.expected
209 562580bc 2020-01-14 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
210 562580bc 2020-01-14 stsp echo '-alpha' >> $testroot/stdout.expected
211 562580bc 2020-01-14 stsp echo '+modified alpha' >> $testroot/stdout.expected
212 562580bc 2020-01-14 stsp
213 562580bc 2020-01-14 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
214 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
215 562580bc 2020-01-14 stsp ret="$?"
216 562580bc 2020-01-14 stsp if [ "$ret" != "0" ]; then
217 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
218 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
219 562580bc 2020-01-14 stsp return 1
220 562580bc 2020-01-14 stsp fi
221 562580bc 2020-01-14 stsp
222 562580bc 2020-01-14 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
223 562580bc 2020-01-14 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
224 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
225 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
226 562580bc 2020-01-14 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
227 562580bc 2020-01-14 stsp echo " (mode 644)" >> $testroot/stdout.expected
228 562580bc 2020-01-14 stsp echo '--- /dev/null' >> $testroot/stdout.expected
229 562580bc 2020-01-14 stsp echo '+++ new' >> $testroot/stdout.expected
230 562580bc 2020-01-14 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
231 562580bc 2020-01-14 stsp echo '+new file' >> $testroot/stdout.expected
232 d24820bf 2019-08-11 stsp
233 562580bc 2020-01-14 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
234 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
235 562580bc 2020-01-14 stsp ret="$?"
236 562580bc 2020-01-14 stsp if [ "$ret" != "0" ]; then
237 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
238 562580bc 2020-01-14 stsp fi
239 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
240 562580bc 2020-01-14 stsp }
241 562580bc 2020-01-14 stsp
242 f6cae3ed 2020-09-13 naddy test_diff_lightweight_tag() {
243 562580bc 2020-01-14 stsp local testroot=`test_init diff_tag`
244 562580bc 2020-01-14 stsp local commit_id0=`git_show_head $testroot/repo`
245 562580bc 2020-01-14 stsp local tag1=1.0.0
246 562580bc 2020-01-14 stsp local tag2=2.0.0
247 562580bc 2020-01-14 stsp
248 562580bc 2020-01-14 stsp echo "modified alpha" > $testroot/repo/alpha
249 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "changed alpha"
250 562580bc 2020-01-14 stsp local commit_id1=`git_show_head $testroot/repo`
251 562580bc 2020-01-14 stsp
252 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag1)
253 562580bc 2020-01-14 stsp
254 562580bc 2020-01-14 stsp echo "new file" > $testroot/repo/new
255 562580bc 2020-01-14 stsp (cd $testroot/repo && git add new)
256 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "new file"
257 562580bc 2020-01-14 stsp local commit_id2=`git_show_head $testroot/repo`
258 562580bc 2020-01-14 stsp
259 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag2)
260 562580bc 2020-01-14 stsp
261 d24820bf 2019-08-11 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
262 d24820bf 2019-08-11 stsp echo -n 'blob - ' >> $testroot/stdout.expected
263 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
264 d24820bf 2019-08-11 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
265 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
266 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
267 d24820bf 2019-08-11 stsp >> $testroot/stdout.expected
268 d24820bf 2019-08-11 stsp echo '--- alpha' >> $testroot/stdout.expected
269 d24820bf 2019-08-11 stsp echo '+++ alpha' >> $testroot/stdout.expected
270 d24820bf 2019-08-11 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
271 d24820bf 2019-08-11 stsp echo '-alpha' >> $testroot/stdout.expected
272 d24820bf 2019-08-11 stsp echo '+modified alpha' >> $testroot/stdout.expected
273 d24820bf 2019-08-11 stsp
274 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
275 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
276 d24820bf 2019-08-11 stsp ret="$?"
277 d24820bf 2019-08-11 stsp if [ "$ret" != "0" ]; then
278 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
279 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
280 d24820bf 2019-08-11 stsp return 1
281 d24820bf 2019-08-11 stsp fi
282 d24820bf 2019-08-11 stsp
283 d24820bf 2019-08-11 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
284 d24820bf 2019-08-11 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
285 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
286 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
287 46f68b20 2019-10-19 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
288 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
289 d24820bf 2019-08-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
290 d24820bf 2019-08-11 stsp echo '+++ new' >> $testroot/stdout.expected
291 d24820bf 2019-08-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
292 d24820bf 2019-08-11 stsp echo '+new file' >> $testroot/stdout.expected
293 d24820bf 2019-08-11 stsp
294 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
295 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
296 d24820bf 2019-08-11 stsp ret="$?"
297 d24820bf 2019-08-11 stsp if [ "$ret" != "0" ]; then
298 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
299 d24820bf 2019-08-11 stsp fi
300 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
301 d24820bf 2019-08-11 stsp }
302 d24820bf 2019-08-11 stsp
303 f6cae3ed 2020-09-13 naddy test_diff_ignore_whitespace() {
304 63035f9f 2019-10-06 stsp local testroot=`test_init diff_ignore_whitespace`
305 63035f9f 2019-10-06 stsp local commit_id0=`git_show_head $testroot/repo`
306 63035f9f 2019-10-06 stsp
307 63035f9f 2019-10-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
308 63035f9f 2019-10-06 stsp ret="$?"
309 63035f9f 2019-10-06 stsp if [ "$ret" != "0" ]; then
310 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
311 63035f9f 2019-10-06 stsp return 1
312 63035f9f 2019-10-06 stsp fi
313 63035f9f 2019-10-06 stsp
314 63035f9f 2019-10-06 stsp echo "alpha " > $testroot/wt/alpha
315 63035f9f 2019-10-06 stsp
316 63035f9f 2019-10-06 stsp (cd $testroot/wt && got diff -w > $testroot/stdout)
317 63035f9f 2019-10-06 stsp
318 63035f9f 2019-10-06 stsp echo "diff $commit_id0 $testroot/wt" > $testroot/stdout.expected
319 63035f9f 2019-10-06 stsp echo -n 'blob - ' >> $testroot/stdout.expected
320 63035f9f 2019-10-06 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
321 63035f9f 2019-10-06 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
322 63035f9f 2019-10-06 stsp echo 'file + alpha' >> $testroot/stdout.expected
323 63035f9f 2019-10-06 stsp
324 63035f9f 2019-10-06 stsp cmp -s $testroot/stdout.expected $testroot/stdout
325 63035f9f 2019-10-06 stsp ret="$?"
326 63035f9f 2019-10-06 stsp if [ "$ret" != "0" ]; then
327 63035f9f 2019-10-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 e7303626 2020-05-14 stsp fi
329 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
330 e7303626 2020-05-14 stsp }
331 e7303626 2020-05-14 stsp
332 f6cae3ed 2020-09-13 naddy test_diff_submodule_of_same_repo() {
333 e7303626 2020-05-14 stsp local testroot=`test_init diff_submodule_of_same_repo`
334 e7303626 2020-05-14 stsp
335 e7303626 2020-05-14 stsp (cd $testroot && git clone -q repo repo2 >/dev/null)
336 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
337 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
338 e7303626 2020-05-14 stsp
339 e7303626 2020-05-14 stsp epsilon_id=$(got tree -r $testroot/repo -i | grep 'epsilon/$' | \
340 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
341 e7303626 2020-05-14 stsp submodule_id=$(got tree -r $testroot/repo -i | grep 'repo2\$$' | \
342 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
343 e7303626 2020-05-14 stsp
344 e7303626 2020-05-14 stsp # Attempt a (nonsensical) diff between a tree object and a submodule.
345 e7303626 2020-05-14 stsp # Currently fails with "wrong type of object" error
346 e7303626 2020-05-14 stsp got diff -r $testroot/repo $epsilon_id $submodule_id \
347 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
348 e7303626 2020-05-14 stsp ret="$?"
349 e7303626 2020-05-14 stsp if [ "$ret" == "0" ]; then
350 e7303626 2020-05-14 stsp echo "diff command succeeded unexpectedly" >&2
351 e7303626 2020-05-14 stsp test_done "$testroot" "1"
352 e7303626 2020-05-14 stsp return 1
353 63035f9f 2019-10-06 stsp fi
354 e7303626 2020-05-14 stsp echo "got: wrong type of object" > $testroot/stderr.expected
355 e7303626 2020-05-14 stsp
356 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
357 e7303626 2020-05-14 stsp ret="$?"
358 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
359 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
360 e7303626 2020-05-14 stsp return 1
361 e7303626 2020-05-14 stsp fi
362 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
363 63035f9f 2019-10-06 stsp }
364 39449a05 2020-07-23 stsp
365 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_work_tree() {
366 39449a05 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_work_tree`
367 39449a05 2020-07-23 stsp
368 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
369 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
370 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
371 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
372 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
373 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
374 39449a05 2020-07-23 stsp (cd $testroot/repo && git add .)
375 39449a05 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
376 39449a05 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
377 39449a05 2020-07-23 stsp
378 39449a05 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
379 39449a05 2020-07-23 stsp ret="$?"
380 39449a05 2020-07-23 stsp if [ "$ret" != "0" ]; then
381 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
382 39449a05 2020-07-23 stsp return 1
383 39449a05 2020-07-23 stsp fi
384 39449a05 2020-07-23 stsp
385 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
386 4135d7d0 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
387 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
388 39449a05 2020-07-23 stsp echo -n '.got/bar' > $testroot/wt/dotgotfoo.link
389 39449a05 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
390 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf epsilon/zeta zeta.link)
391 39449a05 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
392 39449a05 2020-07-23 stsp (cd $testroot/wt && got diff > $testroot/stdout)
393 63035f9f 2019-10-06 stsp
394 39449a05 2020-07-23 stsp echo "diff $commit_id1 $testroot/wt" > $testroot/stdout.expected
395 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
396 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
397 39449a05 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
398 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
399 39449a05 2020-07-23 stsp echo 'file + alpha.link' >> $testroot/stdout.expected
400 39449a05 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
401 39449a05 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
402 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
403 39449a05 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
404 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
405 39449a05 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
406 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
407 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
408 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
409 39449a05 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
410 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
411 39449a05 2020-07-23 stsp echo 'file + dotgotfoo.link' >> $testroot/stdout.expected
412 39449a05 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
413 39449a05 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
414 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
415 39449a05 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
416 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
417 39449a05 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
418 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
419 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
420 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
421 39449a05 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
422 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
423 39449a05 2020-07-23 stsp echo 'file + epsilon/beta.link' >> $testroot/stdout.expected
424 39449a05 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
425 39449a05 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
426 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
427 39449a05 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
428 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
429 39449a05 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
430 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
431 4135d7d0 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
432 4135d7d0 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
433 4135d7d0 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
434 4135d7d0 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
435 4135d7d0 2020-07-23 stsp echo 'file + epsilon.link' >> $testroot/stdout.expected
436 4135d7d0 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
437 4135d7d0 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
438 4135d7d0 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
439 4135d7d0 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
440 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
441 4135d7d0 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
442 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
443 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
444 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
445 39449a05 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
446 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
447 39449a05 2020-07-23 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
448 39449a05 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
449 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
450 39449a05 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
451 39449a05 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
452 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
453 39449a05 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
454 39449a05 2020-07-23 stsp echo 'file + zeta.link' >> $testroot/stdout.expected
455 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
456 40dde666 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
457 40dde666 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
458 40dde666 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
459 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
460 40dde666 2020-07-23 stsp
461 40dde666 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
462 40dde666 2020-07-23 stsp ret="$?"
463 40dde666 2020-07-23 stsp if [ "$ret" != "0" ]; then
464 40dde666 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
465 40dde666 2020-07-23 stsp fi
466 40dde666 2020-07-23 stsp test_done "$testroot" "$ret"
467 40dde666 2020-07-23 stsp }
468 40dde666 2020-07-23 stsp
469 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_repo() {
470 40dde666 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_repo`
471 40dde666 2020-07-23 stsp
472 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
473 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
474 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
475 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
476 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
477 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
478 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
479 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
480 40dde666 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
481 40dde666 2020-07-23 stsp
482 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
483 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sfh gamma epsilon.link)
484 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
485 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar $testroot/repo/dotgotfoo.link)
486 40dde666 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
487 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
488 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
489 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
490 40dde666 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
491 40dde666 2020-07-23 stsp
492 40dde666 2020-07-23 stsp got diff -r $testroot/repo $commit_id1 $commit_id2 > $testroot/stdout
493 40dde666 2020-07-23 stsp
494 40dde666 2020-07-23 stsp echo "diff $commit_id1 $commit_id2" > $testroot/stdout.expected
495 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
496 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
497 40dde666 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
498 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
499 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
500 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
501 40dde666 2020-07-23 stsp grep 'alpha.link@ -> beta$' | \
502 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
503 40dde666 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
504 40dde666 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
505 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
506 40dde666 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
507 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
508 40dde666 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
509 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
510 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
511 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
512 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
513 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
514 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
515 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
516 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/bar$' | \
517 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
518 40dde666 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
519 40dde666 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
520 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
521 40dde666 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
522 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
523 40dde666 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
524 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
525 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
526 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
527 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
528 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
529 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
530 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i epsilon | \
531 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../gamma/delta$' | \
532 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
533 40dde666 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
534 40dde666 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
535 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
536 40dde666 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
537 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
538 40dde666 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
539 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
540 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
541 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
542 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
543 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
544 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
545 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
546 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> gamma$' | \
547 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
548 40dde666 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
549 40dde666 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
550 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
551 40dde666 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
552 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
553 40dde666 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
554 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
555 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
556 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
557 40dde666 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
558 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
559 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
560 40dde666 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
561 40dde666 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
562 40dde666 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
563 40dde666 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
564 40dde666 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
565 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
566 40dde666 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
567 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
568 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
569 40dde666 2020-07-23 stsp grep 'zeta.link@ -> epsilon/zeta$' | \
570 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
571 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
572 40dde666 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
573 39449a05 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
574 39449a05 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
575 39449a05 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
576 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
577 39449a05 2020-07-23 stsp
578 39449a05 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
579 39449a05 2020-07-23 stsp ret="$?"
580 39449a05 2020-07-23 stsp if [ "$ret" != "0" ]; then
581 39449a05 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
582 dffd0deb 2020-11-20 stsp fi
583 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
584 dffd0deb 2020-11-20 stsp }
585 dffd0deb 2020-11-20 stsp
586 dffd0deb 2020-11-20 stsp test_diff_binary_files() {
587 dffd0deb 2020-11-20 stsp local testroot=`test_init diff_binary_files`
588 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
589 dffd0deb 2020-11-20 stsp
590 dffd0deb 2020-11-20 stsp got checkout $testroot/repo $testroot/wt > /dev/null
591 dffd0deb 2020-11-20 stsp ret="$?"
592 dffd0deb 2020-11-20 stsp if [ "$ret" != "0" ]; then
593 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
594 dffd0deb 2020-11-20 stsp return 1
595 dffd0deb 2020-11-20 stsp fi
596 dffd0deb 2020-11-20 stsp
597 dffd0deb 2020-11-20 stsp printf '\377\377\0\0\377\377\0\0' > $testroot/wt/foo
598 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got add foo >/dev/null)
599 64453f7e 2020-11-21 stsp
600 64453f7e 2020-11-21 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
601 64453f7e 2020-11-21 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
602 64453f7e 2020-11-21 stsp echo 'file + foo' >> $testroot/stdout.expected
603 1cb46f00 2020-11-21 stsp echo "Binary files /dev/null and foo differ" \
604 1cb46f00 2020-11-21 stsp >> $testroot/stdout.expected
605 64453f7e 2020-11-21 stsp
606 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff > $testroot/stdout)
607 64453f7e 2020-11-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
608 64453f7e 2020-11-21 stsp ret="$?"
609 64453f7e 2020-11-21 stsp if [ "$ret" != "0" ]; then
610 64453f7e 2020-11-21 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
611 64453f7e 2020-11-21 stsp test_done "$testroot" "$ret"
612 64453f7e 2020-11-21 stsp return 1
613 64453f7e 2020-11-21 stsp fi
614 dffd0deb 2020-11-20 stsp
615 dffd0deb 2020-11-20 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
616 dffd0deb 2020-11-20 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
617 dffd0deb 2020-11-20 stsp echo 'file + foo' >> $testroot/stdout.expected
618 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
619 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
620 dffd0deb 2020-11-20 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
621 dffd0deb 2020-11-20 stsp printf '+\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
622 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
623 dffd0deb 2020-11-20 stsp
624 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
625 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
626 dffd0deb 2020-11-20 stsp ret="$?"
627 dffd0deb 2020-11-20 stsp if [ "$ret" != "0" ]; then
628 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
629 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
630 dffd0deb 2020-11-20 stsp return 1
631 39449a05 2020-07-23 stsp fi
632 dffd0deb 2020-11-20 stsp
633 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
634 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
635 dffd0deb 2020-11-20 stsp
636 dffd0deb 2020-11-20 stsp printf '\377\200\0\0\377\200\0\0' > $testroot/wt/foo
637 dffd0deb 2020-11-20 stsp
638 dffd0deb 2020-11-20 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
639 dffd0deb 2020-11-20 stsp echo -n 'blob - ' >> $testroot/stdout.expected
640 dffd0deb 2020-11-20 stsp got tree -r $testroot/repo -i | grep 'foo$' | cut -d' ' -f 1 \
641 dffd0deb 2020-11-20 stsp >> $testroot/stdout.expected
642 dffd0deb 2020-11-20 stsp echo 'file + foo' >> $testroot/stdout.expected
643 dffd0deb 2020-11-20 stsp echo '--- foo' >> $testroot/stdout.expected
644 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
645 dffd0deb 2020-11-20 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
646 578133c9 2020-11-28 naddy printf -- '-\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
647 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
648 dffd0deb 2020-11-20 stsp printf '+\377\200\0\0\377\200\0\0\n' >> $testroot/stdout.expected
649 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
650 dffd0deb 2020-11-20 stsp
651 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
652 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
653 dffd0deb 2020-11-20 stsp ret="$?"
654 dffd0deb 2020-11-20 stsp if [ "$ret" != "0" ]; then
655 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
656 dffd0deb 2020-11-20 stsp fi
657 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
658 39449a05 2020-07-23 stsp }
659 39449a05 2020-07-23 stsp
660 7fb414ae 2020-08-08 stsp test_parseargs "$@"
661 95adcdca 2019-03-27 stsp run_test test_diff_basic
662 95adcdca 2019-03-27 stsp run_test test_diff_shows_conflict
663 d24820bf 2019-08-11 stsp run_test test_diff_tag
664 562580bc 2020-01-14 stsp run_test test_diff_lightweight_tag
665 63035f9f 2019-10-06 stsp run_test test_diff_ignore_whitespace
666 e7303626 2020-05-14 stsp run_test test_diff_submodule_of_same_repo
667 39449a05 2020-07-23 stsp run_test test_diff_symlinks_in_work_tree
668 40dde666 2020-07-23 stsp run_test test_diff_symlinks_in_repo
669 dffd0deb 2020-11-20 stsp run_test test_diff_binary_files