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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed May 12, 2021 at 17:28 UTC 2e4e43a6910393d681d095f515d41232c2372966
1 file changed +23
t/t7300-clean.sh
+23
@@ -746,4 +746,27 @@ test_expect_success 'clean untracked paths by pathspec' '
746 test_must_be_empty actual
747 '
748
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 +
772 test_done