File tree Expand file tree Collapse file tree 1 file changed +16
-20
lines changed
git-branchless-navigation/src Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Original file line number Diff line number Diff line change @@ -474,7 +474,7 @@ pub fn switch(
474
474
switch_options : & SwitchOptions ,
475
475
) -> EyreExitOr < ( ) > {
476
476
let SwitchOptions {
477
- interactive : _ ,
477
+ interactive,
478
478
branch_name,
479
479
force,
480
480
merge,
@@ -510,27 +510,23 @@ pub fn switch(
510
510
false ,
511
511
) ?;
512
512
513
- let initial_query = match switch_options {
514
- SwitchOptions {
515
- interactive : true ,
516
- branch_name : _,
517
- force : _,
518
- merge : _,
519
- detach : _,
520
- target,
521
- } => Some ( target. clone ( ) . unwrap_or_default ( ) ) ,
522
- SwitchOptions {
523
- interactive : false ,
524
- branch_name : _,
525
- force : _,
526
- merge : _,
527
- detach : _,
528
- target : _,
529
- } => None ,
513
+ enum Target {
514
+ /// The (possibly empty) target expression should be used as the initial
515
+ /// query in the commit selector.
516
+ Interactive ( String ) ,
517
+
518
+ /// No target expression was specified.
519
+ None ,
520
+ }
521
+ let initial_query = match ( interactive, target) {
522
+ ( true , Some ( target) ) => Target :: Interactive ( target. clone ( ) ) ,
523
+ ( true , None ) => Target :: Interactive ( String :: new ( ) ) ,
524
+ ( false , Some ( _) ) => Target :: None ,
525
+ ( false , None ) => Target :: None ,
530
526
} ;
531
527
let target: Option < CheckoutTarget > = match initial_query {
532
- None => target . clone ( ) . map ( CheckoutTarget :: Unknown ) ,
533
- Some ( initial_query) => {
528
+ Target :: None => None ,
529
+ Target :: Interactive ( initial_query) => {
534
530
match prompt_select_commit (
535
531
None ,
536
532
& initial_query,
You can’t perform that action at this time.
0 commit comments