fix: normalize full-path matches for parent search paths#1969
Closed
lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
Closed
fix: normalize full-path matches for parent search paths#1969lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in fd’s --full-path matching where relative search paths containing ./.. could produce non-normalized absolute paths (e.g., <cwd>/../…) and therefore fail to match patterns unless --absolute-path was also used.
Changes:
- Normalize constructed match paths for
--full-pathwhen the traversed entry path contains.or..components (fallback to prior behavior if normalization fails). - Add a regression test covering
--full-pathmatching when searching from a nested directory with..as the search path. - Document the bugfix in the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/walk.rs |
Normalizes the absolute match path for --full-path when dot-components are present, fixing mismatches from parent-relative search roots. |
tests/tests.rs |
Adds an integration regression test reproducing the reported --full-path + .. mismatch and validating the corrected behavior. |
CHANGELOG.md |
Records the bugfix under Unreleased bugfixes and links to the reported issue. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Normalize
--full-pathmatching for relative search paths containing.or...Fixes #1513.
Before
From a nested directory, a full-path match against a parent search path could fail unless
--absolute-pathwas also set. For example, fromone/two:fd --full-path -t f '<abs>/one/b.foo' ..returned no results, while the same logical query started matching when
--absolute-pathwas added.After
--full-pathmatching normalizes relative search paths with.or..before matching, so the result set no longer depends on--absolute-path.Why this is correct
The matching path was being built as
<cwd>/../...and compared without normalization. This change only normalizes paths for matching when the relative entry path actually contains.or.., and falls back to the existing behavior if normalization fails.Testing
cargo test test_full_path_normalizes_relative_search_path -- --nocapturecargo test test_normalized_absolute_path -- --nocapturecargo test test_full_path -- --nocapturecargo test test_symlink_and_full_path -- --nocapturecargo test search_str_for_entry_with_relative_path -- --nocapture