From 483195110a7d4b1251ed892cd3f7c0c551d1ebeb Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 2 Apr 2025 14:59:32 +0200 Subject: [PATCH] Use Model().Branches[0] instead of refsHelper.GetCheckedOutRef() in MergeAndRebaseHelper It's the same, really, except that GetCheckedOutRef() does a check if any branches exist and returns nil if not. Since we are accessing the returned branch unconditionally without checking for nil, it seems this check is not needed here. (The functions we are touching here are called from handlers that are guarded with itemSelected or singleItemSelected, so we know that at least one branch exists.) The goal is to get rid of the dependency to refsHelper. --- pkg/gui/controllers/helpers/merge_and_rebase_helper.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index dc5988757..d5efc72ca 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -270,8 +270,8 @@ func (self *MergeAndRebaseHelper) PromptToContinueRebase() error { } func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error { - checkedOutBranch := self.refsHelper.GetCheckedOutRef() - checkedOutBranchName := self.refsHelper.GetCheckedOutRef().Name + checkedOutBranch := self.c.Model().Branches[0] + checkedOutBranchName := checkedOutBranch.Name var disabledReason, baseBranchDisabledReason *types.DisabledReason if checkedOutBranchName == ref { disabledReason = &types.DisabledReason{Text: self.c.Tr.CantRebaseOntoSelf} @@ -383,7 +383,7 @@ func (self *MergeAndRebaseHelper) MergeRefIntoCheckedOutBranch(refName string) e if self.c.Git().Branch.IsHeadDetached() { return errors.New("Cannot merge branch in detached head state. You might have checked out a commit directly or a remote branch, in which case you should checkout the local branch you want to be on") } - checkedOutBranchName := self.refsHelper.GetCheckedOutRef().Name + checkedOutBranchName := self.c.Model().Branches[0].Name if checkedOutBranchName == refName { return errors.New(self.c.Tr.CantMergeBranchIntoItself) }