From 915acd6afbcdbe7b0d27aceaf1c2a8c3b3bb40ef Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Tue, 8 Oct 2024 22:24:34 +0200 Subject: [PATCH] Fixes a bug when validating stack target commit --- crates/gitbutler-stack-api/src/stack_ext.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/gitbutler-stack-api/src/stack_ext.rs b/crates/gitbutler-stack-api/src/stack_ext.rs index 3105dae55..e4320db82 100644 --- a/crates/gitbutler-stack-api/src/stack_ext.rs +++ b/crates/gitbutler-stack-api/src/stack_ext.rs @@ -591,9 +591,14 @@ fn commit_by_branch_id_and_change_id<'a>( ) -> Result> { // Find the commit with the change id let merge_base = ctx.repository().merge_base(stack_head, target_sha)?; - let commit = ctx - .repository() - .log(stack_head, LogUntil::Commit(merge_base))? + + let commits = if stack_head == merge_base { + vec![ctx.repository().find_commit(stack_head)?] + } else { + ctx.repository() + .log(stack_head, LogUntil::Commit(merge_base))? + }; + let commit = commits .iter() .map(|c| c.id()) .find(|c| {