Skip to content

Commit 2e4e43a

Browse files
newrengitster
authored andcommitted
t7300: add testcase showing unnecessary traversal into ignored directory
The PNPM package manager is apparently creating deeply nested (but ignored) directory structures; traversing them is costly performance-wise, unnecessary, and in some cases is even throwing warnings/errors because the paths are too long to handle on various platforms. Add a testcase that checks for such unnecessary directory traversal. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b338e9f commit 2e4e43a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

t/t7300-clean.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,4 +746,27 @@ test_expect_success 'clean untracked paths by pathspec' '
746746
test_must_be_empty actual
747747
'
748748

749+
test_expect_failure 'avoid traversing into ignored directories' '
750+
test_when_finished rm -f output error trace.* &&
751+
test_create_repo avoid-traversing-deep-hierarchy &&
752+
(
753+
cd avoid-traversing-deep-hierarchy &&
754+
755+
mkdir -p untracked/subdir/with/a &&
756+
>untracked/subdir/with/a/random-file.txt &&
757+
758+
GIT_TRACE2_PERF="$TRASH_DIRECTORY/trace.output" \
759+
git clean -ffdxn -e untracked
760+
) &&
761+
762+
# Make sure we only visited into the top-level directory, and did
763+
# not traverse into the "untracked" subdirectory since it was excluded
764+
grep data.*read_directo.*directories-visited trace.output |
765+
cut -d "|" -f 9 >trace.relevant &&
766+
cat >trace.expect <<-EOF &&
767+
..directories-visited:1
768+
EOF
769+
test_cmp trace.expect trace.relevant
770+
'
771+
749772
test_done

0 commit comments

Comments
 (0)