about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-05-28 06:33:28 +0000
committerGitHub <noreply@github.com>2025-05-28 06:33:28 +0000
commit98485a89f83b3d5cb03a27eaed3c2c59fc5336cb (patch)
tree04479c0c1843e28ae02ffc5dfe78e1365eab5220
parentcbdc930747b0d1aad368b83dcd29d1904fb1a794 (diff)
parentd7c62a037c4fd4ed087247c5b1c8780d4847c3ca (diff)
downloadrust-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.rs23
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()?;