@matheusbsbs / matheus-bagliano / commits / 3ea6025e17
Fork 0

t3101: test more ls-tree options

Add tests for --full-name, --full-tree, --abbrev, and --name-only. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Boyd committed Nov 13, 2009 at 20:34 UTC 3ea6025e172273e1bf237dff366c0cc19cdacbf1
1 file changed +87 -2
t/t3101-ls-tree-dirname.sh
+87 -2
@@ -39,8 +39,8 @@ test_expect_success \
39 tree=`git write-tree` &&
40 echo $tree'
41
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"
42 +_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
43 +_x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
44 test_output () {
45 sed -e "s/ $_x40 / X /" <current >check
46 test_cmp expected check
@@ -141,4 +141,89 @@ test_expect_success 'ls-tree filter is leading path match' '
141 test_output
142 '
143
144 +test_expect_success 'ls-tree --full-name' '
145 + (
146 + cd path0 &&
147 + git ls-tree --full-name $tree a
148 + ) >current &&
149 + cat >expected <<\EOF &&
150 +040000 tree X path0/a
151 +EOF
152 + test_output
153 +'
154 +
155 +test_expect_success 'ls-tree --full-tree' '
156 + (
157 + cd path1/b/c &&
158 + git ls-tree --full-tree $tree
159 + ) >current &&
160 + cat >expected <<\EOF &&
161 +100644 blob X 1.txt
162 +100644 blob X 2.txt
163 +040000 tree X path0
164 +040000 tree X path1
165 +040000 tree X path2
166 +040000 tree X path3
167 +EOF
168 + test_output
169 +'
170 +
171 +test_expect_success 'ls-tree --full-tree -r' '
172 + (
173 + cd path3/ &&
174 + git ls-tree --full-tree -r $tree
175 + ) >current &&
176 + cat >expected <<\EOF &&
177 +100644 blob X 1.txt
178 +100644 blob X 2.txt
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
184 +EOF
185 + test_output
186 +'
187 +
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 &&
192 +100644 blob X 1.txt
193 +100644 blob X 2.txt
194 +040000 tree X path0
195 +040000 tree X path1
196 +040000 tree X path2
197 +040000 tree X path3
198 +EOF
199 + test_cmp expected check
200 +'
201 +
202 +test_expect_success 'ls-tree --name-only' '
203 + git ls-tree --name-only $tree >current
204 + cat >expected <<\EOF &&
205 +1.txt
206 +2.txt
207 +path0
208 +path1
209 +path2
210 +path3
211 +EOF
212 + test_output
213 +'
214 +
215 +test_expect_success 'ls-tree --name-only -r' '
216 + git ls-tree --name-only -r $tree >current
217 + cat >expected <<\EOF &&
218 +1.txt
219 +2.txt
220 +path0/a/b/c/1.txt
221 +path1/b/c/1.txt
222 +path2/1.txt
223 +path3/1.txt
224 +path3/2.txt
225 +EOF
226 + test_output
227 +'
228 +
229 test_done