conflicts: use an early return to reduce indentation

Thanks to @ilyagr for the suggestion.
This commit is contained in:
Martin von Zweigbergk 2023-06-03 20:26:53 -07:00 committed by Martin von Zweigbergk
parent f4499aa65e
commit 9907cccf37

View file

@ -464,7 +464,15 @@ pub fn update_conflict_from_content(
// further down.
let mut removed_content = vec![vec![]; conflict.removes().len()];
let mut added_content = vec![vec![]; conflict.adds().len()];
if let Some(hunks) = parse_conflict(content, conflict.removes().len(), conflict.adds().len()) {
// TODO: Change to let-else once our MSRV is above 1.65
let hunks = if let Some(hunks) =
parse_conflict(content, conflict.removes().len(), conflict.adds().len())
{
hunks
} else {
// Either there are no conflict markers of they don't have the expected arity
return Ok(None);
};
for hunk in hunks {
match hunk {
MergeHunk::Resolved(slice) => {
@ -532,9 +540,6 @@ pub fn update_conflict_from_content(
}
let new_conflict_id = store.write_conflict(path, &conflict.to_backend_conflict())?;
Ok(Some(new_conflict_id))
} else {
Ok(None)
}
}
#[cfg(test)]