Skip to content

fix(rg): preserve default binary-match reporting for explicit inputs#1756

Merged
chaliy merged 1 commit into
mainfrom
2026-05-25-fix-rg-skipping-explicit-binary-inputs
May 25, 2026
Merged

fix(rg): preserve default binary-match reporting for explicit inputs#1756
chaliy merged 1 commit into
mainfrom
2026-05-25-fix-rg-skipping-explicit-binary-inputs

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 25, 2026

Motivation

  • A NUL-byte check introduced a blanket skip for binary inputs because stdin, explicit paths, and recursively discovered files were collapsed into (filename, content) tuples, losing provenance and causing false negatives for explicit files and stdin.
  • Goal: match ripgrep semantics where default binary skipping applies to recursively discovered files but explicit file arguments and stdin should report binary file matches ... by default.

Description

  • Introduce RgSearchInput with fields filename, content, and skip_binary_by_default and replace Vec<(String,String)> with Vec<RgSearchInput> for RgCollectedInputs to preserve input provenance (crates/bashkit/src/builtins/rg/mod.rs).
  • Mark stdin and explicit path reads with RgSearchInput::explicit(...) (no default skip) and mark recursively discovered/indexed files with RgSearchInput::recursive(...) (default-skip enabled).
  • Change the main search loop to consult input.skip_binary_by_default when deciding whether a NUL-containing input should be silently skipped, so explicit inputs and stdin produce ripgrep-style binary summaries by default.
  • Add regression assertions to test_rg_binary_text_modes to cover explicit binary file argument and binary stdin behavior under default mode.

Testing

  • Ran cargo test -p bashkit test_rg_binary_text_modes, which passed (1 passed; 0 failed).
  • The modified test_rg_binary_text_modes now includes assertions for explicit binary path and binary stdin and these assertions succeeded.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 25, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit a210074 Commit Preview URL May 25 2026, 04:34 PM

Verify default-mode 'binary file matches ...' reporting:
- explicit binary file argument
- binary stdin

Main already implements input.explicit handling differently than the
original PR proposed (using a bool field rather than skip_binary_by_default);
the meaningful contribution is the regression coverage.

Rebased on current main; original PR #1756 by chaliy (refactor portion
superseded by #1737).
@chaliy chaliy force-pushed the 2026-05-25-fix-rg-skipping-explicit-binary-inputs branch from 3016384 to a210074 Compare May 25, 2026 15:18
@chaliy chaliy merged commit 4ede96f into main May 25, 2026
33 checks passed
@chaliy chaliy deleted the 2026-05-25-fix-rg-skipping-explicit-binary-inputs branch May 25, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant