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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
May 12, 2021 at 17:28 UTC
a97c7a8bc4f2068b2e8c23ce8d17f7db8333ded0
2 files changed
+24
t/t3001-ls-files-others-exclude.sh
+5
@@ -292,6 +292,11 @@ EOF
292
test_cmp expect actual
293
'
294
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
+'
300
301
test_expect_success 'ls-files with "**" patterns and no slashes' '
302
git ls-files -o -i --exclude "one**a.1" >actual &&
t/t7300-clean.sh
+19
@@ -769,4 +769,23 @@ test_expect_failure 'avoid traversing into ignored directories' '
769
test_cmp trace.expect trace.relevant
770
'
771
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
+
791
test_done