split: add conflict labels

This commit is contained in:
Scott Taylor 2025-12-14 17:20:05 -06:00
parent 5fd1b2fd5b
commit 042b3838a3

View file

@ -20,6 +20,8 @@ use jj_lib::backend::CommitId;
use jj_lib::commit::Commit;
use jj_lib::matchers::Matcher;
use jj_lib::merge::Diff;
use jj_lib::merge::Merge;
use jj_lib::merged_tree::MergedTree;
use jj_lib::object_id::ObjectId as _;
use jj_lib::rewrite::CommitWithSelection;
use jj_lib::rewrite::EmptyBehavior;
@ -339,9 +341,19 @@ pub(crate) fn cmd_split(
// Merge the original commit tree with its parent using the tree
// containing the user selected changes as the base for the merge.
// This results in a tree with the changes the user didn't select.
target_tree
.merge_unlabeled(target.selected_tree.clone(), target.parent_tree.clone())
.block_on()?
let selected_diff = target.diff_with_labels(
"parents of split commit",
"selected changes for split",
"split commit",
)?;
MergedTree::merge(Merge::from_diffs(
(
target_tree,
format!("split commit ({})", target.commit.conflict_label()),
),
[selected_diff.invert()],
))
.block_on()?
} else {
target_tree
};