@matheusbsbs / matheus-bagliano / commits / 246cc52f38
Fork 0

ls-tree: match the test to the new semantics.

The diff for this commit is a good illustration of what changed in ls-tree behaviour. - With -r, tree nodes themselves are not shown anymore, but blobs in subtrees are shown. - The order of paths parameters do not matter, since they are not like arguments to /bin/ls, but are filter patterns. - When filter patterns overlap, unintuitive things happen. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 28, 2005 at 02:32 UTC 246cc52f388cae8ca99e5a12b8458c9bfa467765
3 files changed +22 -56
t/t0000-basic.sh
+2 -3
@@ -126,19 +126,18 @@ test_expect_success \
126 'git-ls-tree output for a known tree.' \
127 'diff current expected'
128
129 +# This changed in ls-tree pathspec change -- recursive does
130 +# not show tree nodes anymore.
131 test_expect_success \
132 'showing tree with git-ls-tree -r' \
133 'git-ls-tree -r $tree >current'
134 cat >expected <<\EOF
135 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
136 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
135 -040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe path2
137 100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2
138 120000 blob d8ce161addc5173867a3c3c730924388daedbc38 path2/file2sym
138 -040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3
139 100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376 path3/file3
140 120000 blob 8599103969b43aff7e430efea79ca4636466794f path3/file3sym
141 -040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2 path3/subp3
141 100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f path3/subp3/file3
142 120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
143 EOF
t/t3100-ls-tree-restrict.sh
+12 -23
@@ -54,8 +54,6 @@ test_expect_success \
54 cat >expected <<\EOF &&
55 100644 blob X path0
56 120000 blob X path1
57 -040000 tree X path2
58 -040000 tree X path2/baz
57 100644 blob X path2/baz/b
58 120000 blob X path2/bazbo
59 100644 blob X path2/foo
@@ -70,12 +68,14 @@ EOF
68 test_output'
69
70
71 +# it used to be path1 and then path0, but with pathspec semantics
72 +# they are shown in canonical order.
73 test_expect_success \
74 'ls-tree filtered with path1 path0' \
75 'git-ls-tree $tree path1 path0 >current &&
76 cat >expected <<\EOF &&
77 -120000 blob X path1
77 100644 blob X path0
78 +120000 blob X path1
79 EOF
80 test_output'
81
@@ -86,45 +86,34 @@ test_expect_success \
86 EOF
87 test_output'
88
89 +# It used to show path2 and its immediate children but
90 +# with pathspec semantics it shows only path2
91 test_expect_success \
92 'ls-tree filtered with path2' \
93 'git-ls-tree $tree path2 >current &&
94 cat >expected <<\EOF &&
95 040000 tree X path2
94 -040000 tree X path2/baz
95 -120000 blob X path2/bazbo
96 -100644 blob X path2/foo
97 -EOF
98 - test_output'
99 -
100 -test_expect_success \
101 - 'ls-tree filtered with path2/baz' \
102 - 'git-ls-tree $tree path2/baz >current &&
103 - cat >expected <<\EOF &&
104 -040000 tree X path2/baz
105 -100644 blob X path2/baz/b
96 EOF
97 test_output'
98
99 +# ... and path2/ shows the children.
100 test_expect_success \
110 - 'ls-tree filtered with path2' \
111 - 'git-ls-tree $tree path2 >current &&
101 + 'ls-tree filtered with path2/' \
102 + 'git-ls-tree $tree path2/ >current &&
103 cat >expected <<\EOF &&
113 -040000 tree X path2
104 040000 tree X path2/baz
105 120000 blob X path2/bazbo
106 100644 blob X path2/foo
107 EOF
108 test_output'
109
110 +# The same change -- exact match does not show children of
111 +# path2/baz
112 test_expect_success \
121 - 'ls-tree filtered with path2/' \
122 - 'git-ls-tree $tree path2/ >current &&
113 + 'ls-tree filtered with path2/baz' \
114 + 'git-ls-tree $tree path2/baz >current &&
115 cat >expected <<\EOF &&
124 -040000 tree X path2
116 040000 tree X path2/baz
126 -120000 blob X path2/bazbo
127 -100644 blob X path2/foo
117 EOF
118 test_output'
119
t/t3101-ls-tree-dirname.sh
+8 -30
@@ -59,24 +59,16 @@ test_expect_success \
59 EOF
60 test_output'
61
62 +# Recursive does not show tree nodes anymore...
63 test_expect_success \
64 'ls-tree recursive' \
65 'git-ls-tree -r $tree >current &&
66 cat >expected <<\EOF &&
67 100644 blob X 1.txt
68 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
69 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
70 100644 blob X path1/b/c/1.txt
77 -040000 tree X path2
71 100644 blob X path2/1.txt
79 -040000 tree X path3
72 100644 blob X path3/1.txt
73 100644 blob X path3/2.txt
74 EOF
@@ -110,41 +102,27 @@ test_expect_success \
102 EOF
103 test_output'
104
105 +# I am not so sure about this one after ls-tree doing pathspec match.
106 +# Having both path0/a and path0/a/b/c makes path0/a redundant, and
107 +# it behaves as if path0/a/b/c, path1/b/c, path2 and path3 are specified.
108 test_expect_success \
109 'ls-tree filter directories' \
110 'git-ls-tree $tree path3 path2 path0/a/b/c path1/b/c path0/a >current &&
111 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
112 040000 tree X path0/a/b/c
123 -100644 blob X path0/a/b/c/1.txt
113 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
114 +040000 tree X path2
115 +040000 tree X path3
116 EOF
117 test_output'
118
119 +# Again, duplicates are filtered away so this is equivalent to
120 +# having 1.txt and path3
121 test_expect_success \
122 'ls-tree filter odd names' \
123 'git-ls-tree $tree 1.txt /1.txt //1.txt path3/1.txt /path3/1.txt //path3//1.txt path3 /path3/ path3// >current &&
124 cat >expected <<\EOF &&
125 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
126 100644 blob X path3/1.txt
127 100644 blob X path3/2.txt
128 EOF