ok/jj
1
0
Fork 0
forked from mirrors/jj

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.
This commit is contained in:
Yuya Nishihara 2024-08-06 18:34:56 +09:00
parent f7836aa687
commit 8cac8fba5a

View file

@ -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)?;