From cb7533a5a1bef90c82b1741903db75fe7e69eb70 Mon Sep 17 00:00:00 2001 From: Matt Stark Date: Tue, 2 Jan 2024 11:20:52 +1100 Subject: [PATCH] Rewrite instead of abandoning empty commits. Fixes #2760 Given the tree: ``` A-B-C \ B2 ``` And the command `jj rebase -s B -d B2` We were previously marking B as abandoned, despite the comment stating that we were marking it as being succeeded by B2. This resulted in a call to `rewrite(rewrites={}, abandoned={B})` instead of `rewrite(rewrites={B=>B2}, abandoned={})`, which then made the new parent of `C` into `A` instead of `B2` --- lib/src/rewrite.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index f6d449b4ee..841d011489 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -159,11 +159,11 @@ pub fn rebase_commit_with_options( EmptyBehaviour::AbandonAllEmpty => *parent.tree_id() == new_tree_id, }; if should_abandon { - mut_repo.record_abandoned_commit(old_commit.id().clone()); // Record old_commit as being succeeded by the parent for the purposes of // the rebase. // This ensures that when we stack commits, the second commit knows to // rebase on top of the parent commit, rather than the abandoned commit. + mut_repo.record_rewritten_commit(old_commit.id().clone(), parent.id().clone()); return Ok(parent.clone()); } }