diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 737e4c077..86418453d 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -483,16 +483,17 @@ func (self *CommitLoader) getMergeBase(refName string) string { // We pass all configured main branches to the merge-base call; git will // return the base commit for the closest one. - output, err := self.cmd.New( + // We ignore errors from this call, since we can't distinguish whether the + // error is because one of the main branches has been deleted since the last + // call to determineMainBranches, or because the refName has no common + // history with any of the main branches. Since the former should happen + // very rarely, users must quit and restart lazygit to fix it; the latter is + // also not very common, but can totally happen and is not an error. + + output, _ := self.cmd.New( NewGitCmd("merge-base").Arg(refName).Arg(self.mainBranches...). ToArgv(), ).DontLog().RunWithOutput() - if err != nil { - // If there's an error, it must be because one of the main branches that - // used to exist when we called getExistingMainBranches() was deleted - // meanwhile. To fix this for next time, throw away our cache. - self.mainBranches = nil - } return ignoringWarnings(output) }