cli: lift a return statement out of an if-else block

As pointed out by IntelliJ (maybe it came from rust-analyzer or
something, I don't know). I also lifted out
`Err(CommandError::UserError())` and extracted a variable.
This commit is contained in:
Martin von Zweigbergk 2022-09-19 13:49:46 -07:00 committed by Martin von Zweigbergk
parent 8402dd8264
commit 5270c165ed

View file

@ -2308,20 +2308,21 @@ fn cmd_untrack(
locked_working_copy.discard();
let path = &added_back[0].0;
let ui_path = workspace_command.format_file_path(path);
if added_back.len() > 1 {
return Err(CommandError::UserError(format!(
let message = if added_back.len() > 1 {
format!(
"'{}' and {} other files would be added back because they're not ignored. \
Make sure they're ignored, then try again.",
ui_path,
added_back.len() - 1
)));
)
} else {
return Err(CommandError::UserError(format!(
format!(
"'{}' would be added back because it's not ignored. Make sure it's ignored, \
then try again.",
ui_path
)));
}
)
};
return Err(CommandError::UserError(message));
} else {
// This means there were some concurrent changes made in the working copy. We
// don't want to mix those in, so reset the working copy again.