Fix moving a custom patch from the very first commit of the history to a later commit (#4631)

- **PR Description**

Moving a custom patch from the very first commit of the history to a
later commit would crash with an index-out-of-range error.

I double-checked that all other callers of
PrepareInteractiveRebaseCommand already call getBaseHashOrRoot, so this
was the only one that was broken.

I decided not to add a test for this as the scenario is not a very
common one.

Fixes #4624.
This commit is contained in:
Stefan Haller 2025-06-19 18:46:28 +02:00 committed by GitHub
commit 159efdef9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -162,7 +162,7 @@ func (self *PatchCommands) MovePatchToSelectedCommit(commits []*models.Commit, s
self.os.LogCommand(logTodoChanges(changes), false)
err := self.rebase.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
baseHashOrRoot: commits[baseIndex].Hash(),
baseHashOrRoot: getBaseHashOrRoot(commits, baseIndex),
overrideEditor: true,
instruction: daemon.NewChangeTodoActionsInstruction(changes),
}).Run()