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.
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. Also path0/ should snow nothing.
23 'mkdir path2 path2/baz &&
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-index --add &&
31 tree=`git write-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"
37 sed -e "s/ $_x40 / X /" <current >check
38 git diff expected check
43 'git ls-tree $tree >current &&
44 cat >expected <<\EOF &&
53 'git ls-tree -r $tree >current &&
54 cat >expected <<\EOF &&
57 100644 blob X path2/baz/b
58 120000 blob X path2/bazbo
59 100644 blob X path2/foo
64 'ls-tree recursive with -t' \
65 'git ls-tree -r -t $tree >current &&
66 cat >expected <<\EOF &&
70 040000 tree X path2/baz
71 100644 blob X path2/baz/b
72 120000 blob X path2/bazbo
73 100644 blob X path2/foo
78 'ls-tree recursive with -d' \
79 'git ls-tree -r -d $tree >current &&
80 cat >expected <<\EOF &&
82 040000 tree X path2/baz
87 'ls-tree filtered with path' \
88 'git ls-tree $tree path >current &&
89 cat >expected <<\EOF &&
94 # it used to be path1 and then path0, but with pathspec semantics
95 # they are shown in canonical order.
97 'ls-tree filtered with path1 path0' \
98 'git ls-tree $tree path1 path0 >current &&
99 cat >expected <<\EOF &&
105 test_expect_success \
106 'ls-tree filtered with path0/' \
107 'git ls-tree $tree path0/ >current &&
108 cat >expected <<\EOF &&
112 # It used to show path2 and its immediate children but
113 # with pathspec semantics it shows only path2
114 test_expect_success \
115 'ls-tree filtered with path2' \
116 'git ls-tree $tree path2 >current &&
117 cat >expected <<\EOF &&
122 # ... and path2/ shows the children.
123 test_expect_success \
124 'ls-tree filtered with path2/' \
125 'git ls-tree $tree path2/ >current &&
126 cat >expected <<\EOF &&
127 040000 tree X path2/baz
128 120000 blob X path2/bazbo
129 100644 blob X path2/foo
133 # The same change -- exact match does not show children of
135 test_expect_success \
136 'ls-tree filtered with path2/baz' \
137 'git ls-tree $tree path2/baz >current &&
138 cat >expected <<\EOF &&
139 040000 tree X path2/baz
143 test_expect_success \
144 'ls-tree filtered with path2/bak' \
145 'git ls-tree $tree path2/bak >current &&
146 cat >expected <<\EOF &&
150 test_expect_success \
151 'ls-tree -t filtered with path2/bak' \
152 'git ls-tree -t $tree path2/bak >current &&
153 cat >expected <<\EOF &&