Skip to content

Commit 7260c7b

Browse files
newrengitster
authored andcommitted
t3000: add more testcases testing a variety of ls-files issues
This adds seven new ls-files tests. While currently all seven test pass, my earlier rounds of restructuring dir.c to replace an exponential algorithm with a linear one passed all the tests in the testsuite but failed six of these seven new tests. Add these tests to increase our case coverage. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ce5c61a commit 7260c7b

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

t/t3000-ls-files-others.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,125 @@ test_expect_success SYMLINKS 'ls-files --others with symlinked submodule' '
9191
test_cmp expect actual
9292
'
9393

94+
test_expect_success 'setup nested pathspec search' '
95+
test_create_repo nested &&
96+
(
97+
cd nested &&
98+
99+
mkdir -p partially_tracked/untracked_dir &&
100+
> partially_tracked/content &&
101+
> partially_tracked/untracked_dir/file &&
102+
103+
mkdir -p untracked/deep &&
104+
> untracked/deep/path &&
105+
> untracked/deep/foo.c &&
106+
107+
git add partially_tracked/content
108+
)
109+
'
110+
111+
test_expect_success 'ls-files -o --directory with single deep dir pathspec' '
112+
(
113+
cd nested &&
114+
115+
git ls-files -o --directory untracked/deep/ >actual &&
116+
117+
cat <<-EOF >expect &&
118+
untracked/deep/
119+
EOF
120+
121+
test_cmp expect actual
122+
)
123+
'
124+
125+
test_expect_success 'ls-files -o --directory with multiple dir pathspecs' '
126+
(
127+
cd nested &&
128+
129+
git ls-files -o --directory partially_tracked/ untracked/ >actual &&
130+
131+
cat <<-EOF >expect &&
132+
partially_tracked/untracked_dir/
133+
untracked/
134+
EOF
135+
136+
test_cmp expect actual
137+
)
138+
'
139+
140+
test_expect_success 'ls-files -o --directory with mix dir/file pathspecs' '
141+
(
142+
cd nested &&
143+
144+
git ls-files -o --directory partially_tracked/ untracked/deep/path >actual &&
145+
146+
cat <<-EOF >expect &&
147+
partially_tracked/untracked_dir/
148+
untracked/deep/path
149+
EOF
150+
151+
test_cmp expect actual
152+
)
153+
'
154+
155+
test_expect_success 'ls-files --o --directory with glob filetype match' '
156+
(
157+
cd nested &&
158+
159+
# globs kinda defeat --directory, but only for that pathspec
160+
git ls-files --others --directory partially_tracked "untracked/*.c" >actual &&
161+
162+
cat <<-EOF >expect &&
163+
partially_tracked/untracked_dir/
164+
untracked/deep/foo.c
165+
EOF
166+
167+
test_cmp expect actual
168+
)
169+
'
170+
171+
test_expect_success 'ls-files --o --directory with mix of tracked states' '
172+
(
173+
cd nested &&
174+
175+
# globs kinda defeat --directory, but only for that pathspec
176+
git ls-files --others --directory partially_tracked/ "untracked/?*" >actual &&
177+
178+
cat <<-EOF >expect &&
179+
partially_tracked/untracked_dir/
180+
untracked/deep/
181+
EOF
182+
183+
test_cmp expect actual
184+
)
185+
'
186+
187+
test_expect_success 'ls-files --o --directory with glob filetype match only' '
188+
(
189+
cd nested &&
190+
191+
git ls-files --others --directory "untracked/*.c" >actual &&
192+
193+
cat <<-EOF >expect &&
194+
untracked/deep/foo.c
195+
EOF
196+
197+
test_cmp expect actual
198+
)
199+
'
200+
201+
test_expect_success 'ls-files --o --directory to get immediate paths under one dir only' '
202+
(
203+
cd nested &&
204+
205+
git ls-files --others --directory "untracked/?*" >actual &&
206+
207+
cat <<-EOF >expect &&
208+
untracked/deep/
209+
EOF
210+
211+
test_cmp expect actual
212+
)
213+
'
214+
94215
test_done

0 commit comments

Comments
 (0)