Skip to content

Commit a97c7a8

Browse files
newrengitster
authored andcommitted
t3001, t7300: add testcase showcasing missed directory traversal
In the last commit, we added a testcase showing that the directory traversal machinery sometimes traverses into directories unnecessarily. Here we show that there are cases where it does the opposite: it does not traverse into directories, despite those directories having important files that need to be flagged. Add a testcase showing that `git ls-files -o -i --directory` can omit some of the files it should be listing, and another showing that `git clean -fX` can fail to clean out some of the expected files. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e4e43a commit a97c7a8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

t/t3001-ls-files-others-exclude.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ EOF
292292
test_cmp expect actual
293293
'
294294

295+
test_expect_failure 'ls-files with "**" patterns and --directory' '
296+
# Expectation same as previous test
297+
git ls-files --directory -o -i --exclude "**/a.1" >actual &&
298+
test_cmp expect actual
299+
'
295300

296301
test_expect_success 'ls-files with "**" patterns and no slashes' '
297302
git ls-files -o -i --exclude "one**a.1" >actual &&

t/t7300-clean.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,4 +769,23 @@ test_expect_failure 'avoid traversing into ignored directories' '
769769
test_cmp trace.expect trace.relevant
770770
'
771771

772+
test_expect_failure 'traverse into directories that may have ignored entries' '
773+
test_when_finished rm -f output &&
774+
test_create_repo need-to-traverse-into-hierarchy &&
775+
(
776+
cd need-to-traverse-into-hierarchy &&
777+
mkdir -p modules/foobar/src/generated &&
778+
> modules/foobar/src/generated/code.c &&
779+
> modules/foobar/Makefile &&
780+
echo "/modules/**/src/generated/" >.gitignore &&
781+
782+
git clean -fX modules/foobar >../output &&
783+
784+
grep Removing ../output &&
785+
786+
test_path_is_missing modules/foobar/src/generated/code.c &&
787+
test_path_is_file modules/foobar/Makefile
788+
)
789+
'
790+
772791
test_done

0 commit comments

Comments
 (0)