From 351f6b8f1118de1c936b5e033eb8b6f80f220f25 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 23 Feb 2017 15:01:10 +0200 Subject: [PATCH] Gerrit: Improve default SSH lookup * Append exe suffix * Detect also if not found (for example, when upgrading from msysGit to Git for Windows). Change-Id: I9c47f0f4e54e957e21e224f100c2959dc1884ec2 Reviewed-by: Tobias Hunger --- src/plugins/git/gerrit/gerritparameters.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/git/gerrit/gerritparameters.cpp b/src/plugins/git/gerrit/gerritparameters.cpp index a1e5ef8b57d..d080c6b2871 100644 --- a/src/plugins/git/gerrit/gerritparameters.cpp +++ b/src/plugins/git/gerrit/gerritparameters.cpp @@ -58,13 +58,14 @@ static inline QString detectSsh() const QByteArray gitSsh = qgetenv("GIT_SSH"); if (!gitSsh.isEmpty()) return QString::fromLocal8Bit(gitSsh); - QString ssh = QStandardPaths::findExecutable(defaultSshC); + const QString defaultSsh = Utils::HostOsInfo::withExecutableSuffix(defaultSshC); + QString ssh = QStandardPaths::findExecutable(defaultSsh); if (!ssh.isEmpty()) return ssh; if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found. Utils::FileName path = GerritPlugin::gitBinDirectory(); if (!path.isEmpty()) - ssh = path.appendPath(defaultSshC).toString(); + ssh = path.appendPath(defaultSsh).toString(); } return ssh; } @@ -186,7 +187,7 @@ void GerritParameters::fromSettings(const QSettings *s) savedQueries = s->value(rootKey + savedQueriesKeyC, QString()).toString() .split(','); https = s->value(rootKey + httpsKeyC, QVariant(true)).toBool(); - if (ssh.isEmpty()) + if (ssh.isEmpty() || !QFile::exists(ssh)) ssh = detectSsh(); }