Blob


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