Skip to content

Commit

Permalink
cli: op diff: consolidate match arms of forward diffs
Browse files Browse the repository at this point in the history
These two are equivalent. It's still restricted to zero or one removed commits
because I'm not sure how diverged changes should be rendered.
  • Loading branch information
yuja committed Aug 7, 2024
1 parent f7836aa commit 8cac8fb
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cli/src/commands/operation/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,9 @@ fn show_change_diff(
width: usize,
) -> Result<(), CommandError> {
match (&*change.removed_commits, &*change.added_commits) {
(predecessors @ [_], [commit]) => {
(predecessors @ ([] | [_]), [commit]) => {
// New or modified change. If the modification involved a rebase,
// show diffs from the rebased tree.
let predecessor_tree = rebase_to_dest_parent(repo, predecessors, commit)?;
let tree = commit.tree()?;
diff_renderer.show_diff(
Expand All @@ -568,9 +570,6 @@ fn show_change_diff(
width,
)?;
}
([], [commit]) => {
diff_renderer.show_patch(ui, formatter, commit, &EverythingMatcher, width)?;
}
([commit], []) => {
// TODO: Should we show a reverse diff?
diff_renderer.show_patch(ui, formatter, commit, &EverythingMatcher, width)?;
Expand Down

0 comments on commit 8cac8fb

Please sign in to comment.