From 206283d1f70bc5aab5aba52a56df63112ed42b0c Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 9 Jun 2025 16:53:24 +0200 Subject: [PATCH] Fix moving a custom patch from the very first commit of the history to a later commit This 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. --- pkg/commands/git_commands/patch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/commands/git_commands/patch.go b/pkg/commands/git_commands/patch.go index 0b1c3db01..c43dc0561 100644 --- a/pkg/commands/git_commands/patch.go +++ b/pkg/commands/git_commands/patch.go @@ -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()