mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
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.
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user