Use -- in more places that call subcommands with paths (#53484)

Thanks to Dario Weißer for the suggestion

Release Notes:

- Fixed some potential edge cases when paths in a project started
  with `-`.
This commit is contained in:
Conrad Irwin 2026-04-09 20:38:21 -06:00 committed by GitHub
parent f1d9afff66
commit b8766ef3af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 5 deletions

View file

@ -196,7 +196,7 @@ impl Docker {
async fn pull_image(&self, image: &String) -> Result<(), DevContainerError> {
let mut command = Command::new(&self.docker_cli);
command.args(&["pull", image]);
command.args(&["pull", "--", image]);
let output = command.output().await.map_err(|e| {
log::error!("Error pulling image: {e}");

View file

@ -58,7 +58,7 @@ async fn run_git_blame(
let mut child = {
let span = ztracing::debug_span!("spawning git-blame command", path = path.as_unix_str());
let _enter = span.enter();
git.build_command(&["blame", "--incremental", "--contents", "-"])
git.build_command(&["blame", "--incremental", "--contents", "-", "--"])
.arg(path.as_unix_str())
.stdin(Stdio::piped())
.stdout(Stdio::piped())

View file

@ -1462,7 +1462,7 @@ impl GitRepository for RealGitRepository {
log::debug!("indexing SHA: {sha}, path {path:?}");
let output = git
.build_command(&["update-index", "--add", "--cacheinfo", mode, sha])
.build_command(&["update-index", "--add", "--cacheinfo", mode, sha, "--"])
.envs(env.iter())
.arg(path.as_unix_str())
.output()
@ -1476,7 +1476,7 @@ impl GitRepository for RealGitRepository {
} else {
log::debug!("removing path {path:?} from the index");
let output = git
.build_command(&["update-index", "--force-remove"])
.build_command(&["update-index", "--force-remove", "--"])
.envs(env.iter())
.arg(path.as_unix_str())
.output()
@ -2114,7 +2114,7 @@ impl GitRepository for RealGitRepository {
.spawn(async move {
let git = git_binary?;
let output = git
.build_command(&["stash", "push", "--quiet", "--include-untracked"])
.build_command(&["stash", "push", "--quiet", "--include-untracked", "--"])
.envs(env.iter())
.args(paths.iter().map(|p| p.as_unix_str()))
.output()
@ -3146,6 +3146,7 @@ fn git_status_args(path_prefixes: &[RepoPath]) -> Vec<OsString> {
OsString::from("--untracked-files=all"),
OsString::from("--no-renames"),
OsString::from("-z"),
OsString::from("--"),
];
args.extend(path_prefixes.iter().map(|path_prefix| {
if path_prefix.is_empty() {

View file

@ -858,6 +858,7 @@ impl Platform for MacPlatform {
.background_executor
.spawn(async move {
if let Some(mut child) = new_command("open")
.arg("--")
.arg(path)
.spawn()
.context("invoking open command")