From 8cac8fba5ac5412fc652f05511b7ebfb095fdcb9 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 6 Aug 2024 18:34:56 +0900 Subject: [PATCH] cli: op diff: consolidate match arms of forward diffs 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. --- cli/src/commands/operation/diff.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/src/commands/operation/diff.rs b/cli/src/commands/operation/diff.rs index 84ee6e706f..7b9b32a5b2 100644 --- a/cli/src/commands/operation/diff.rs +++ b/cli/src/commands/operation/diff.rs @@ -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( @@ -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)?;