@@ -375,6 +375,14 @@ pub mod merge {
375375 Theirs ,
376376 }
377377
378+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , PartialOrd , Ord , clap:: ValueEnum ) ]
379+ pub enum TreeFavor {
380+ /// Use only the previous tree entry in case of conflict.
381+ Ancestor ,
382+ /// Use only ours tree entry in case of conflict.
383+ Ours ,
384+ }
385+
378386 impl From < FileFavor > for gix:: merge:: tree:: FileFavor {
379387 fn from ( value : FileFavor ) -> Self {
380388 match value {
@@ -384,6 +392,33 @@ pub mod merge {
384392 }
385393 }
386394
395+ impl From < TreeFavor > for gix:: merge:: tree:: TreeFavor {
396+ fn from ( value : TreeFavor ) -> Self {
397+ match value {
398+ TreeFavor :: Ancestor => gix:: merge:: tree:: TreeFavor :: Ancestor ,
399+ TreeFavor :: Ours => gix:: merge:: tree:: TreeFavor :: Ours ,
400+ }
401+ }
402+ }
403+
404+ #[ derive( Debug , clap:: Parser ) ]
405+ pub struct SharedOptions {
406+ /// Keep all objects to be written in memory to avoid any disk IO.
407+ ///
408+ /// Note that the resulting tree won't be available or inspectable.
409+ #[ clap( long, short = 'm' ) ]
410+ pub in_memory : bool ,
411+ /// Decide how to resolve content conflicts in files. If unset, write conflict markers and fail.
412+ #[ clap( long, short = 'f' ) ]
413+ pub file_favor : Option < FileFavor > ,
414+ /// Decide how to resolve conflicts in trees, i.e. modification/deletion. If unset, try to preserve both states and fail.
415+ #[ clap( long, short = 't' ) ]
416+ pub tree_favor : Option < TreeFavor > ,
417+ /// Print additional information about conflicts for debugging.
418+ #[ clap( long, short = 'd' ) ]
419+ pub debug : bool ,
420+ }
421+
387422 #[ derive( Debug , clap:: Parser ) ]
388423 #[ command( about = "perform merges of various kinds" ) ]
389424 pub struct Platform {
@@ -412,17 +447,8 @@ pub mod merge {
412447
413448 /// Merge a tree by specifying ours, base and theirs, writing it to the object database.
414449 Tree {
415- /// Keep all objects to be written in memory to avoid any disk IO.
416- ///
417- /// Note that the resulting tree won't be available or inspectable.
418- #[ clap( long, short = 'm' ) ]
419- in_memory : bool ,
420- /// Decide how to resolve content conflicts in files. If unset, write conflict markers and fail.
421- #[ clap( long, short = 'f' ) ]
422- file_favor : Option < FileFavor > ,
423- /// Print additional information about conflicts for debugging.
424- #[ clap( long, short = 'd' ) ]
425- debug : bool ,
450+ #[ clap( flatten) ]
451+ opts : SharedOptions ,
426452
427453 /// A revspec to our treeish.
428454 #[ clap( value_name = "OURS" , value_parser = crate :: shared:: AsBString ) ]
@@ -436,17 +462,8 @@ pub mod merge {
436462 } ,
437463 /// Merge a commits by specifying ours, and theirs, writing the tree to the object database.
438464 Commit {
439- /// Keep all objects to be written in memory to avoid any disk IO.
440- ///
441- /// Note that the resulting tree won't be available or inspectable.
442- #[ clap( long, short = 'm' ) ]
443- in_memory : bool ,
444- /// Decide how to resolve content conflicts in files. If unset, write conflict markers and fail.
445- #[ clap( long, short = 'f' ) ]
446- file_favor : Option < FileFavor > ,
447- /// Print additional information about conflicts for debugging.
448- #[ clap( long, short = 'd' ) ]
449- debug : bool ,
465+ #[ clap( flatten) ]
466+ opts : SharedOptions ,
450467
451468 /// A revspec to our committish.
452469 #[ clap( value_name = "OURS" , value_parser = crate :: shared:: AsBString ) ]
0 commit comments