@@ -3,6 +3,9 @@ use but_core::UnifiedDiff;
3
3
use but_db:: poll:: ItemKind ;
4
4
use but_graph:: VirtualBranchesTomlMetadata ;
5
5
use but_settings:: AppSettings ;
6
+ use but_workspace:: branch:: OnWorkspaceMergeConflict ;
7
+ use but_workspace:: branch:: apply:: { IntegrationMode , WorkspaceReferenceNaming } ;
8
+ use but_workspace:: branch:: checkout:: UncommitedWorktreeChanges ;
6
9
use but_workspace:: branch:: create_reference:: { Anchor , Position } ;
7
10
use but_workspace:: { DiffSpec , HunkHeader } ;
8
11
use gitbutler_project:: { Project , ProjectId } ;
@@ -633,6 +636,32 @@ pub fn remove_reference(
633
636
Ok ( ( ) )
634
637
}
635
638
639
+ pub fn apply ( args : & super :: Args , short_name : & str , order : Option < usize > ) -> anyhow:: Result < ( ) > {
640
+ let ( repo, project, graph, mut meta) =
641
+ repo_and_maybe_project_and_graph ( args, RepositoryOpenMode :: Merge ) ?;
642
+ let branch = repo. find_reference ( short_name) ?;
643
+ let ws = graph. to_workspace ( ) ?;
644
+ _ = but_workspace:: branch:: apply (
645
+ branch. name ( ) ,
646
+ & ws,
647
+ & repo,
648
+ & mut * meta,
649
+ but_workspace:: branch:: apply:: Options {
650
+ integration_mode : IntegrationMode :: AlwaysMerge ,
651
+ on_workspace_conflict : OnWorkspaceMergeConflict :: MaterializeAndReportConflictingStacks ,
652
+ workspace_reference_naming : WorkspaceReferenceNaming :: Default ,
653
+ uncommitted_changes : UncommitedWorktreeChanges :: KeepAndAbortOnConflict ,
654
+ order,
655
+ } ,
656
+ ) ?;
657
+
658
+ if project. is_some ( ) {
659
+ // write metadata if there are projects - this is a special case while we use vb.toml.
660
+ ManuallyDrop :: into_inner ( meta) ;
661
+ }
662
+ Ok ( ( ) )
663
+ }
664
+
636
665
pub fn create_reference (
637
666
args : & super :: Args ,
638
667
short_name : & str ,
0 commit comments