From 14a29d6d6ff61ef253a2a7122de8ed25bde91ebf Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 28 Aug 2024 16:38:55 +0200 Subject: [PATCH] Bugfix: more comprehensive check whether custom patch must be reset We need to compare more than just the "To" ref. The NewPatchRequired function existed already for this purpose, it just wasn't used. --- pkg/gui/controllers/commits_files_controller.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 8091468a7..17c92224a 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -307,7 +307,8 @@ func (self *CommitFilesController) toggleForPatch(selectedNodes []*filetree.Comm }) } - if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.To != self.context().GetRef().RefName() { + from, to, reverse := self.currentFromToReverseForPatchBuilding() + if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.NewPatchRequired(from, to, reverse) { return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardPatch, Prompt: self.c.Tr.DiscardPatchConfirm, @@ -364,7 +365,8 @@ func (self *CommitFilesController) enterCommitFile(node *filetree.CommitFileNode return self.c.Context().Push(self.c.Contexts().CustomPatchBuilder, opts) } - if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.To != self.context().GetRef().RefName() { + from, to, reverse := self.currentFromToReverseForPatchBuilding() + if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.NewPatchRequired(from, to, reverse) { return self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardPatch, Prompt: self.c.Tr.DiscardPatchConfirm,