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