cli: complete: fix stderr during autocomplete of revsets
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run

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.
This commit is contained in:
Jakob Hellermann 2025-01-10 23:21:54 +01:00
parent 98724278c5
commit f1e91cdab5
2 changed files with 5 additions and 0 deletions

View file

@ -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();

View file

@ -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"");
}