From 5c2840450e986fb864011bd0ffe0a01e71dd8ec6 Mon Sep 17 00:00:00 2001 From: Jonatan Dahl Date: Fri, 13 Feb 2026 14:23:37 -0500 Subject: [PATCH] fix(sync): skip redundant "Returning to" message when already on branch During `stack sync`, the "Returning to ..." message and checkout always ran at the end, even when the user was already on that branch (e.g., single-branch stacks). Now checks the current branch first and only prints the message / performs checkout when actually needed. Co-Authored-By: Claude Opus 4.6 --- cmd/sync.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/sync.go b/cmd/sync.go index 934acc9..ec50fdf 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -840,10 +840,13 @@ func runSync(gitClient git.GitClient, githubClient github.GitHubClient) error { } } - // Return to original branch - fmt.Printf("Returning to %s...\n", ui.Branch(originalBranch)) - if err := gitClient.CheckoutBranch(originalBranch); err != nil { - fmt.Fprintf(os.Stderr, "Warning: failed to return to original branch: %v\n", err) + // Return to original branch if needed + currentBranch, err := gitClient.GetCurrentBranch() + if err == nil && currentBranch != originalBranch { + fmt.Printf("Returning to %s...\n", ui.Branch(originalBranch)) + if err := gitClient.CheckoutBranch(originalBranch); err != nil { + fmt.Fprintf(os.Stderr, "Warning: failed to return to original branch: %v\n", err) + } } // Display the updated stack status (reuse prCache to avoid redundant API call)