private @Nullable String getPathToGit(@Nullable Project project, @Nullable File gitDirectory, boolean detectIfNeeded) {
    String path = null;
    if (project != null && (project.isDefault() || isTrusted(project))) {
      path = GitVcsSettings.getInstance(project).getPathToGit();
    }
    if (path == null) path = GitVcsApplicationSettings.getInstance().getSavedPathToGit();
    if (path == null) {
      WSLDistribution distribution = gitDirectory != null
                                     ? WslPath.getDistributionByWindowsUncPath(gitDirectory.getPath())
                                     : getProjectWslDistribution(project);
      path = myExecutableDetector.getExecutable(distribution, detectIfNeeded);
    }
    return path;
  }
private @Nullable String getPathToGit(@Nullable Project project, @Nullable File gitDirectory, boolean detectIfNeeded)