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 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: $head_rev" \
125 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
126 95adcdca 2019-03-27 stsp echo >> $testroot/stdout.expected
127 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
128 95adcdca 2019-03-27 stsp
129 95adcdca 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
130 95adcdca 2019-03-27 stsp
131 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
132 95adcdca 2019-03-27 stsp ret="$?"
133 95adcdca 2019-03-27 stsp if [ "$ret" != "0" ]; then
134 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
135 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
136 95adcdca 2019-03-27 stsp return 1
137 95adcdca 2019-03-27 stsp fi
138 95adcdca 2019-03-27 stsp
139 95adcdca 2019-03-27 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
140 95adcdca 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
141 95adcdca 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'numbers$' | cut -d' ' -f 1 \
142 95adcdca 2019-03-27 stsp >> $testroot/stdout.expected
143 95adcdca 2019-03-27 stsp echo 'file + numbers' >> $testroot/stdout.expected
144 95adcdca 2019-03-27 stsp echo '--- numbers' >> $testroot/stdout.expected
145 95adcdca 2019-03-27 stsp echo '+++ numbers' >> $testroot/stdout.expected
146 d136cfcb 2019-10-12 stsp echo '@@ -1,8 +1,20 @@' >> $testroot/stdout.expected
147 95adcdca 2019-03-27 stsp echo ' 1' >> $testroot/stdout.expected
148 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
149 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
150 95adcdca 2019-03-27 stsp echo ' 22' >> $testroot/stdout.expected
151 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
152 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
153 d136cfcb 2019-10-12 stsp echo '+2' >> $testroot/stdout.expected
154 95adcdca 2019-03-27 stsp echo '+=======' >> $testroot/stdout.expected
155 95adcdca 2019-03-27 stsp echo '+77' >> $testroot/stdout.expected
156 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
157 95adcdca 2019-03-27 stsp echo ' 3' >> $testroot/stdout.expected
158 95adcdca 2019-03-27 stsp echo ' 4' >> $testroot/stdout.expected
159 95adcdca 2019-03-27 stsp echo ' 5' >> $testroot/stdout.expected
160 d136cfcb 2019-10-12 stsp echo ' 6' >> $testroot/stdout.expected
161 d136cfcb 2019-10-12 stsp echo ' 7' >> $testroot/stdout.expected
162 f69721c3 2019-10-21 stsp echo "+<<<<<<< merged change: commit $head_rev" \
163 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
164 d136cfcb 2019-10-12 stsp echo ' 33' >> $testroot/stdout.expected
165 f69721c3 2019-10-21 stsp echo "+||||||| 3-way merge base: commit $base_commit" \
166 f69721c3 2019-10-21 stsp >> $testroot/stdout.expected
167 d136cfcb 2019-10-12 stsp echo '+8' >> $testroot/stdout.expected
168 d136cfcb 2019-10-12 stsp echo '+=======' >> $testroot/stdout.expected
169 d136cfcb 2019-10-12 stsp echo '+88' >> $testroot/stdout.expected
170 f69721c3 2019-10-21 stsp echo '+>>>>>>>' >> $testroot/stdout.expected
171 95adcdca 2019-03-27 stsp
172 95adcdca 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
173 95adcdca 2019-03-27 stsp
174 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
175 95adcdca 2019-03-27 stsp ret="$?"
176 95adcdca 2019-03-27 stsp if [ "$ret" != "0" ]; then
177 95adcdca 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
178 95adcdca 2019-03-27 stsp fi
179 95adcdca 2019-03-27 stsp test_done "$testroot" "$ret"
180 95adcdca 2019-03-27 stsp }
181 95adcdca 2019-03-27 stsp
182 f6cae3ed 2020-09-13 naddy test_diff_tag() {
183 d24820bf 2019-08-11 stsp local testroot=`test_init diff_tag`
184 d24820bf 2019-08-11 stsp local commit_id0=`git_show_head $testroot/repo`
185 d24820bf 2019-08-11 stsp local tag1=1.0.0
186 d24820bf 2019-08-11 stsp local tag2=2.0.0
187 d24820bf 2019-08-11 stsp
188 d24820bf 2019-08-11 stsp echo "modified alpha" > $testroot/repo/alpha
189 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "changed alpha"
190 d24820bf 2019-08-11 stsp local commit_id1=`git_show_head $testroot/repo`
191 d24820bf 2019-08-11 stsp
192 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag1)
193 d24820bf 2019-08-11 stsp
194 d24820bf 2019-08-11 stsp echo "new file" > $testroot/repo/new
195 d24820bf 2019-08-11 stsp (cd $testroot/repo && git add new)
196 d24820bf 2019-08-11 stsp git_commit $testroot/repo -m "new file"
197 d24820bf 2019-08-11 stsp local commit_id2=`git_show_head $testroot/repo`
198 d24820bf 2019-08-11 stsp
199 d24820bf 2019-08-11 stsp (cd $testroot/repo && git tag -m "test" $tag2)
200 562580bc 2020-01-14 stsp
201 562580bc 2020-01-14 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
202 562580bc 2020-01-14 stsp echo -n 'blob - ' >> $testroot/stdout.expected
203 562580bc 2020-01-14 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
204 562580bc 2020-01-14 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
205 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
206 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
207 562580bc 2020-01-14 stsp >> $testroot/stdout.expected
208 562580bc 2020-01-14 stsp echo '--- alpha' >> $testroot/stdout.expected
209 562580bc 2020-01-14 stsp echo '+++ alpha' >> $testroot/stdout.expected
210 562580bc 2020-01-14 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
211 562580bc 2020-01-14 stsp echo '-alpha' >> $testroot/stdout.expected
212 562580bc 2020-01-14 stsp echo '+modified alpha' >> $testroot/stdout.expected
213 562580bc 2020-01-14 stsp
214 562580bc 2020-01-14 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
215 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
216 562580bc 2020-01-14 stsp ret="$?"
217 562580bc 2020-01-14 stsp if [ "$ret" != "0" ]; then
218 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
219 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
220 562580bc 2020-01-14 stsp return 1
221 562580bc 2020-01-14 stsp fi
222 562580bc 2020-01-14 stsp
223 562580bc 2020-01-14 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
224 562580bc 2020-01-14 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
225 562580bc 2020-01-14 stsp echo -n 'blob + ' >> $testroot/stdout.expected
226 562580bc 2020-01-14 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
227 562580bc 2020-01-14 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
228 562580bc 2020-01-14 stsp echo " (mode 644)" >> $testroot/stdout.expected
229 562580bc 2020-01-14 stsp echo '--- /dev/null' >> $testroot/stdout.expected
230 562580bc 2020-01-14 stsp echo '+++ new' >> $testroot/stdout.expected
231 562580bc 2020-01-14 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
232 562580bc 2020-01-14 stsp echo '+new file' >> $testroot/stdout.expected
233 d24820bf 2019-08-11 stsp
234 562580bc 2020-01-14 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
235 562580bc 2020-01-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
236 562580bc 2020-01-14 stsp ret="$?"
237 562580bc 2020-01-14 stsp if [ "$ret" != "0" ]; then
238 562580bc 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
239 562580bc 2020-01-14 stsp fi
240 562580bc 2020-01-14 stsp test_done "$testroot" "$ret"
241 562580bc 2020-01-14 stsp }
242 562580bc 2020-01-14 stsp
243 f6cae3ed 2020-09-13 naddy test_diff_lightweight_tag() {
244 562580bc 2020-01-14 stsp local testroot=`test_init diff_tag`
245 562580bc 2020-01-14 stsp local commit_id0=`git_show_head $testroot/repo`
246 562580bc 2020-01-14 stsp local tag1=1.0.0
247 562580bc 2020-01-14 stsp local tag2=2.0.0
248 562580bc 2020-01-14 stsp
249 562580bc 2020-01-14 stsp echo "modified alpha" > $testroot/repo/alpha
250 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "changed alpha"
251 562580bc 2020-01-14 stsp local commit_id1=`git_show_head $testroot/repo`
252 562580bc 2020-01-14 stsp
253 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag1)
254 562580bc 2020-01-14 stsp
255 562580bc 2020-01-14 stsp echo "new file" > $testroot/repo/new
256 562580bc 2020-01-14 stsp (cd $testroot/repo && git add new)
257 562580bc 2020-01-14 stsp git_commit $testroot/repo -m "new file"
258 562580bc 2020-01-14 stsp local commit_id2=`git_show_head $testroot/repo`
259 562580bc 2020-01-14 stsp
260 562580bc 2020-01-14 stsp (cd $testroot/repo && git tag $tag2)
261 562580bc 2020-01-14 stsp
262 d24820bf 2019-08-11 stsp echo "diff $commit_id0 refs/tags/$tag1" > $testroot/stdout.expected
263 d24820bf 2019-08-11 stsp echo -n 'blob - ' >> $testroot/stdout.expected
264 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
265 d24820bf 2019-08-11 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
266 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
267 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i | grep 'alpha$' | cut -d' ' -f 1 \
268 d24820bf 2019-08-11 stsp >> $testroot/stdout.expected
269 d24820bf 2019-08-11 stsp echo '--- alpha' >> $testroot/stdout.expected
270 d24820bf 2019-08-11 stsp echo '+++ alpha' >> $testroot/stdout.expected
271 d24820bf 2019-08-11 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
272 d24820bf 2019-08-11 stsp echo '-alpha' >> $testroot/stdout.expected
273 d24820bf 2019-08-11 stsp echo '+modified alpha' >> $testroot/stdout.expected
274 d24820bf 2019-08-11 stsp
275 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $commit_id0 $tag1 > $testroot/stdout
276 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
277 d24820bf 2019-08-11 stsp ret="$?"
278 d24820bf 2019-08-11 stsp if [ "$ret" != "0" ]; then
279 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
280 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
281 d24820bf 2019-08-11 stsp return 1
282 d24820bf 2019-08-11 stsp fi
283 d24820bf 2019-08-11 stsp
284 d24820bf 2019-08-11 stsp echo "diff refs/tags/$tag1 refs/tags/$tag2" > $testroot/stdout.expected
285 d24820bf 2019-08-11 stsp echo "blob - /dev/null" >> $testroot/stdout.expected
286 d24820bf 2019-08-11 stsp echo -n 'blob + ' >> $testroot/stdout.expected
287 d24820bf 2019-08-11 stsp got tree -r $testroot/repo -i -c $commit_id2 | grep 'new$' | \
288 46f68b20 2019-10-19 stsp cut -d' ' -f 1 | tr -d '\n' >> $testroot/stdout.expected
289 46f68b20 2019-10-19 stsp echo " (mode 644)" >> $testroot/stdout.expected
290 d24820bf 2019-08-11 stsp echo '--- /dev/null' >> $testroot/stdout.expected
291 d24820bf 2019-08-11 stsp echo '+++ new' >> $testroot/stdout.expected
292 d24820bf 2019-08-11 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
293 d24820bf 2019-08-11 stsp echo '+new file' >> $testroot/stdout.expected
294 d24820bf 2019-08-11 stsp
295 d24820bf 2019-08-11 stsp got diff -r $testroot/repo $tag1 $tag2 > $testroot/stdout
296 d24820bf 2019-08-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
297 d24820bf 2019-08-11 stsp ret="$?"
298 d24820bf 2019-08-11 stsp if [ "$ret" != "0" ]; then
299 d24820bf 2019-08-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
300 d24820bf 2019-08-11 stsp fi
301 d24820bf 2019-08-11 stsp test_done "$testroot" "$ret"
302 d24820bf 2019-08-11 stsp }
303 d24820bf 2019-08-11 stsp
304 f6cae3ed 2020-09-13 naddy test_diff_ignore_whitespace() {
305 63035f9f 2019-10-06 stsp local testroot=`test_init diff_ignore_whitespace`
306 63035f9f 2019-10-06 stsp local commit_id0=`git_show_head $testroot/repo`
307 63035f9f 2019-10-06 stsp
308 63035f9f 2019-10-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
309 63035f9f 2019-10-06 stsp ret="$?"
310 63035f9f 2019-10-06 stsp if [ "$ret" != "0" ]; then
311 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
312 63035f9f 2019-10-06 stsp return 1
313 63035f9f 2019-10-06 stsp fi
314 63035f9f 2019-10-06 stsp
315 63035f9f 2019-10-06 stsp echo "alpha " > $testroot/wt/alpha
316 63035f9f 2019-10-06 stsp
317 63035f9f 2019-10-06 stsp (cd $testroot/wt && got diff -w > $testroot/stdout)
318 63035f9f 2019-10-06 stsp
319 63035f9f 2019-10-06 stsp echo "diff $commit_id0 $testroot/wt" > $testroot/stdout.expected
320 63035f9f 2019-10-06 stsp echo -n 'blob - ' >> $testroot/stdout.expected
321 63035f9f 2019-10-06 stsp got tree -r $testroot/repo -c $commit_id0 -i | grep 'alpha$' | \
322 63035f9f 2019-10-06 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
323 63035f9f 2019-10-06 stsp echo 'file + alpha' >> $testroot/stdout.expected
324 63035f9f 2019-10-06 stsp
325 63035f9f 2019-10-06 stsp cmp -s $testroot/stdout.expected $testroot/stdout
326 63035f9f 2019-10-06 stsp ret="$?"
327 63035f9f 2019-10-06 stsp if [ "$ret" != "0" ]; then
328 63035f9f 2019-10-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
329 e7303626 2020-05-14 stsp fi
330 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
331 e7303626 2020-05-14 stsp }
332 e7303626 2020-05-14 stsp
333 f6cae3ed 2020-09-13 naddy test_diff_submodule_of_same_repo() {
334 e7303626 2020-05-14 stsp local testroot=`test_init diff_submodule_of_same_repo`
335 e7303626 2020-05-14 stsp
336 e7303626 2020-05-14 stsp (cd $testroot && git clone -q repo repo2 >/dev/null)
337 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
338 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
339 e7303626 2020-05-14 stsp
340 e7303626 2020-05-14 stsp epsilon_id=$(got tree -r $testroot/repo -i | grep 'epsilon/$' | \
341 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
342 e7303626 2020-05-14 stsp submodule_id=$(got tree -r $testroot/repo -i | grep 'repo2\$$' | \
343 e7303626 2020-05-14 stsp cut -d ' ' -f 1)
344 e7303626 2020-05-14 stsp
345 e7303626 2020-05-14 stsp # Attempt a (nonsensical) diff between a tree object and a submodule.
346 e7303626 2020-05-14 stsp # Currently fails with "wrong type of object" error
347 e7303626 2020-05-14 stsp got diff -r $testroot/repo $epsilon_id $submodule_id \
348 e7303626 2020-05-14 stsp > $testroot/stdout 2> $testroot/stderr
349 e7303626 2020-05-14 stsp ret="$?"
350 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
351 e7303626 2020-05-14 stsp echo "diff command succeeded unexpectedly" >&2
352 e7303626 2020-05-14 stsp test_done "$testroot" "1"
353 e7303626 2020-05-14 stsp return 1
354 63035f9f 2019-10-06 stsp fi
355 e7303626 2020-05-14 stsp echo "got: wrong type of object" > $testroot/stderr.expected
356 e7303626 2020-05-14 stsp
357 e7303626 2020-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
358 e7303626 2020-05-14 stsp ret="$?"
359 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
360 e7303626 2020-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
361 e7303626 2020-05-14 stsp return 1
362 e7303626 2020-05-14 stsp fi
363 63035f9f 2019-10-06 stsp test_done "$testroot" "$ret"
364 63035f9f 2019-10-06 stsp }
365 39449a05 2020-07-23 stsp
366 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_work_tree() {
367 39449a05 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_work_tree`
368 39449a05 2020-07-23 stsp
369 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
370 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
371 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
372 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
373 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
374 39449a05 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
375 39449a05 2020-07-23 stsp (cd $testroot/repo && git add .)
376 39449a05 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
377 39449a05 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
378 39449a05 2020-07-23 stsp
379 39449a05 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
380 39449a05 2020-07-23 stsp ret="$?"
381 39449a05 2020-07-23 stsp if [ "$ret" != "0" ]; then
382 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
383 39449a05 2020-07-23 stsp return 1
384 39449a05 2020-07-23 stsp fi
385 39449a05 2020-07-23 stsp
386 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
387 dd6165e4 2021-09-21 thomas.ad (cd $testroot/wt && ln -sfT gamma epsilon.link)
388 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf ../gamma/delta epsilon/beta.link)
389 39449a05 2020-07-23 stsp echo -n '.got/bar' > $testroot/wt/dotgotfoo.link
390 39449a05 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
391 39449a05 2020-07-23 stsp (cd $testroot/wt && ln -sf epsilon/zeta zeta.link)
392 39449a05 2020-07-23 stsp (cd $testroot/wt && got add zeta.link > /dev/null)
393 39449a05 2020-07-23 stsp (cd $testroot/wt && got diff > $testroot/stdout)
394 63035f9f 2019-10-06 stsp
395 39449a05 2020-07-23 stsp echo "diff $commit_id1 $testroot/wt" > $testroot/stdout.expected
396 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
397 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
398 39449a05 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
399 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
400 39449a05 2020-07-23 stsp echo 'file + alpha.link' >> $testroot/stdout.expected
401 39449a05 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
402 39449a05 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
403 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
404 39449a05 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
405 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
406 39449a05 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
407 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
408 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
409 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
410 39449a05 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
411 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
412 39449a05 2020-07-23 stsp echo 'file + dotgotfoo.link' >> $testroot/stdout.expected
413 39449a05 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
414 39449a05 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
415 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
416 39449a05 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
417 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
418 39449a05 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
419 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
420 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
421 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
422 39449a05 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
423 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
424 39449a05 2020-07-23 stsp echo 'file + 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 '+++ epsilon/beta.link' >> $testroot/stdout.expected
427 39449a05 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
428 39449a05 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
429 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
430 39449a05 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
431 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
432 4135d7d0 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
433 4135d7d0 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
434 4135d7d0 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
435 4135d7d0 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
436 4135d7d0 2020-07-23 stsp echo 'file + epsilon.link' >> $testroot/stdout.expected
437 4135d7d0 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
438 4135d7d0 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
439 4135d7d0 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
440 4135d7d0 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
441 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
442 4135d7d0 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
443 4135d7d0 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
444 39449a05 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
445 39449a05 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
446 39449a05 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
447 39449a05 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
448 39449a05 2020-07-23 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
449 39449a05 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
450 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
451 39449a05 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
452 39449a05 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
453 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
454 39449a05 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
455 39449a05 2020-07-23 stsp echo 'file + zeta.link' >> $testroot/stdout.expected
456 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
457 40dde666 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
458 40dde666 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
459 40dde666 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
460 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
461 40dde666 2020-07-23 stsp
462 40dde666 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
463 40dde666 2020-07-23 stsp ret="$?"
464 40dde666 2020-07-23 stsp if [ "$ret" != "0" ]; then
465 40dde666 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
466 40dde666 2020-07-23 stsp fi
467 40dde666 2020-07-23 stsp test_done "$testroot" "$ret"
468 40dde666 2020-07-23 stsp }
469 40dde666 2020-07-23 stsp
470 f6cae3ed 2020-09-13 naddy test_diff_symlinks_in_repo() {
471 40dde666 2020-07-23 stsp local testroot=`test_init diff_symlinks_in_repo`
472 40dde666 2020-07-23 stsp
473 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
474 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
475 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
476 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
477 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
478 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
479 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
480 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
481 40dde666 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
482 40dde666 2020-07-23 stsp
483 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
484 dd6165e4 2021-09-21 thomas.ad (cd $testroot/repo && ln -sfT gamma epsilon.link)
485 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
486 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar $testroot/repo/dotgotfoo.link)
487 40dde666 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
488 40dde666 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
489 40dde666 2020-07-23 stsp (cd $testroot/repo && git add .)
490 40dde666 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
491 40dde666 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
492 40dde666 2020-07-23 stsp
493 40dde666 2020-07-23 stsp got diff -r $testroot/repo $commit_id1 $commit_id2 > $testroot/stdout
494 40dde666 2020-07-23 stsp
495 40dde666 2020-07-23 stsp echo "diff $commit_id1 $commit_id2" > $testroot/stdout.expected
496 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
497 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
498 40dde666 2020-07-23 stsp grep 'alpha.link@ -> alpha$' | \
499 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
500 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
501 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
502 40dde666 2020-07-23 stsp grep 'alpha.link@ -> beta$' | \
503 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
504 40dde666 2020-07-23 stsp echo '--- alpha.link' >> $testroot/stdout.expected
505 40dde666 2020-07-23 stsp echo '+++ alpha.link' >> $testroot/stdout.expected
506 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
507 40dde666 2020-07-23 stsp echo '-alpha' >> $testroot/stdout.expected
508 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
509 40dde666 2020-07-23 stsp echo '+beta' >> $testroot/stdout.expected
510 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
511 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
512 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
513 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/foo$' | \
514 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
515 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
516 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
517 40dde666 2020-07-23 stsp grep 'dotgotfoo.link@ -> .got/bar$' | \
518 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
519 40dde666 2020-07-23 stsp echo '--- dotgotfoo.link' >> $testroot/stdout.expected
520 40dde666 2020-07-23 stsp echo '+++ dotgotfoo.link' >> $testroot/stdout.expected
521 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
522 40dde666 2020-07-23 stsp echo '-.got/foo' >> $testroot/stdout.expected
523 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
524 40dde666 2020-07-23 stsp echo '+.got/bar' >> $testroot/stdout.expected
525 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
526 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
527 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i epsilon | \
528 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../beta$' | \
529 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
530 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
531 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i epsilon | \
532 40dde666 2020-07-23 stsp grep 'beta.link@ -> ../gamma/delta$' | \
533 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
534 40dde666 2020-07-23 stsp echo '--- epsilon/beta.link' >> $testroot/stdout.expected
535 40dde666 2020-07-23 stsp echo '+++ epsilon/beta.link' >> $testroot/stdout.expected
536 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
537 40dde666 2020-07-23 stsp echo '-../beta' >> $testroot/stdout.expected
538 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
539 40dde666 2020-07-23 stsp echo '+../gamma/delta' >> $testroot/stdout.expected
540 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
541 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
542 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
543 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> epsilon$' | \
544 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
545 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
546 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
547 40dde666 2020-07-23 stsp grep 'epsilon.link@ -> gamma$' | \
548 40dde666 2020-07-23 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
549 40dde666 2020-07-23 stsp echo '--- epsilon.link' >> $testroot/stdout.expected
550 40dde666 2020-07-23 stsp echo '+++ epsilon.link' >> $testroot/stdout.expected
551 40dde666 2020-07-23 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
552 40dde666 2020-07-23 stsp echo '-epsilon' >> $testroot/stdout.expected
553 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
554 40dde666 2020-07-23 stsp echo '+gamma' >> $testroot/stdout.expected
555 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
556 40dde666 2020-07-23 stsp echo -n 'blob - ' >> $testroot/stdout.expected
557 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id1 -i | \
558 40dde666 2020-07-23 stsp grep 'nonexistent.link@ -> nonexistent$' | \
559 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
560 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
561 40dde666 2020-07-23 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
562 40dde666 2020-07-23 stsp echo '--- nonexistent.link' >> $testroot/stdout.expected
563 40dde666 2020-07-23 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
564 40dde666 2020-07-23 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
565 40dde666 2020-07-23 stsp echo '-nonexistent' >> $testroot/stdout.expected
566 40dde666 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
567 40dde666 2020-07-23 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
568 40dde666 2020-07-23 stsp echo -n 'blob + ' >> $testroot/stdout.expected
569 40dde666 2020-07-23 stsp got tree -r $testroot/repo -c $commit_id2 -i | \
570 40dde666 2020-07-23 stsp grep 'zeta.link@ -> epsilon/zeta$' | \
571 40dde666 2020-07-23 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 120000)/' \
572 40dde666 2020-07-23 stsp >> $testroot/stdout.expected
573 40dde666 2020-07-23 stsp echo '--- /dev/null' >> $testroot/stdout.expected
574 39449a05 2020-07-23 stsp echo '+++ zeta.link' >> $testroot/stdout.expected
575 39449a05 2020-07-23 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
576 39449a05 2020-07-23 stsp echo '+epsilon/zeta' >> $testroot/stdout.expected
577 39449a05 2020-07-23 stsp echo '\ No newline at end of file' >> $testroot/stdout.expected
578 39449a05 2020-07-23 stsp
579 39449a05 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
580 39449a05 2020-07-23 stsp ret="$?"
581 39449a05 2020-07-23 stsp if [ "$ret" != "0" ]; then
582 39449a05 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
583 dffd0deb 2020-11-20 stsp fi
584 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
585 dffd0deb 2020-11-20 stsp }
586 dffd0deb 2020-11-20 stsp
587 dffd0deb 2020-11-20 stsp test_diff_binary_files() {
588 dffd0deb 2020-11-20 stsp local testroot=`test_init diff_binary_files`
589 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
590 dffd0deb 2020-11-20 stsp
591 dffd0deb 2020-11-20 stsp got checkout $testroot/repo $testroot/wt > /dev/null
592 dffd0deb 2020-11-20 stsp ret="$?"
593 dffd0deb 2020-11-20 stsp if [ "$ret" != "0" ]; then
594 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
595 dffd0deb 2020-11-20 stsp return 1
596 dffd0deb 2020-11-20 stsp fi
597 dffd0deb 2020-11-20 stsp
598 dffd0deb 2020-11-20 stsp printf '\377\377\0\0\377\377\0\0' > $testroot/wt/foo
599 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got add foo >/dev/null)
600 64453f7e 2020-11-21 stsp
601 64453f7e 2020-11-21 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
602 64453f7e 2020-11-21 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
603 64453f7e 2020-11-21 stsp echo 'file + foo' >> $testroot/stdout.expected
604 1cb46f00 2020-11-21 stsp echo "Binary files /dev/null and foo differ" \
605 1cb46f00 2020-11-21 stsp >> $testroot/stdout.expected
606 64453f7e 2020-11-21 stsp
607 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff > $testroot/stdout)
608 64453f7e 2020-11-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
609 64453f7e 2020-11-21 stsp ret="$?"
610 64453f7e 2020-11-21 stsp if [ "$ret" != "0" ]; then
611 64453f7e 2020-11-21 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
612 64453f7e 2020-11-21 stsp test_done "$testroot" "$ret"
613 64453f7e 2020-11-21 stsp return 1
614 64453f7e 2020-11-21 stsp fi
615 dffd0deb 2020-11-20 stsp
616 dffd0deb 2020-11-20 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
617 dffd0deb 2020-11-20 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
618 dffd0deb 2020-11-20 stsp echo 'file + foo' >> $testroot/stdout.expected
619 1cb46f00 2020-11-21 stsp echo '--- /dev/null' >> $testroot/stdout.expected
620 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
621 dffd0deb 2020-11-20 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
622 dffd0deb 2020-11-20 stsp printf '+\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
623 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
624 dffd0deb 2020-11-20 stsp
625 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
626 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
627 dffd0deb 2020-11-20 stsp ret="$?"
628 dffd0deb 2020-11-20 stsp if [ "$ret" != "0" ]; then
629 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
630 dffd0deb 2020-11-20 stsp test_done "$testroot" "$ret"
631 dffd0deb 2020-11-20 stsp return 1
632 39449a05 2020-07-23 stsp fi
633 dffd0deb 2020-11-20 stsp
634 dffd0deb 2020-11-20 stsp (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
635 dffd0deb 2020-11-20 stsp local head_rev=`git_show_head $testroot/repo`
636 dffd0deb 2020-11-20 stsp
637 dffd0deb 2020-11-20 stsp printf '\377\200\0\0\377\200\0\0' > $testroot/wt/foo
638 dffd0deb 2020-11-20 stsp
639 dffd0deb 2020-11-20 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
640 dffd0deb 2020-11-20 stsp echo -n 'blob - ' >> $testroot/stdout.expected
641 dffd0deb 2020-11-20 stsp got tree -r $testroot/repo -i | grep 'foo$' | cut -d' ' -f 1 \
642 dffd0deb 2020-11-20 stsp >> $testroot/stdout.expected
643 dffd0deb 2020-11-20 stsp echo 'file + foo' >> $testroot/stdout.expected
644 dffd0deb 2020-11-20 stsp echo '--- foo' >> $testroot/stdout.expected
645 dffd0deb 2020-11-20 stsp echo '+++ foo' >> $testroot/stdout.expected
646 dffd0deb 2020-11-20 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
647 578133c9 2020-11-28 naddy printf -- '-\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
648 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
649 dffd0deb 2020-11-20 stsp printf '+\377\200\0\0\377\200\0\0\n' >> $testroot/stdout.expected
650 578133c9 2020-11-28 naddy printf '\\ No newline at end of file\n' >> $testroot/stdout.expected
651 dffd0deb 2020-11-20 stsp
652 64453f7e 2020-11-21 stsp (cd $testroot/wt && got diff -a > $testroot/stdout)
653 dffd0deb 2020-11-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
654 dffd0deb 2020-11-20 stsp ret="$?"
655 dffd0deb 2020-11-20 stsp if [ "$ret" != "0" ]; then
656 dffd0deb 2020-11-20 stsp diff -a -u $testroot/stdout.expected $testroot/stdout
657 dffd0deb 2020-11-20 stsp fi
658 39449a05 2020-07-23 stsp test_done "$testroot" "$ret"
659 39449a05 2020-07-23 stsp }
660 39449a05 2020-07-23 stsp
661 7fb414ae 2020-08-08 stsp test_parseargs "$@"
662 95adcdca 2019-03-27 stsp run_test test_diff_basic
663 95adcdca 2019-03-27 stsp run_test test_diff_shows_conflict
664 d24820bf 2019-08-11 stsp run_test test_diff_tag
665 562580bc 2020-01-14 stsp run_test test_diff_lightweight_tag
666 63035f9f 2019-10-06 stsp run_test test_diff_ignore_whitespace
667 e7303626 2020-05-14 stsp run_test test_diff_submodule_of_same_repo
668 39449a05 2020-07-23 stsp run_test test_diff_symlinks_in_work_tree
669 40dde666 2020-07-23 stsp run_test test_diff_symlinks_in_repo
670 dffd0deb 2020-11-20 stsp run_test test_diff_binary_files