Skip to content

Commit 2761ddc

Browse files
authored
Merge pull request #4351 from RalfJung/squash-win
attempt to fix squash on Windows
2 parents ac636db + b7c6cac commit 2761ddc

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

miri-script/src/commands.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,28 @@ impl Command {
404404
// We want to forward the host stdin so apparently we cannot use `cmd!`.
405405
let mut cmd = process::Command::new("git");
406406
cmd.arg("rebase").arg(&base).arg("--interactive");
407-
cmd.env("GIT_SEQUENCE_EDITOR", env::current_exe()?);
407+
let current_exe = {
408+
if cfg!(windows) {
409+
// Apparently git-for-Windows gets confused by backslashes if we just use
410+
// `current_exe()` here. So replace them by forward slashes if this is not a "magic"
411+
// path starting with "\\". This is clearly a git bug but we work around it here.
412+
// Also see <https://github.com/rust-lang/miri/issues/4340>.
413+
let bin = env::current_exe()?;
414+
match bin.into_os_string().into_string() {
415+
Err(not_utf8) => not_utf8.into(), // :shrug:
416+
Ok(str) => {
417+
if str.starts_with(r"\\") {
418+
str.into() // don't touch these magic paths, they must use backslashes
419+
} else {
420+
str.replace('\\', "/").into()
421+
}
422+
}
423+
}
424+
} else {
425+
env::current_exe()?
426+
}
427+
};
428+
cmd.env("GIT_SEQUENCE_EDITOR", current_exe);
408429
cmd.env("MIRI_SCRIPT_IS_GIT_SEQUENCE_EDITOR", "1");
409430
cmd.current_dir(sh.current_dir());
410431
let result = cmd.status()?;

0 commit comments

Comments
 (0)