Skip to content

Commit

Permalink
Improved handling of failed git editor check
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenengler committed Jun 23, 2024
1 parent 6b67af2 commit 99d687e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,16 @@ pub fn editor_cmd() -> impl Iterator<Item = impl AsRef<OsStr>> + Clone {
.arg("core.editor")
.output()
{
let mut output = output.stdout;
// the last byte should be a nul
assert_eq!(Some(0), output.pop());

if !output.is_empty() {
let cmd = split_whitespace(&output);
if !cmd.is_empty() {
return cmd;
if output.status.success() {
let mut output = output.stdout;
// the last byte should be a nul
assert!(matches!(output.pop(), Some(0) | None));

if !output.is_empty() {
let cmd = split_whitespace(&output);
if !cmd.is_empty() {
return cmd;
}
}
}
}
Expand Down

0 comments on commit 99d687e

Please sign in to comment.