From 6dc34a62d225ab11659017144b473e519c90f2a7 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 7 Nov 2026 09:43:25 +0100 Subject: [PATCH] Resume a pull whose rebase a lock error stopped partway through If pull.rebase is set and a lock stops the rebase partway through, the git command runner ran "git pull" again. This failed with "You are not currently on a branch", and the rebase was left stopped halfway. Handle this the same way as for an interactive rebase. Continue the rebase if git rescheduled the todo that failed, give up if it didn't, and run the pull again if the lock stopped it before the rebase started. Co-Authored-By: Claude Opus 5.5 --- pkg/commands/git_commands/sync.go | 14 +++++++++++++- ...ck_error_partway_through_pull_with_rebase.go | 17 ----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/pkg/commands/git_commands/sync.go b/pkg/commands/git_commands/sync.go index 603e5b8eb..59f052db8 100644 --- a/pkg/commands/git_commands/sync.go +++ b/pkg/commands/git_commands/sync.go @@ -111,7 +111,19 @@ func (self *SyncCommands) Pull(task gocui.Task, opts PullOptions) error { // setting GIT_SEQUENCE_EDITOR to ':' as a way of skipping it, in case the user // has 'pull.rebase = interactive' configured. - return self.cmd.New(cmdArgs).AddEnvVars("GIT_SEQUENCE_EDITOR=:").PromptOnCredentialRequest(task).Run() + cmdObj := self.cmd.New(cmdArgs).AddEnvVars("GIT_SEQUENCE_EDITOR=:").PromptOnCredentialRequest(task) + + // With pull.rebase set, a lock error can stop the pull partway through its + // rebase. + gitDir := lo.Ternary(opts.WorktreeGitDir != "", opts.WorktreeGitDir, self.repoPaths.WorktreeGitDirPath()) + return resumeRebaseAfterLockError(cmdObj, gitDir, self.config.GetCoreCommentChar(), func() *oscommands.CmdObj { + continueArgs := NewGitCmd("rebase"). + Arg("--continue"). + GitDirIf(opts.WorktreeGitDir != "", opts.WorktreeGitDir). + WorktreePathIf(opts.WorktreePath != "", opts.WorktreePath). + ToArgv() + return skipEditor(self.cmd.New(continueArgs)) + }).Run() } // Fetches the given branches of the given remote, updating their diff --git a/pkg/integration/tests/sync/lock_error_partway_through_pull_with_rebase.go b/pkg/integration/tests/sync/lock_error_partway_through_pull_with_rebase.go index 273f3e9fd..3135dd8b2 100644 --- a/pkg/integration/tests/sync/lock_error_partway_through_pull_with_rebase.go +++ b/pkg/integration/tests/sync/lock_error_partway_through_pull_with_rebase.go @@ -49,7 +49,6 @@ var LockErrorPartwayThroughPullWithRebase = NewIntegrationTest(NewIntegrationTes IsFocused(). Press(keys.Universal.Pull) - /* EXPECTED: t.Views().Status().Content(Equals("↑2 repo → master")) t.Views().Commits(). @@ -60,21 +59,5 @@ var LockErrorPartwayThroughPullWithRebase = NewIntegrationTest(NewIntegrationTes Contains("two"), Contains("one"), ) - ACTUAL: */ - t.ExpectPopup().Alert(). - Title(Equals("Error")). - Content(Contains("You are not currently on a branch.")). - Confirm() - - t.Views().Commits(). - Lines( - Contains("─── Pending rebase todos"), - Contains("pick").Contains("five"), - Contains("─── Commits"), - Contains("four"), - Contains("three"), - Contains("two"), - Contains("one"), - ) }, })