Skip to content

Commit 159efde

Browse files
authored
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.
2 parents ec0f4d2 + 206283d commit 159efde

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/commands/git_commands/patch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (self *PatchCommands) MovePatchToSelectedCommit(commits []*models.Commit, s
162162
self.os.LogCommand(logTodoChanges(changes), false)
163163

164164
err := self.rebase.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{
165-
baseHashOrRoot: commits[baseIndex].Hash(),
165+
baseHashOrRoot: getBaseHashOrRoot(commits, baseIndex),
166166
overrideEditor: true,
167167
instruction: daemon.NewChangeTodoActionsInstruction(changes),
168168
}).Run()

0 commit comments

Comments
 (0)