Skip to content

fix: handle ./foo/bar glob pattern the same as foo/bar#10313

Merged
graphite-app[bot] merged 1 commit into
mainfrom
07-16-fix_handle_._foo_bar_glob_pattern_the_same_as_foo_bar_
Jul 16, 2026
Merged

fix: handle ./foo/bar glob pattern the same as foo/bar#10313
graphite-app[bot] merged 1 commit into
mainfrom
07-16-fix_handle_._foo_bar_glob_pattern_the_same_as_foo_bar_

Conversation

@sapphi-red

@sapphi-red sapphi-red commented Jul 16, 2026

Copy link
Copy Markdown
Member

./foo/bar was treated differently from foo/bar for globs. This PR fixes that inconsistency.

This fixes ,vitejs/vite#22943. The e2e test case is added in vitejs/vite#22955.

@netlify

netlify Bot commented Jul 16, 2026

Copy link
Copy Markdown

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 2fd5c5c
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a58c5e12913e5000844fb73

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

sapphi-red commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

Merge activity

  • Jul 16, 9:31 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 16, 11:51 AM UTC: sapphi-red added this pull request to the Graphite merge queue.
  • Jul 16, 11:56 AM UTC: Merged by the Graphite merge queue.

@codspeed-hq

codspeed-hq Bot commented Jul 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing 07-16-fix_handle_.foo_bar_glob_pattern_the_same_as_foo_bar (3eb1408) with main (a0b18cf)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

`./foo/bar` was treated differently from `foo/bar` for globs. This PR fixes that inconsistency.

This fixes ,vitejs/vite#22943. The e2e test case is added in vitejs/vite#22955.
@graphite-app
graphite-app Bot force-pushed the 07-16-fix_handle_._foo_bar_glob_pattern_the_same_as_foo_bar_ branch from 3eb1408 to 2fd5c5c Compare July 16, 2026 11:51
@graphite-app
graphite-app Bot merged commit 2fd5c5c into main Jul 16, 2026
33 of 34 checks passed
@graphite-app
graphite-app Bot deleted the 07-16-fix_handle_._foo_bar_glob_pattern_the_same_as_foo_bar_ branch July 16, 2026 11:56
graphite-app Bot pushed a commit that referenced this pull request Jul 17, 2026
## Summary

- consume joined `PathBuf` values through a shared `normalize_path_buf_to_slash` helper
- avoid copying the normalized glob path into a second allocation before matching
- strengthen the `./foo` versus `foo` regression test through the public filter path, including a Windows drive cwd
- document the owned-path rule in the path manipulation guide and link it from `AGENTS.md`

## Why

#10313 correctly inserted lexical normalization into the existing `join -> to_string_lossy -> slash` chain. However, `join` had already produced an owned `PathBuf`; calling the non-consuming `normalize()` API converted it to `Cow<Path>`, and the following string conversion copied the normalized buffer.

The same ownership issue was caught during #10230's review in `file_emitter.rs`, but the general rule never made it into the final style guide. The guide covered consuming relative/slash conversion and exposed `path_buf_to_slash`, but it did not provide a named normalize-plus-slash helper or list the non-consuming owned-path chain as an anti-pattern.

This PR records that missing rule and centralizes the composition so future call sites do not need to reconstruct it.

## Performance

A release-mode `GlobalAlloc` counter around matcher construction reported one fewer allocation/reallocation for each non-bypass relative glob:

| Pattern | Current | This PR |
| --- | ---: | ---: |
| `foo/*.txt` | 3 | 2 |
| `./foo/*.txt` | 4 | 3 |

The probe compared exact outputs across clean, dirty, parent, trailing-separator, absolute, and `**` cases. No benchmark case is added here; if this path is added to continuous performance coverage, the benchmark should land first in a baseline-only PR and the implementation comparison should follow from that baseline.

## Validation

- `just lint-rust`
- `just lint-repo`
- `cargo test -p rolldown_std_utils -p rolldown_utils -p rolldown_common`
- `cargo check -p rolldown_std_utils -p rolldown_utils --tests --target x86_64-pc-windows-msvc --locked`
- `cargo check -p rolldown_std_utils --tests --target wasm32-wasip1 --locked`
- `RUSTDOCFLAGS='-D warnings' cargo doc -p rolldown_std_utils --no-deps --locked`
- `just test-rust` executed the workspace suite successfully until the single `test262_module_code` test stopped on the intentionally uninitialized `test262` submodule; 1,873 integration tests had passed, with no code failure
- adversarial review passed after documenting the strict UTF-8 panic contract
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.

2 participants