Skip to content

fix: normalize full-path matches for parent search paths#1969

Closed
lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
lawrence3699:fix/full-path-parent-normalization
Closed

fix: normalize full-path matches for parent search paths#1969
lawrence3699 wants to merge 1 commit intosharkdp:masterfrom
lawrence3699:fix/full-path-parent-normalization

Conversation

@lawrence3699
Copy link
Copy Markdown

Summary

Normalize --full-path matching 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-path was also set. For example, from one/two:

fd --full-path -t f '<abs>/one/b.foo' ..

returned no results, while the same logical query started matching when --absolute-path was added.

After

--full-path matching 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 -- --nocapture
  • cargo test test_normalized_absolute_path -- --nocapture
  • cargo test test_full_path -- --nocapture
  • cargo test test_symlink_and_full_path -- --nocapture
  • cargo test search_str_for_entry_with_relative_path -- --nocapture

Copilot AI review requested due to automatic review settings April 17, 2026 00:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-path when the traversed entry path contains . or .. components (fallback to prior behavior if normalization fails).
  • Add a regression test covering --full-path matching 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Wrong result when --full-path and ..

2 participants