Repository navigation
Fix passthru output when no lines match - #128
Conversation
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
New issues introduced by this change (3)
| Severity | Finding |
|---|---|
tgrep-cli/tests/ripgrep_compat.rs — This test does not exercise the indexed path: naming a file makes run set bypass_index and call… |
|
tgrep-cli/tests/ripgrep_compat.rs — Passing this explicit file also triggers bypass_index before server discovery… |
|
tgrep-cli/src/serve.rs — MatchAll applies to the server's entire index, because the request does not carry the CLI's… |
What changed in this PR
Fixes --passthru so eligible text files are emitted even without matches while preserving exit status and binary behavior.
Changes:
- Uses full indexed-file enumeration for passthru.
- Emits no-hit files through context output.
- Adds local, indexed, binary, and server-oriented tests.
| File | Description |
|---|---|
tgrep-cli/src/search.rs |
Handles no-hit passthru output and exit status. |
tgrep-cli/src/serve.rs |
Adds server-side full-file passthru handling. |
tgrep-cli/tests/ripgrep_compat.rs |
Adds passthru regression coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
Review tier: Balanced
Findings: 1
Pre-existing issues (3)
| Severity | Finding |
|---|---|
tgrep-cli/src/serve.rs — MatchAll applies to the server's entire index, because the request does not carry the CLI's… View comment |
|
tgrep-cli/tests/ripgrep_compat.rs — Passing this explicit file also triggers bypass_index before server discovery… View comment |
|
tgrep-cli/tests/ripgrep_compat.rs — This test does not exercise the indexed path: naming a file makes run set bypass_index and call… View comment |
Suppressed comments (4)
tgrep-cli/tests/ripgrep_compat.rs:2730
- A file target bypasses server delegation entirely (
search.rs:492-528), so the running daemon is never queried and the “Server unreachable” assertion passes vacuously. Target the one-file root directory instead so this exercises the new server context-row response and client exit-status calculation.
path.to_str().unwrap(),
tgrep-cli/tests/ripgrep_compat.rs:2743
- Because
pathresolves to a file, the indexed and server iterations both bypass their advertised paths and run brute-force search (search.rs:492-528). Point the shared target atrootso the test actually validates-m 0through local-index and server request handling.
let path = root.join("hello.rs");
let path = path.to_str().unwrap();
tgrep-cli/tests/ripgrep_compat.rs:2596
- This target is a single file, so
search::runsetsbypass_indexand executes the brute-force path (search.rs:492-528). As a result, this test does not cover the changed local-index candidate selection or the no-matchFileOutcomehandling it is named for. Use a directory target and assert that all eligible files are emitted while the process still exits 1.
path.to_str().unwrap(),
tgrep-cli/src/serve.rs:1294
- Making passthru a
MatchAllserver query causes the daemon to search its entire index even for a subtree request, materialize every file line into nested vectors, serialize one large JSON response, and only then let the client discard out-of-scope rows (serve.rs:1514-1554,search.rs:692-734). For large repositories this makes memory and network usage scale with the full repository and can exhaust the daemon/client. Bypass server delegation for effective passthru, or add server-side scope plus streaming/bounded responses.
let plan = if passthru || invert_match || encoding.may_differ_from_index() {
query::QueryPlan::MatchAll
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]> Copilot-Session: c4fb5038-6356-4740-aab0-2216d80e27bd
82673a2 to
9956009
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Server bypass can omit live additions and emit tombstoned or newly ignored files from a stale on-disk index.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
tgrep-cli/src/search.rs — Bypassing the daemon here makes --passthru discover candidates only from the on-disk… |
Issues resolved since last review (3)
| Severity | Finding |
|---|---|
tgrep-cli/src/serve.rs — MatchAll applies to the server's entire index, because the request does not carry the CLI's… View resolved comment |
|
tgrep-cli/tests/ripgrep_compat.rs — Passing this explicit file also triggers bypass_index before server discovery… View resolved comment |
|
tgrep-cli/tests/ripgrep_compat.rs — This test does not exercise the indexed path: naming a file makes run set bypass_index and call… View resolved comment |
| // never reports. | ||
| if !opts.no_index | ||
| && !bypass_index | ||
| && !opts.effective_passthru() |


Summary
--passthrusearches through every eligible indexed fileTesting
cargo test --test ripgrep_compat passthru -- --nocapturecargo test --test ripgrep_compat new_flags_agree_across_search_paths -- --nocapturecargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspaceCloses #126