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 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-08 14:54:41 +01:00
co-authored by Claude Opus 5.5
parent 3fb06d9095
commit 6dc34a62d2
2 changed files with 13 additions and 18 deletions
+13 -1
View File
@@ -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
@@ -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"),
)
},
})