]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t3101-ls-tree-dirname.sh
3 # Copyright (c) 2005 Junio C Hamano
4 # Copyright (c) 2005 Robert Fitzsimons
7 test_description
='git ls-tree directory and filenames handling.
9 This test runs git ls-tree with the following in a tree.
13 path0/a/b/c/1.txt - a file in a directory
14 path1/b/c/1.txt - a file in a directory
15 path2/1.txt - a file in a directory
16 path3/1.txt - a file in a directory
17 path3/2.txt - a file in a directory
19 Test the handling of multiple directories which have matching file
20 entries. Also test odd filename and missing entries handling.
24 test_expect_success
'setup' '
27 mkdir path0 path0/a path0/a/b path0/a/b/c &&
28 echo 111 >path0/a/b/c/1.txt &&
29 mkdir path1 path1/b path1/b/c &&
30 echo 111 >path1/b/c/1.txt &&
32 echo 111 >path2/1.txt &&
34 echo 111 >path3/1.txt &&
35 echo 222 >path3/2.txt &&
36 find *.txt path* \( -type f -o -type l \) -print |
37 xargs git update-index --add &&
38 tree=$(git write-tree) &&
43 sed -e "s/ $OID_REGEX / X /" <current
>check
&&
44 test_cmp expected check
47 test_expect_success
'ls-tree plain' '
48 git ls-tree $tree >current &&
49 cat >expected <<\EOF &&
60 # Recursive does not show tree nodes anymore...
61 test_expect_success
'ls-tree recursive' '
62 git ls-tree -r $tree >current &&
63 cat >expected <<\EOF &&
66 100644 blob X path0/a/b/c/1.txt
67 100644 blob X path1/b/c/1.txt
68 100644 blob X path2/1.txt
69 100644 blob X path3/1.txt
70 100644 blob X path3/2.txt
75 test_expect_success
'ls-tree filter 1.txt' '
76 git ls-tree $tree 1.txt >current &&
77 cat >expected <<\EOF &&
83 test_expect_success
'ls-tree filter path1/b/c/1.txt' '
84 git ls-tree $tree path1/b/c/1.txt >current &&
85 cat >expected <<\EOF &&
86 100644 blob X path1/b/c/1.txt
91 test_expect_success
'ls-tree filter all 1.txt files' '
92 git ls-tree $tree 1.txt path0/a/b/c/1.txt \
93 path1/b/c/1.txt path2/1.txt path3/1.txt >current &&
94 cat >expected <<\EOF &&
96 100644 blob X path0/a/b/c/1.txt
97 100644 blob X path1/b/c/1.txt
98 100644 blob X path2/1.txt
99 100644 blob X path3/1.txt
104 # I am not so sure about this one after ls-tree doing pathspec match.
105 # Having both path0/a and path0/a/b/c makes path0/a redundant, and
106 # it behaves as if path0/a/b/c, path1/b/c, path2 and path3 are specified.
107 test_expect_success
'ls-tree filter directories' '
108 git ls-tree $tree path3 path2 path0/a/b/c path1/b/c path0/a >current &&
109 cat >expected <<\EOF &&
110 040000 tree X path0/a/b/c
111 040000 tree X path1/b/c
118 # Again, duplicates are filtered away so this is equivalent to
119 # having 1.txt and path3
120 test_expect_success
'ls-tree filter odd names' '
121 git ls-tree $tree 1.txt ./1.txt .//1.txt \
122 path3/1.txt path3/./1.txt path3 path3// >current &&
123 cat >expected <<\EOF &&
125 100644 blob X path3/1.txt
126 100644 blob X path3/2.txt
131 test_expect_success
'ls-tree filter missing files and extra slashes' '
132 git ls-tree $tree 1.txt/ abc.txt \
133 path3//23.txt path3/2.txt/// >current &&
138 test_expect_success
'ls-tree filter is leading path match' '
139 git ls-tree $tree pa path3/a >current &&
144 test_expect_success
'ls-tree --full-name' '
147 git ls-tree --full-name $tree a
149 cat >expected <<\EOF &&
150 040000 tree X path0/a
155 test_expect_success
'ls-tree --full-tree' '
158 git ls-tree --full-tree $tree
160 cat >expected <<\EOF &&
171 test_expect_success
'ls-tree --full-tree -r' '
174 git ls-tree --full-tree -r $tree
176 cat >expected <<\EOF &&
179 100644 blob X path0/a/b/c/1.txt
180 100644 blob X path1/b/c/1.txt
181 100644 blob X path2/1.txt
182 100644 blob X path3/1.txt
183 100644 blob X path3/2.txt
188 test_expect_success
'ls-tree --abbrev=5' '
189 git ls-tree --abbrev=5 $tree >current &&
190 sed -e "s/ $_x05[0-9a-f]* / X /" <current >check &&
191 cat >expected <<\EOF &&
199 test_cmp expected check
202 test_expect_success
'ls-tree --name-only' '
203 git ls-tree --name-only $tree >current &&
204 cat >expected <<\EOF &&
215 test_expect_success
'ls-tree --name-only -r' '
216 git ls-tree --name-only -r $tree >current &&
217 cat >expected <<\EOF &&