diff --git a/crates/but-testing/src/command/mod.rs b/crates/but-testing/src/command/mod.rs index b4f337a870..b306b0d967 100644 --- a/crates/but-testing/src/command/mod.rs +++ b/crates/but-testing/src/command/mod.rs @@ -14,7 +14,7 @@ use but_workspace::{ DiffSpec, HunkHeader, branch::{ OnWorkspaceMergeConflict, - apply::{IntegrationMode, WorkspaceReferenceNaming}, + apply::{WorkspaceMerge, WorkspaceReferenceNaming}, checkout::UncommitedWorktreeChanges, create_reference::{Anchor, Position}, }, @@ -709,7 +709,7 @@ pub fn apply(args: &super::Args, short_name: &str, order: Option) -> anyh &repo, &mut *meta, but_workspace::branch::apply::Options { - integration_mode: IntegrationMode::AlwaysMerge, + workspace_merge: WorkspaceMerge::AlwaysMerge, on_workspace_conflict: OnWorkspaceMergeConflict::MaterializeAndReportConflictingStacks, workspace_reference_naming: WorkspaceReferenceNaming::Default, uncommitted_changes: UncommitedWorktreeChanges::KeepAndAbortOnConflict, diff --git a/crates/but-workspace/src/branch/apply.rs b/crates/but-workspace/src/branch/apply.rs index 997a24cba0..a92312c493 100644 --- a/crates/but-workspace/src/branch/apply.rs +++ b/crates/but-workspace/src/branch/apply.rs @@ -62,12 +62,12 @@ impl std::fmt::Debug for Outcome<'_> { } } -/// How the newly applied branch should be integrated into the workspace. +/// How the newly applied branch should be merged into the workspace commit. #[derive(Default, Debug, Copy, Clone)] -pub enum IntegrationMode { +pub enum WorkspaceMerge { /// Do nothing but to merge it into the workspace commit, *even* if it's not needed as the workspace reference /// can connect directly with the *one* workspace base. - /// This also ensures that there is a workspace merge commit. + /// This also ensures that there is a workspace merge commit, even if it is none-sensical. #[default] AlwaysMerge, /// Only create a merge commit if a new commit is effectively merged in. This avoids *unnecessary* merge commits, @@ -89,8 +89,8 @@ pub enum WorkspaceReferenceNaming { /// Options for [function::apply()]. #[derive(Default, Debug, Clone)] pub struct Options { - /// how the branch should be brought into the workspace. - pub integration_mode: IntegrationMode, + /// How the branch should be brought into the workspace. + pub workspace_merge: WorkspaceMerge, /// Decide how to deal with conflicts when creating the workspace merge commit to bring in each stack. pub on_workspace_conflict: OnWorkspaceMergeConflict, /// How the workspace reference should be named should it be created. @@ -132,7 +132,7 @@ pub(crate) mod function { }; use tracing::instrument; - use super::{IntegrationMode, Options, Outcome, WorkspaceReferenceNaming}; + use super::{Options, Outcome, WorkspaceMerge, WorkspaceReferenceNaming}; use crate::{WorkspaceCommit, branch::checkout, ext::ObjectStorageExt, ref_info::WorkspaceExt}; /// Apply `branch` to the given `workspace`, and possibly create the workspace reference in `repo` @@ -162,7 +162,7 @@ pub(crate) mod function { repo: &gix::Repository, meta: &mut impl RefMetadata, Options { - integration_mode, + workspace_merge: integration_mode, on_workspace_conflict, workspace_reference_naming, uncommitted_changes, @@ -390,7 +390,7 @@ pub(crate) mod function { &ws_md, local_tracking_config_and_ref_info, )?; - let ws_commit_with_new_message = WorkspaceCommit::from_graph_workspace( + let ws_commit_with_new_message = WorkspaceCommit::from_graph_workspace_and_tree( &workspace, repo, head_id.object()?.peel_to_tree()?.id, @@ -635,7 +635,7 @@ pub(crate) mod function { /// Setup `local_tracking_ref` to track `remote_tracking_ref` using the typical pattern, and prepare the configuration file /// so that it can replace `.git/config` of `repo` when written back, with everything the same but the branch configuration added. /// We also return the commit at which `local_tracking_ref` should be placed, which is assumed to not exist, and `repo` will be used - /// for computing the merge-base with `ws_ref_name`, traditionally, without a graph, as forcing the graph here wouldn't buy us anything. + /// for computing the merge-base with `ws_ref_id`, traditionally, without a graph, as forcing the graph here wouldn't buy us anything. /// Merge-base computations can still be done with `repo` IF the graph isn't up to date. fn setup_local_tracking_configuration( repo: &gix::Repository, @@ -827,10 +827,10 @@ pub(crate) mod function { fn needs_workspace_commit_without_remerge( ws: &but_graph::projection::Workspace<'_>, - integration_mode: IntegrationMode, + integration_mode: WorkspaceMerge, ) -> bool { match integration_mode { - IntegrationMode::AlwaysMerge => match ws.kind { + WorkspaceMerge::AlwaysMerge => match ws.kind { WorkspaceKind::Managed { .. } => false, WorkspaceKind::AdHoc => { // If it's still ad-hoc, there must be a reason, and we don't try to create a managed commit @@ -838,7 +838,7 @@ pub(crate) mod function { } WorkspaceKind::ManagedMissingWorkspaceCommit { .. } => true, }, - IntegrationMode::MergeIfNeeded => false, + WorkspaceMerge::MergeIfNeeded => false, } } diff --git a/crates/but-workspace/src/commit.rs b/crates/but-workspace/src/commit.rs index 3a3a7e8023..6636fec710 100644 --- a/crates/but-workspace/src/commit.rs +++ b/crates/but-workspace/src/commit.rs @@ -386,7 +386,7 @@ impl<'repo> WorkspaceCommit<'repo> { /// A way to create a commit from `workspace` stacks, with the `tree` being used as the tree of the workspace commit. /// It's supposed to be the legitimate merge of the stacks contained in `workspace`. /// Note that it will be written to `repo` immediately for persistence, with its object id returned. - pub fn from_graph_workspace( + pub fn from_graph_workspace_and_tree( workspace: &but_graph::projection::Workspace, repo: &'repo gix::Repository, tree: gix::ObjectId, diff --git a/crates/but-workspace/tests/workspace/branch/apply_unapply_commit_uncommit.rs b/crates/but-workspace/tests/workspace/branch/apply_unapply_commit_uncommit.rs index 0159b9bc72..216e565ed3 100644 --- a/crates/but-workspace/tests/workspace/branch/apply_unapply_commit_uncommit.rs +++ b/crates/but-workspace/tests/workspace/branch/apply_unapply_commit_uncommit.rs @@ -10,7 +10,7 @@ use but_testsupport::{ }; use but_workspace::branch::{ OnWorkspaceMergeConflict, - apply::{IntegrationMode, WorkspaceReferenceNaming}, + apply::{WorkspaceMerge, WorkspaceReferenceNaming}, checkout::UncommitedWorktreeChanges, }; use gix::refs::Category; @@ -372,7 +372,7 @@ fn no_ws_ref_no_ws_commit_two_stacks_on_same_commit_ad_hoc_workspace_without_tar &repo, &mut meta, but_workspace::branch::apply::Options { - integration_mode: IntegrationMode::AlwaysMerge, + workspace_merge: WorkspaceMerge::AlwaysMerge, ..default_options() }, )?; @@ -396,7 +396,7 @@ fn no_ws_ref_no_ws_commit_two_stacks_on_same_commit_ad_hoc_workspace_without_tar &repo, &mut meta, but_workspace::branch::apply::Options { - integration_mode: IntegrationMode::AlwaysMerge, + workspace_merge: WorkspaceMerge::AlwaysMerge, ..default_options() }, )?; @@ -1540,7 +1540,7 @@ fn unborn_apply_needs_base() -> anyhow::Result<()> { fn default_options() -> but_workspace::branch::apply::Options { but_workspace::branch::apply::Options { - integration_mode: IntegrationMode::MergeIfNeeded, + workspace_merge: WorkspaceMerge::MergeIfNeeded, on_workspace_conflict: OnWorkspaceMergeConflict::AbortAndReportConflictingStacks, workspace_reference_naming: WorkspaceReferenceNaming::Default, uncommitted_changes: UncommitedWorktreeChanges::KeepAndAbortOnConflict, 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 92412bfecd..2feb36234a 100644 --- a/crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs +++ b/crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs @@ -2,7 +2,7 @@ use anyhow::{Context, Result, anyhow, bail}; use but_workspace::{ branch::{ OnWorkspaceMergeConflict, - apply::{IntegrationMode, WorkspaceReferenceNaming}, + apply::{WorkspaceMerge, WorkspaceReferenceNaming}, checkout::UncommitedWorktreeChanges, }, stack_ext::StackExt, @@ -159,7 +159,7 @@ impl BranchManager<'_> { &repo, &mut *meta, but_workspace::branch::apply::Options { - integration_mode: IntegrationMode::AlwaysMerge, + workspace_merge: WorkspaceMerge::AlwaysMerge, on_workspace_conflict: OnWorkspaceMergeConflict::MaterializeAndReportConflictingStacks, workspace_reference_naming: WorkspaceReferenceNaming::Default,