Skip to content

Commit

Permalink
cli: complete: fix stderr during autocomplete of revsets
Browse files Browse the repository at this point in the history
When running `cmd.spawn()` rust will by default inherit
the stderr of the parent, so `jj log test<TAB>`, would
print `There is no jj repo in "."` into the prompt.
  • Loading branch information
jakobhellermann committed Jan 11, 2025
1 parent 9872427 commit f1e91cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/src/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ fn all_files_from_rev(rev: String, current: &std::ffi::OsStr) -> Vec<CompletionC
.arg("--config=ui.allow-filesets=true")
.arg(current_prefix_to_fileset(current))
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::null())
.spawn()
.map_err(user_error)?;
let stdout = child.stdout.take().unwrap();
Expand Down
4 changes: 4 additions & 0 deletions cli/tests/test_completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,4 +819,8 @@ fn test_files() {
f_not_yet_renamed
f_unchanged
");

let outside_repo = test_env.env_root();
let stdout = test_env.jj_cmd_success(outside_repo, &["--", "jj", "log", "f_"]);
insta::assert_snapshot!(stdout, @r"");
}

0 comments on commit f1e91cd

Please sign in to comment.