diff options
| author | Ralf Jung <post@ralfj.de> | 2025-05-28 06:33:28 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-28 06:33:28 +0000 |
| commit | 98485a89f83b3d5cb03a27eaed3c2c59fc5336cb (patch) | |
| tree | 04479c0c1843e28ae02ffc5dfe78e1365eab5220 | |
| parent | cbdc930747b0d1aad368b83dcd29d1904fb1a794 (diff) | |
| parent | d7c62a037c4fd4ed087247c5b1c8780d4847c3ca (diff) | |
| download | rust-98485a89f83b3d5cb03a27eaed3c2c59fc5336cb.tar.gz rust-98485a89f83b3d5cb03a27eaed3c2c59fc5336cb.zip | |
Merge pull request #4351 from RalfJung/squash-win
attempt to fix squash on Windows
| -rw-r--r-- | src/tools/miri/miri-script/src/commands.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/tools/miri/miri-script/src/commands.rs b/src/tools/miri/miri-script/src/commands.rs index 1781ca119ee..86362145d47 100644 --- a/src/tools/miri/miri-script/src/commands.rs +++ b/src/tools/miri/miri-script/src/commands.rs @@ -404,7 +404,28 @@ impl Command { // We want to forward the host stdin so apparently we cannot use `cmd!`. let mut cmd = process::Command::new("git"); cmd.arg("rebase").arg(&base).arg("--interactive"); - cmd.env("GIT_SEQUENCE_EDITOR", env::current_exe()?); + let current_exe = { + if cfg!(windows) { + // Apparently git-for-Windows gets confused by backslashes if we just use + // `current_exe()` here. So replace them by forward slashes if this is not a "magic" + // path starting with "\\". This is clearly a git bug but we work around it here. + // Also see <https://github.com/rust-lang/miri/issues/4340>. + let bin = env::current_exe()?; + match bin.into_os_string().into_string() { + Err(not_utf8) => not_utf8.into(), // :shrug: + Ok(str) => { + if str.starts_with(r"\\") { + str.into() // don't touch these magic paths, they must use backslashes + } else { + str.replace('\\', "/").into() + } + } + } + } else { + env::current_exe()? + } + }; + cmd.env("GIT_SEQUENCE_EDITOR", current_exe); cmd.env("MIRI_SCRIPT_IS_GIT_SEQUENCE_EDITOR", "1"); cmd.current_dir(sh.current_dir()); let result = cmd.status()?; |
