diff --git a/crates/gitbutler-core/src/virtual_branches/integration.rs b/crates/gitbutler-core/src/virtual_branches/integration.rs index 4944c9560..3d45b687b 100644 --- a/crates/gitbutler-core/src/virtual_branches/integration.rs +++ b/crates/gitbutler-core/src/virtual_branches/integration.rs @@ -121,10 +121,17 @@ fn write_integration_file(head: &git::Reference, path: PathBuf) -> Result<()> { std::fs::write(path, format!(":{}", sha))?; Ok(()) } - pub fn update_gitbutler_integration( vb_state: &VirtualBranchesHandle, project_repository: &project_repository::Repository, +) -> Result { + update_gitbutler_integration_with_commit(vb_state, project_repository, None) +} + +pub fn update_gitbutler_integration_with_commit( + vb_state: &VirtualBranchesHandle, + project_repository: &project_repository::Repository, + integration_commit_id: Option, ) -> Result { let target = vb_state .get_default_target() @@ -175,7 +182,10 @@ pub fn update_gitbutler_integration( .filter(|branch| branch.applied) .collect::>(); - let integration_commit_id = get_workspace_head(&vb_state, project_repository)?; + let integration_commit_id = match integration_commit_id { + Some(commit_id) => commit_id, + _ => get_workspace_head(&vb_state, project_repository)?, + }; let integration_commit = repo.find_commit(integration_commit_id).unwrap(); let integration_tree = integration_commit.tree()?; diff --git a/crates/gitbutler-core/src/virtual_branches/virtual.rs b/crates/gitbutler-core/src/virtual_branches/virtual.rs index 8cf9e9d2a..0f1b4581b 100644 --- a/crates/gitbutler-core/src/virtual_branches/virtual.rs +++ b/crates/gitbutler-core/src/virtual_branches/virtual.rs @@ -788,7 +788,11 @@ pub fn list_virtual_branches( .find_commit(integration_commit_id) .unwrap(); - super::integration::update_gitbutler_integration(&vb_state, project_repository)?; + super::integration::update_gitbutler_integration_with_commit( + &vb_state, + project_repository, + Some(integration_commit_id), + )?; let (statuses, skipped_files) = get_status_by_branch(project_repository, Some(&integration_commit.id()))?;