From df9a3902cd213a78a69566343d629d1f5135d04f Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Wed, 20 Nov 2024 20:01:29 +0100 Subject: [PATCH] Always rebase when applying from existing branch This ensures that change IDs are present --- .../src/branch_manager/branch_creation.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs b/crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs index fd6c06754..ccebd9ce5 100644 --- a/crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs +++ b/crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs @@ -331,7 +331,11 @@ impl BranchManager<'_> { } // Do we need to rebase the branch on top of the default target? - if merge_base != default_target.sha { + + let has_change_id = repo.find_commit(stack.head())?.change_id().is_some(); + // If the branch has no change ID for the head commit, we want to rebase it even if the base is the same + // This way stacking functionality which relies on change IDs will work as expected + if merge_base != default_target.sha || !has_change_id { let new_head = if stack.allow_rebasing { let commits_to_rebase = repo.l(stack.head(), LogUntil::Commit(merge_base), false)?;