Skip to content

Commit cc2857b

Browse files
committed
fix: interpret-trailer values for Windows
Running `git interpret-trailers` can be difficult on Windows due to weird/inconsistent/broken command line parsing. Splitting the "--trailer" flag from its value is a partial mitigation of these problems. On Windows, Command.arg() does some magic auto-quoting. A value such as "--trailer=Signed-off-by=Some Name <[email protected]>" will be quoted such that *some* git executables will interpret the whole shebang as a file argument. The Git for Windows executable has different (better, probably) behavior than, for example, git built for MSYS2/MINGW/CRT64 environment. For the MSYS2 git, this change may work in some cases (e.g. if the trailer value is all ASCII?), but not in others (e.g. if there are any non-ASCII characters?). So, partial mitigation.
1 parent 3c7d614 commit cc2857b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/stupid/context.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -696,14 +696,13 @@ impl<'repo, 'index> StupidContext<'repo, 'index> {
696696
message: &[u8],
697697
trailers: impl IntoIterator<Item = (&'a str, &'a str)>,
698698
) -> Result<Vec<u8>> {
699-
let output = self
700-
.git()
701-
.arg("interpret-trailers")
702-
.args(
703-
trailers
704-
.into_iter()
705-
.map(|(trailer, by)| format!("--trailer={trailer}={by}")),
706-
)
699+
let mut command = self.git();
700+
command.arg("interpret-trailers");
701+
for (trailer, by) in trailers {
702+
command.arg("--trailer");
703+
command.arg(format!("{trailer}={by}"));
704+
}
705+
let output = command
707706
.stdout(Stdio::piped())
708707
.in_and_out(message)?
709708
.require_success("interpret-trailers")?;

0 commit comments

Comments
 (0)