@@ -1200,9 +1200,14 @@ type remoteReconcileResult struct {
12001200 stack * stack.Stack
12011201
12021202 // skipStackObjectSync tells runSync to skip the later syncStack step so we
1203- // never push the local stack over a divergent remote. Set for cancel,
1204- // disassociate, and unresolved (non-interactive) divergences.
1203+ // never push the local stack over a divergent remote. Set when disassociating.
12051204 skipStackObjectSync bool
1205+
1206+ // abort tells runSync to stop the whole sync immediately (before any
1207+ // fast-forward, rebase, or push) and exit successfully without changes. Set
1208+ // when the user cancels an interactive divergence prompt, or when a
1209+ // divergence is detected in a non-interactive terminal.
1210+ abort bool
12061211}
12071212
12081213// remoteStackClass classifies the relationship between the local stack's active
@@ -1407,11 +1412,9 @@ func pullRemoteAdditions(cfg *config.Config, sf *stack.StackFile, s *stack.Stack
14071412
14081413// resolveStackDivergence handles a stack whose local composition has diverged
14091414// from the remote (neither is a prefix of the other). In an interactive
1410- // terminal it prompts the user; otherwise it is a safe no-op that reports the
1411- // divergence and leaves everything untouched .
1415+ // terminal it prompts the user to resolve it; otherwise (or when the user
1416+ // cancels) it aborts the sync so nothing is pushed or updated .
14121417func resolveStackDivergence (cfg * config.Config , client github.ClientOps , sf * stack.StackFile , s * stack.Stack , gitDir , remote string , prs []* github.PullRequest , remoteActive []string ) (remoteReconcileResult , error ) {
1413- res := remoteReconcileResult {skipStackObjectSync : true }
1414-
14151418 cfg .Printf ("" )
14161419 cfg .Warningf ("Your local stack has diverged from the stack on GitHub" )
14171420 cfg .Printf (" Local: %s" , s .DisplayChain ())
@@ -1420,14 +1423,14 @@ func resolveStackDivergence(cfg *config.Config, client github.ClientOps, sf *sta
14201423 if ! cfg .IsInteractive () {
14211424 cfg .Printf (" Re-run in an interactive terminal to resolve, or import the remote stack with `%s`." ,
14221425 cfg .ColorCyan ("gh stack checkout <pr>" ))
1423- return res , nil
1426+ return remoteReconcileResult { abort : true } , nil
14241427 }
14251428
14261429 options := []string {
14271430 "Use the remote stack as the source of truth (update local to match)" ,
14281431 "Use your local stack as the source of truth (update remote to match)" ,
1429- "Disassociate — stop tracking this stack on GitHub" ,
1430- "Cancel — make no changes for now " ,
1432+ "Disassociate — unlink local stack with remote on GitHub" ,
1433+ "Cancel — abort the sync and do not make any changes " ,
14311434 }
14321435 p := prompter .New (cfg .In , cfg .Out , cfg .Err )
14331436 selectFn := func (prompt , def string , opts []string ) (int , error ) {
@@ -1436,17 +1439,17 @@ func resolveStackDivergence(cfg *config.Config, client github.ClientOps, sf *sta
14361439 }
14371440 return p .Select (prompt , def , opts )
14381441 }
1439- selected , err := selectFn ("How would you like to resolve this ?" , "" , options )
1442+ selected , err := selectFn ("How would you like to resolve?" , "" , options )
14401443 if err != nil {
14411444 if isInterruptError (err ) {
14421445 if cfg .SelectFn == nil {
14431446 clearSelectPrompt (cfg , len (options ))
14441447 }
14451448 printInterrupt (cfg )
1446- return res , errInterrupt
1449+ return remoteReconcileResult { abort : true } , errInterrupt
14471450 }
14481451 cfg .Errorf ("selection failed: %v" , err )
1449- return res , ErrSilent
1452+ return remoteReconcileResult {} , ErrSilent
14501453 }
14511454
14521455 switch selected {
@@ -1457,8 +1460,8 @@ func resolveStackDivergence(cfg *config.Config, client github.ClientOps, sf *sta
14571460 case 2 :
14581461 return resolveDivergenceDisassociate (cfg , sf , s , gitDir )
14591462 default :
1460- cfg . Infof ( "No changes made — your local and remote stacks still differ" )
1461- return res , nil
1463+ // Cancel: abort the whole sync without touching branches or PRs.
1464+ return remoteReconcileResult { abort : true } , nil
14621465 }
14631466}
14641467
0 commit comments