Remove erroneous optimization which was skipping the path normalization. - #12617
Remove erroneous optimization which was skipping the path normalization.#12617desruisseaux wants to merge 1 commit into
Conversation
That optimization can produce false positive if the pattern appears in the base directory. For example if the base directory is "something/target/test-classes" and if an include or exclude pattern is "**/test-classes" where "test-classes" is another directory as a child of the base directory, the optimization would always consider that there is a match.
gnodet
left a comment
There was a problem hiding this comment.
The fix correctly removes a flawed optimization that skipped path relativization when all patterns started with **, which could cause false-positive matches when the base directory path itself contained segments matching the pattern. The code change is sound.
One suggestion: no regression test is added for the specific false-positive scenario described in the PR body. A test constructing that exact scenario (e.g., base directory = something/target/test-classes with pattern **/test-classes matching a child directory) would prevent reintroduction of the removed optimization and document the edge case for future maintainers.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
…zation The optimization skipped path relativization when all include/exclude patterns started with "**". This produced false positives when the base directory path itself contained a segment matching the pattern (e.g., base = "something/target/test-classes" with pattern "**/test-classes/**" would match every file under the base directory). Added a regression test for the exact false-positive scenario. PR: #12621 Original fix by: Martin Desruisseaux (@desruisseaux) Supersedes: #12617 Closes #12621
That optimization can produce false positive if the pattern appears in the base directory. For example if the base directory is
something/target/test-classesand if an include or exclude pattern is**/test-classeswheretest-classesis another directory as a child of the base directory, the optimization would always consider that there is a match.