diff --git a/pkg/commands/git_commands/branch.go b/pkg/commands/git_commands/branch.go index 017b87ed4..8f5fb2d8c 100644 --- a/pkg/commands/git_commands/branch.go +++ b/pkg/commands/git_commands/branch.go @@ -285,11 +285,12 @@ func (self *BranchCommands) Merge(branchName string, variant MergeVariant) error return self.cmd.New(cmdArgs).Run() } -// Returns whether refName can be fast-forward merged into the current branch -func (self *BranchCommands) CanDoFastForwardMerge(refName string) bool { +// Returns whether the first ref is an ancestor of the second one, which also +// means that the second one can be fast-forward merged into the first one +func (self *BranchCommands) IsAncestor(ancestorRefName string, refName string) bool { cmdArgs := NewGitCmd("merge-base"). Arg("--is-ancestor"). - Arg("HEAD", refName). + Arg(ancestorRefName, refName). ToArgv() err := self.cmd.New(cmdArgs).DontLog().Run() return err == nil diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index 8f27efa08..106652ff3 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -525,7 +525,7 @@ func (self *MergeAndRebaseHelper) MergeRefIntoCheckedOutBranch(refName string) e } wantFastForward, wantNonFastForward := self.fastForwardMergeUserPreference() - canFastForward := self.c.Git().Branch.CanDoFastForwardMerge(refName) + canFastForward := self.c.Git().Branch.IsAncestor("HEAD", refName) var firstRegularMergeItem *types.MenuItem var secondRegularMergeItem *types.MenuItem