Skip to content

Commit a5010be

Browse files
authored
Merge pull request #10863 from Byron/next
v3 apply: rebase support
2 parents 02ee544 + 8db85dc commit a5010be

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

crates/but-testing/src/command/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use but_workspace::{
1414
DiffSpec, HunkHeader,
1515
branch::{
1616
OnWorkspaceMergeConflict,
17-
apply::{IntegrationMode, WorkspaceReferenceNaming},
17+
apply::{WorkspaceMerge, WorkspaceReferenceNaming},
1818
checkout::UncommitedWorktreeChanges,
1919
create_reference::{Anchor, Position},
2020
},
@@ -709,7 +709,7 @@ pub fn apply(args: &super::Args, short_name: &str, order: Option<usize>) -> anyh
709709
&repo,
710710
&mut *meta,
711711
but_workspace::branch::apply::Options {
712-
integration_mode: IntegrationMode::AlwaysMerge,
712+
workspace_merge: WorkspaceMerge::AlwaysMerge,
713713
on_workspace_conflict: OnWorkspaceMergeConflict::MaterializeAndReportConflictingStacks,
714714
workspace_reference_naming: WorkspaceReferenceNaming::Default,
715715
uncommitted_changes: UncommitedWorktreeChanges::KeepAndAbortOnConflict,

crates/but-workspace/src/branch/apply.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ impl std::fmt::Debug for Outcome<'_> {
6262
}
6363
}
6464

65-
/// How the newly applied branch should be integrated into the workspace.
65+
/// How the newly applied branch should be merged into the workspace commit.
6666
#[derive(Default, Debug, Copy, Clone)]
67-
pub enum IntegrationMode {
67+
pub enum WorkspaceMerge {
6868
/// Do nothing but to merge it into the workspace commit, *even* if it's not needed as the workspace reference
6969
/// can connect directly with the *one* workspace base.
70-
/// This also ensures that there is a workspace merge commit.
70+
/// This also ensures that there is a workspace merge commit, even if it is none-sensical.
7171
#[default]
7272
AlwaysMerge,
7373
/// 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 {
8989
/// Options for [function::apply()].
9090
#[derive(Default, Debug, Clone)]
9191
pub struct Options {
92-
/// how the branch should be brought into the workspace.
93-
pub integration_mode: IntegrationMode,
92+
/// How the branch should be brought into the workspace.
93+
pub workspace_merge: WorkspaceMerge,
9494
/// Decide how to deal with conflicts when creating the workspace merge commit to bring in each stack.
9595
pub on_workspace_conflict: OnWorkspaceMergeConflict,
9696
/// How the workspace reference should be named should it be created.
@@ -132,7 +132,7 @@ pub(crate) mod function {
132132
};
133133
use tracing::instrument;
134134

135-
use super::{IntegrationMode, Options, Outcome, WorkspaceReferenceNaming};
135+
use super::{Options, Outcome, WorkspaceMerge, WorkspaceReferenceNaming};
136136
use crate::{WorkspaceCommit, branch::checkout, ext::ObjectStorageExt, ref_info::WorkspaceExt};
137137

138138
/// Apply `branch` to the given `workspace`, and possibly create the workspace reference in `repo`
@@ -162,7 +162,7 @@ pub(crate) mod function {
162162
repo: &gix::Repository,
163163
meta: &mut impl RefMetadata,
164164
Options {
165-
integration_mode,
165+
workspace_merge: integration_mode,
166166
on_workspace_conflict,
167167
workspace_reference_naming,
168168
uncommitted_changes,
@@ -390,7 +390,7 @@ pub(crate) mod function {
390390
&ws_md,
391391
local_tracking_config_and_ref_info,
392392
)?;
393-
let ws_commit_with_new_message = WorkspaceCommit::from_graph_workspace(
393+
let ws_commit_with_new_message = WorkspaceCommit::from_graph_workspace_and_tree(
394394
&workspace,
395395
repo,
396396
head_id.object()?.peel_to_tree()?.id,
@@ -635,7 +635,7 @@ pub(crate) mod function {
635635
/// Setup `local_tracking_ref` to track `remote_tracking_ref` using the typical pattern, and prepare the configuration file
636636
/// so that it can replace `.git/config` of `repo` when written back, with everything the same but the branch configuration added.
637637
/// We also return the commit at which `local_tracking_ref` should be placed, which is assumed to not exist, and `repo` will be used
638-
/// for computing the merge-base with `ws_ref_name`, traditionally, without a graph, as forcing the graph here wouldn't buy us anything.
638+
/// for computing the merge-base with `ws_ref_id`, traditionally, without a graph, as forcing the graph here wouldn't buy us anything.
639639
/// Merge-base computations can still be done with `repo` IF the graph isn't up to date.
640640
fn setup_local_tracking_configuration(
641641
repo: &gix::Repository,
@@ -827,18 +827,18 @@ pub(crate) mod function {
827827

828828
fn needs_workspace_commit_without_remerge(
829829
ws: &but_graph::projection::Workspace<'_>,
830-
integration_mode: IntegrationMode,
830+
integration_mode: WorkspaceMerge,
831831
) -> bool {
832832
match integration_mode {
833-
IntegrationMode::AlwaysMerge => match ws.kind {
833+
WorkspaceMerge::AlwaysMerge => match ws.kind {
834834
WorkspaceKind::Managed { .. } => false,
835835
WorkspaceKind::AdHoc => {
836836
// If it's still ad-hoc, there must be a reason, and we don't try to create a managed commit
837837
false
838838
}
839839
WorkspaceKind::ManagedMissingWorkspaceCommit { .. } => true,
840840
},
841-
IntegrationMode::MergeIfNeeded => false,
841+
WorkspaceMerge::MergeIfNeeded => false,
842842
}
843843
}
844844

crates/but-workspace/src/commit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl<'repo> WorkspaceCommit<'repo> {
386386
/// A way to create a commit from `workspace` stacks, with the `tree` being used as the tree of the workspace commit.
387387
/// It's supposed to be the legitimate merge of the stacks contained in `workspace`.
388388
/// Note that it will be written to `repo` immediately for persistence, with its object id returned.
389-
pub fn from_graph_workspace(
389+
pub fn from_graph_workspace_and_tree(
390390
workspace: &but_graph::projection::Workspace,
391391
repo: &'repo gix::Repository,
392392
tree: gix::ObjectId,

crates/but-workspace/tests/workspace/branch/apply_unapply_commit_uncommit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use but_testsupport::{
1010
};
1111
use but_workspace::branch::{
1212
OnWorkspaceMergeConflict,
13-
apply::{IntegrationMode, WorkspaceReferenceNaming},
13+
apply::{WorkspaceMerge, WorkspaceReferenceNaming},
1414
checkout::UncommitedWorktreeChanges,
1515
};
1616
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
372372
&repo,
373373
&mut meta,
374374
but_workspace::branch::apply::Options {
375-
integration_mode: IntegrationMode::AlwaysMerge,
375+
workspace_merge: WorkspaceMerge::AlwaysMerge,
376376
..default_options()
377377
},
378378
)?;
@@ -396,7 +396,7 @@ fn no_ws_ref_no_ws_commit_two_stacks_on_same_commit_ad_hoc_workspace_without_tar
396396
&repo,
397397
&mut meta,
398398
but_workspace::branch::apply::Options {
399-
integration_mode: IntegrationMode::AlwaysMerge,
399+
workspace_merge: WorkspaceMerge::AlwaysMerge,
400400
..default_options()
401401
},
402402
)?;
@@ -1540,7 +1540,7 @@ fn unborn_apply_needs_base() -> anyhow::Result<()> {
15401540

15411541
fn default_options() -> but_workspace::branch::apply::Options {
15421542
but_workspace::branch::apply::Options {
1543-
integration_mode: IntegrationMode::MergeIfNeeded,
1543+
workspace_merge: WorkspaceMerge::MergeIfNeeded,
15441544
on_workspace_conflict: OnWorkspaceMergeConflict::AbortAndReportConflictingStacks,
15451545
workspace_reference_naming: WorkspaceReferenceNaming::Default,
15461546
uncommitted_changes: UncommitedWorktreeChanges::KeepAndAbortOnConflict,

crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{Context, Result, anyhow, bail};
22
use but_workspace::{
33
branch::{
44
OnWorkspaceMergeConflict,
5-
apply::{IntegrationMode, WorkspaceReferenceNaming},
5+
apply::{WorkspaceMerge, WorkspaceReferenceNaming},
66
checkout::UncommitedWorktreeChanges,
77
},
88
stack_ext::StackExt,
@@ -159,7 +159,7 @@ impl BranchManager<'_> {
159159
&repo,
160160
&mut *meta,
161161
but_workspace::branch::apply::Options {
162-
integration_mode: IntegrationMode::AlwaysMerge,
162+
workspace_merge: WorkspaceMerge::AlwaysMerge,
163163
on_workspace_conflict:
164164
OnWorkspaceMergeConflict::MaterializeAndReportConflictingStacks,
165165
workspace_reference_naming: WorkspaceReferenceNaming::Default,

0 commit comments

Comments
 (0)