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 &&
25 if test_have_prereq SYMLINKS
28 ln -s ../path1 path2/bazbo
33 printf path0 > path1 &&
34 printf ../path1 > path2/bazbo
36 sed -e "s/120000 /100644 /" >expected
40 echo Mi >path2/baz/b &&
41 find path? \( -type f -o -type l \) -print |
42 xargs git update-index --add &&
43 tree=`git write-tree` &&
47 sed -e "s/ $_x40 / X /" <current >check
48 test_cmp expected check
53 'git ls-tree $tree >current &&
54 make_expected <<\EOF &&
63 'git ls-tree -r $tree >current &&
64 make_expected <<\EOF &&
67 100644 blob X path2/baz/b
68 120000 blob X path2/bazbo
69 100644 blob X path2/foo
74 'ls-tree recursive with -t' \
75 'git ls-tree -r -t $tree >current &&
76 make_expected <<\EOF &&
80 040000 tree X path2/baz
81 100644 blob X path2/baz/b
82 120000 blob X path2/bazbo
83 100644 blob X path2/foo
88 'ls-tree recursive with -d' \
89 'git ls-tree -r -d $tree >current &&
90 make_expected <<\EOF &&
92 040000 tree X path2/baz
97 'ls-tree filtered with path' \
98 'git ls-tree $tree path >current &&
99 make_expected <<\EOF &&
104 # it used to be path1 and then path0, but with pathspec semantics
105 # they are shown in canonical order.
106 test_expect_success \
107 'ls-tree filtered with path1 path0' \
108 'git ls-tree $tree path1 path0 >current &&
109 make_expected <<\EOF &&
115 test_expect_success \
116 'ls-tree filtered with path0/' \
117 'git ls-tree $tree path0/ >current &&
118 make_expected <<\EOF &&
122 # It used to show path2 and its immediate children but
123 # with pathspec semantics it shows only path2
124 test_expect_success \
125 'ls-tree filtered with path2' \
126 'git ls-tree $tree path2 >current &&
127 make_expected <<\EOF &&
132 # ... and path2/ shows the children.
133 test_expect_success \
134 'ls-tree filtered with path2/' \
135 'git ls-tree $tree path2/ >current &&
136 make_expected <<\EOF &&
137 040000 tree X path2/baz
138 120000 blob X path2/bazbo
139 100644 blob X path2/foo
143 # The same change -- exact match does not show children of
145 test_expect_success \
146 'ls-tree filtered with path2/baz' \
147 'git ls-tree $tree path2/baz >current &&
148 make_expected <<\EOF &&
149 040000 tree X path2/baz
153 test_expect_success \
154 'ls-tree filtered with path2/bak' \
155 'git ls-tree $tree path2/bak >current &&
156 make_expected <<\EOF &&
160 test_expect_success \
161 'ls-tree -t filtered with path2/bak' \
162 'git ls-tree -t $tree path2/bak >current &&
163 make_expected <<\EOF &&