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 diff -u 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 filtered with path' \
65 'git-ls-tree $tree path >current &&
66 cat >expected <<\EOF &&
71 # it used to be path1 and then path0, but with pathspec semantics
72 # they are shown in canonical order.
74 'ls-tree filtered with path1 path0' \
75 'git-ls-tree $tree path1 path0 >current &&
76 cat >expected <<\EOF &&
83 'ls-tree filtered with path0/' \
84 'git-ls-tree $tree path0/ >current &&
85 cat >expected <<\EOF &&
89 # It used to show path2 and its immediate children but
90 # with pathspec semantics it shows only path2
92 'ls-tree filtered with path2' \
93 'git-ls-tree $tree path2 >current &&
94 cat >expected <<\EOF &&
99 # ... and path2/ shows the children.
100 test_expect_success \
101 'ls-tree filtered with path2/' \
102 'git-ls-tree $tree path2/ >current &&
103 cat >expected <<\EOF &&
104 040000 tree X path2/baz
105 120000 blob X path2/bazbo
106 100644 blob X path2/foo
110 # The same change -- exact match does not show children of
112 test_expect_success \
113 'ls-tree filtered with path2/baz' \
114 'git-ls-tree $tree path2/baz >current &&
115 cat >expected <<\EOF &&
116 040000 tree X path2/baz