Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 50 additions & 6 deletions crates/bashkit/src/builtins/rg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4463,6 +4463,7 @@ fn rg_quiet_result(
opts: &RgOptions,
match_count: usize,
any_match: &mut bool,
stderr: &str,
) -> Option<ExecResult> {
let selected = if opts.files_without_matches {
match_count == 0
Expand All @@ -4472,7 +4473,12 @@ fn rg_quiet_result(
if selected {
*any_match = true;
if !opts.stats {
return Some(ExecResult::ok(String::new()));
return Some(ExecResult {
stdout: String::new(),
stderr: stderr.to_string(),
exit_code: 0,
..Default::default()
});
}
}
None
Expand Down Expand Up @@ -4743,7 +4749,9 @@ impl Builtin for Rg {
let matched = if opts.invert_match { !matched } else { matched };
if !matched {
if opts.quiet {
if let Some(result) = rg_quiet_result(&opts, 0, &mut any_match) {
if let Some(result) =
rg_quiet_result(&opts, 0, &mut any_match, &collected_inputs.stderr)
{
return Ok(result);
}
continue;
Expand Down Expand Up @@ -4775,7 +4783,9 @@ impl Builtin for Rg {
stats.matched_lines += 1;
stats.files_with_matches += 1;
if opts.quiet {
if let Some(result) = rg_quiet_result(&opts, 1, &mut any_match) {
if let Some(result) =
rg_quiet_result(&opts, 1, &mut any_match, &collected_inputs.stderr)
{
return Ok(result);
}
continue;
Expand Down Expand Up @@ -4952,7 +4962,12 @@ impl Builtin for Rg {
}

if opts.quiet {
if let Some(result) = rg_quiet_result(&opts, match_count, &mut any_match) {
if let Some(result) = rg_quiet_result(
&opts,
match_count,
&mut any_match,
&collected_inputs.stderr,
) {
return Ok(result);
}
continue;
Expand Down Expand Up @@ -5113,7 +5128,12 @@ impl Builtin for Rg {
}

if opts.quiet {
if let Some(result) = rg_quiet_result(&opts, match_count, &mut any_match) {
if let Some(result) = rg_quiet_result(
&opts,
match_count,
&mut any_match,
&collected_inputs.stderr,
) {
return Ok(result);
}
continue;
Expand Down Expand Up @@ -5543,7 +5563,9 @@ impl Builtin for Rg {
}

if opts.quiet {
if let Some(result) = rg_quiet_result(&opts, match_count, &mut any_match) {
if let Some(result) =
rg_quiet_result(&opts, match_count, &mut any_match, &collected_inputs.stderr)
{
return Ok(result);
}
continue;
Expand Down Expand Up @@ -6778,6 +6800,28 @@ mod tests {
cwd: "/proj",
output: RgDiffOutput::UnorderedLines,
},
RgDiffCase {
name: "quiet keeps missing file diagnostics when match found",
args: &["-q", "needle", "proj/missing.txt", "proj/a.txt"],
stdin: None,
files: DIFF_BASIC_FILES,
cwd: "/",
output: RgDiffOutput::Exact,
},
RgDiffCase {
name: "quiet no messages suppresses missing file diagnostics",
args: &[
"--no-messages",
"-q",
"needle",
"proj/missing.txt",
"proj/a.txt",
],
stdin: None,
files: DIFF_BASIC_FILES,
cwd: "/",
output: RgDiffOutput::Exact,
},
RgDiffCase {
name: "relative recursive display",
args: &["needle", "proj"],
Expand Down
Loading