Teach "approxidate" about weekday syntax
[git.git] / t / t3101-ls-tree-dirname.sh
blob54103683480eb5f2a18ceac3f1018769ea31b18f
1 #!/bin/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.
11 1.txt - a file
12 2.txt - a file
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 mulitple directories which have matching file
20 entries. Also test odd filename and missing entries handling.
22 . ./test-lib.sh
24 test_expect_success \
25 'setup' \
26 'echo 111 >1.txt &&
27 echo 222 >2.txt &&
28 mkdir path0 path0/a path0/a/b path0/a/b/c &&
29 echo 111 >path0/a/b/c/1.txt &&
30 mkdir path1 path1/b path1/b/c &&
31 echo 111 >path1/b/c/1.txt &&
32 mkdir path2 &&
33 echo 111 >path2/1.txt &&
34 mkdir path3 &&
35 echo 111 >path3/1.txt &&
36 echo 222 >path3/2.txt &&
37 find *.txt path* \( -type f -o -type l \) -print |
38 xargs git-update-index --add &&
39 tree=`git-write-tree` &&
40 echo $tree'
42 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
43 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
44 test_output () {
45 sed -e "s/ $_x40 / X /" <current >check
46 diff -u expected check
49 test_expect_success \
50 'ls-tree plain' \
51 'git-ls-tree $tree >current &&
52 cat >expected <<\EOF &&
53 100644 blob X 1.txt
54 100644 blob X 2.txt
55 040000 tree X path0
56 040000 tree X path1
57 040000 tree X path2
58 040000 tree X path3
59 EOF
60 test_output'
62 test_expect_success \
63 'ls-tree recursive' \
64 'git-ls-tree -r $tree >current &&
65 cat >expected <<\EOF &&
66 100644 blob X 1.txt
67 100644 blob X 2.txt
68 040000 tree X path0
69 040000 tree X path0/a
70 040000 tree X path0/a/b
71 040000 tree X path0/a/b/c
72 100644 blob X path0/a/b/c/1.txt
73 040000 tree X path1
74 040000 tree X path1/b
75 040000 tree X path1/b/c
76 100644 blob X path1/b/c/1.txt
77 040000 tree X path2
78 100644 blob X path2/1.txt
79 040000 tree X path3
80 100644 blob X path3/1.txt
81 100644 blob X path3/2.txt
82 EOF
83 test_output'
85 test_expect_success \
86 'ls-tree filter 1.txt' \
87 'git-ls-tree $tree 1.txt >current &&
88 cat >expected <<\EOF &&
89 100644 blob X 1.txt
90 EOF
91 test_output'
93 test_expect_success \
94 'ls-tree filter path1/b/c/1.txt' \
95 'git-ls-tree $tree path1/b/c/1.txt >current &&
96 cat >expected <<\EOF &&
97 100644 blob X path1/b/c/1.txt
98 EOF
99 test_output'
101 test_expect_success \
102 'ls-tree filter all 1.txt files' \
103 'git-ls-tree $tree 1.txt path0/a/b/c/1.txt path1/b/c/1.txt path2/1.txt path3/1.txt >current &&
104 cat >expected <<\EOF &&
105 100644 blob X 1.txt
106 100644 blob X path0/a/b/c/1.txt
107 100644 blob X path1/b/c/1.txt
108 100644 blob X path2/1.txt
109 100644 blob X path3/1.txt
111 test_output'
113 test_expect_success \
114 'ls-tree filter directories' \
115 'git-ls-tree $tree path3 path2 path0/a/b/c path1/b/c path0/a >current &&
116 cat >expected <<\EOF &&
117 040000 tree X path3
118 100644 blob X path3/1.txt
119 100644 blob X path3/2.txt
120 040000 tree X path2
121 100644 blob X path2/1.txt
122 040000 tree X path0/a/b/c
123 100644 blob X path0/a/b/c/1.txt
124 040000 tree X path1/b/c
125 100644 blob X path1/b/c/1.txt
126 040000 tree X path0/a
127 040000 tree X path0/a/b
129 test_output'
131 test_expect_success \
132 'ls-tree filter odd names' \
133 'git-ls-tree $tree 1.txt /1.txt //1.txt path3/1.txt /path3/1.txt //path3//1.txt path3 /path3/ path3// >current &&
134 cat >expected <<\EOF &&
135 100644 blob X 1.txt
136 100644 blob X 1.txt
137 100644 blob X 1.txt
138 100644 blob X path3/1.txt
139 100644 blob X path3/1.txt
140 100644 blob X path3/1.txt
141 040000 tree X path3
142 100644 blob X path3/1.txt
143 100644 blob X path3/2.txt
144 040000 tree X path3
145 100644 blob X path3/1.txt
146 100644 blob X path3/2.txt
147 040000 tree X path3
148 100644 blob X path3/1.txt
149 100644 blob X path3/2.txt
151 test_output'
153 test_expect_success \
154 'ls-tree filter missing files and extra slashes' \
155 'git-ls-tree $tree 1.txt/ abc.txt path3//23.txt path3/2.txt/// >current &&
156 cat >expected <<\EOF &&
158 test_output'
160 test_done