[PATCH] mkdelta enhancements (take 2)
[git/dscho.git] / t / t3100-ls-tree-restrict.sh
blob02d93ebe6f5c024b6684e00df5f764cfce1aed1a
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git-ls-tree test.
8 This test runs git-ls-tree with the following in a tree.
10 path0 - a file
11 path1 - a symlink
12 path2/foo - a file in a directory
13 path2/bazbo - a symlink in a directory
14 path2/baz/b - a file in a directory in a directory
16 The new path restriction code should do the right thing for path2 and
17 path2/baz
19 . ./test-lib.sh
21 test_expect_success \
22 'setup' \
23 'mkdir path2 path2/baz &&
24 echo Hi >path0 &&
25 ln -s path0 path1 &&
26 echo Lo >path2/foo &&
27 ln -s ../path1 path2/bazbo &&
28 echo Mi >path2/baz/b &&
29 find path? \( -type f -o -type l \) -print |
30 xargs git-update-cache --add &&
31 tree=`git-write-tree` &&
32 echo $tree'
34 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
35 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
36 test_output () {
37 sed -e "s/ $_x40 / X /" <current >check
38 diff -u expected check
41 test_expect_success \
42 'ls-tree plain' \
43 'git-ls-tree $tree >current &&
44 cat >expected <<\EOF &&
45 100644 blob X path0
46 120000 blob X path1
47 040000 tree X path2
48 EOF
49 test_output'
51 test_expect_success \
52 'ls-tree recursive' \
53 'git-ls-tree -r $tree >current &&
54 cat >expected <<\EOF &&
55 100644 blob X path0
56 120000 blob X path1
57 040000 tree X path2
58 040000 tree X path2/baz
59 100644 blob X path2/baz/b
60 120000 blob X path2/bazbo
61 100644 blob X path2/foo
62 EOF
63 test_output'
65 test_expect_success \
66 'ls-tree filtered' \
67 'git-ls-tree $tree path >current &&
68 cat >expected <<\EOF &&
69 EOF
70 test_output'
73 test_expect_success \
74 'ls-tree filtered' \
75 'git-ls-tree $tree path1 path0 >current &&
76 cat >expected <<\EOF &&
77 120000 blob X path1
78 100644 blob X path0
79 EOF
80 test_output'
82 test_expect_success \
83 'ls-tree filtered' \
84 'git-ls-tree $tree path2 >current &&
85 cat >expected <<\EOF &&
86 040000 tree X path2
87 040000 tree X path2/baz
88 120000 blob X path2/bazbo
89 100644 blob X path2/foo
90 EOF
91 test_output'
93 test_expect_success \
94 'ls-tree filtered' \
95 'git-ls-tree $tree path2/baz >current &&
96 cat >expected <<\EOF &&
97 040000 tree X path2/baz
98 100644 blob X path2/baz/b
99 EOF
100 test_output'
102 test_done