Skip to content

Commit 4831951

Browse files
committed
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.
1 parent ecc70f4 commit 4831951

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/gui/controllers/helpers/merge_and_rebase_helper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ func (self *MergeAndRebaseHelper) PromptToContinueRebase() error {
270270
}
271271

272272
func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error {
273-
checkedOutBranch := self.refsHelper.GetCheckedOutRef()
274-
checkedOutBranchName := self.refsHelper.GetCheckedOutRef().Name
273+
checkedOutBranch := self.c.Model().Branches[0]
274+
checkedOutBranchName := checkedOutBranch.Name
275275
var disabledReason, baseBranchDisabledReason *types.DisabledReason
276276
if checkedOutBranchName == ref {
277277
disabledReason = &types.DisabledReason{Text: self.c.Tr.CantRebaseOntoSelf}
@@ -383,7 +383,7 @@ func (self *MergeAndRebaseHelper) MergeRefIntoCheckedOutBranch(refName string) e
383383
if self.c.Git().Branch.IsHeadDetached() {
384384
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")
385385
}
386-
checkedOutBranchName := self.refsHelper.GetCheckedOutRef().Name
386+
checkedOutBranchName := self.c.Model().Branches[0].Name
387387
if checkedOutBranchName == refName {
388388
return errors.New(self.c.Tr.CantMergeBranchIntoItself)
389389
}

0 commit comments

Comments
 (0)