@@ -441,6 +441,68 @@ fn cli_apply_submit_executes_and_exits_zero() {
441441 ) ;
442442}
443443
444+ #[ test]
445+ fn cli_apply_submit_keep_going_leaves_a_conflicting_branch_alone ( ) {
446+ let fx = setup_with_remotes ( ) ;
447+ run_git ( & fx. path , & [ "checkout" , "-q" , & fx. main_branch ] ) ;
448+ commit_file ( & fx. path , "conflict.txt" , "v0\n " , "Add conflict.txt v0" ) ;
449+ for remote in [ "origin" , "upstream" ] {
450+ run_git (
451+ & fx. path ,
452+ & [ "push" , "-q" , remote, & format ! ( "HEAD:{}" , fx. main_branch) ] ,
453+ ) ;
454+ }
455+ stack_branch ( & fx, "feat" , & fx. main_branch , "conflict.txt" , "v-feat\n " ) ;
456+ run_git ( & fx. path , & [ "push" , "-q" , "origin" , "feat" ] ) ;
457+ run_git (
458+ & fx. path ,
459+ & [ "branch" , "--set-upstream-to=origin/feat" , "feat" ] ,
460+ ) ;
461+ stack_branch ( & fx, "other" , & fx. main_branch , "conflict.txt" , "v-other\n " ) ;
462+ stack_branch ( & fx, "side" , & fx. main_branch , "side.txt" , "side" ) ;
463+ let feat_tip = run_git ( & fx. path , & [ "rev-parse" , "feat" ] ) ;
464+ let other_tip = run_git ( & fx. path , & [ "rev-parse" , "other" ] ) ;
465+
466+ let out = run_git_stackui ( & [
467+ "--path" ,
468+ & fx. path ,
469+ "--apply" ,
470+ "--keep-going" ,
471+ "--submit" ,
472+ "feat" ,
473+ ] ) ;
474+
475+ assert ! (
476+ !out. status. success( ) ,
477+ "expected non-zero exit for the conflict\n stdout: {}\n stderr: {}" ,
478+ lossy( & out. stdout) ,
479+ lossy( & out. stderr)
480+ ) ;
481+ let rebase_dir = run_git ( & fx. path , & [ "rev-parse" , "--git-path" , "rebase-merge" ] ) ;
482+ assert ! (
483+ !std:: path:: Path :: new( & fx. path) . join( & rebase_dir) . exists( ) ,
484+ "no rebase may be left in progress\n stdout: {}" ,
485+ lossy( & out. stdout)
486+ ) ;
487+ assert_eq ! (
488+ run_git( & fx. path, & [ "rev-parse" , "--abbrev-ref" , "HEAD" ] ) ,
489+ "side"
490+ ) ;
491+ assert_eq ! ( run_git( & fx. path, & [ "rev-parse" , "other" ] ) , other_tip) ;
492+ assert_eq ! (
493+ run_git(
494+ & fx. path,
495+ & [ "rev-parse" , & format!( "upstream/{}" , fx. main_branch) ]
496+ ) ,
497+ feat_tip
498+ ) ;
499+ assert_eq ! (
500+ run_git( & fx. path, & [ "merge-base" , "side" , & fx. main_branch] ) ,
501+ feat_tip,
502+ "side doesn't conflict, so it must still be rebased"
503+ ) ;
504+ }
505+
444506#[ test]
445507fn cli_apply_submit_json_outputs_op_results ( ) {
446508 let fx = setup_with_remotes ( ) ;
0 commit comments