mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-05 08:29:30 +03:00
Use the new checkout_combined_trees in upstream integration
This commit is contained in:
parent
7422110a6d
commit
dc45ab2aac
@ -12,7 +12,7 @@ use gitbutler_repo::{
|
|||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{BranchManagerExt, VirtualBranchesExt as _};
|
use crate::{branch_trees::checkout_branch_trees, BranchManagerExt, VirtualBranchesExt as _};
|
||||||
|
|
||||||
#[derive(Serialize, PartialEq, Debug)]
|
#[derive(Serialize, PartialEq, Debug)]
|
||||||
#[serde(tag = "type", content = "subject", rename_all = "camelCase")]
|
#[serde(tag = "type", content = "subject", rename_all = "camelCase")]
|
||||||
@ -282,10 +282,6 @@ pub(crate) fn integrate_upstream(
|
|||||||
|
|
||||||
let mut branches = virtual_branches_state.list_branches_in_workspace()?;
|
let mut branches = virtual_branches_state.list_branches_in_workspace()?;
|
||||||
|
|
||||||
let new_target_tree = context.new_target.tree()?;
|
|
||||||
let mut final_tree = context.new_target.tree()?;
|
|
||||||
let repository = context.repository;
|
|
||||||
|
|
||||||
// Update branch trees
|
// Update branch trees
|
||||||
for (branch_id, integration_result) in &integration_results {
|
for (branch_id, integration_result) in &integration_results {
|
||||||
let IntegrationResult::UpdatedObjects { head, tree } = integration_result else {
|
let IntegrationResult::UpdatedObjects { head, tree } = integration_result else {
|
||||||
@ -300,21 +296,11 @@ pub(crate) fn integrate_upstream(
|
|||||||
branch.tree = *tree;
|
branch.tree = *tree;
|
||||||
|
|
||||||
virtual_branches_state.set_branch(branch.clone())?;
|
virtual_branches_state.set_branch(branch.clone())?;
|
||||||
|
|
||||||
// Combine tree into new working tree
|
|
||||||
{
|
|
||||||
let branch_tree = repository.find_tree(branch.tree)?;
|
|
||||||
let mut merge_result: git2::Index =
|
|
||||||
repository.merge_trees(&new_target_tree, &final_tree, &branch_tree, None)?;
|
|
||||||
let final_tree_oid = merge_result.write_tree_to(repository)?;
|
|
||||||
final_tree = repository.find_tree(final_tree_oid)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repository.checkout_tree_builder(&final_tree)
|
// Now that we've potentially updated the branch trees, lets checkout
|
||||||
.force()
|
// the result of merging them all together.
|
||||||
.checkout()
|
checkout_branch_trees(command_context, permission)?;
|
||||||
.context("failed to checkout index, this should not have happened, we should have already detected this")?;
|
|
||||||
|
|
||||||
virtual_branches_state.set_default_target(Target {
|
virtual_branches_state.set_default_target(Target {
|
||||||
sha: context.new_target.id(),
|
sha: context.new_target.id(),
|
||||||
|
Loading…
Reference in New Issue
Block a user