Gerrit: Improve curl detection

Until Git for Windows 2.12.0, curl was shipped twice - a MinGW version
in mingw{32,64}/bin, and MSYS2 version in usr/bin[1].

On 2.12.0, the MSYS2 version was removed, leaving only MinGW.

The plugin only searches for curl in usr/bin, so it is clearly broken
with 2.12.

There is no reason to add mingw*/bin to GitClient::gitBinDirectory()
(and return a list), because there are no other useful tools there. The
other tools that use gitBinDirectory are patch and ssh, which are both
in usr/bin.

[1] https://github.com/git-for-windows/git/issues/1069

Change-Id: I5eb5fa727fa384835792c59fd018fdfa31594927
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2017-02-27 17:22:46 +02:00
committed by Orgad Shaneh
parent 4e7e5da8eb
commit ffbdfb883a

View File

@@ -30,6 +30,7 @@
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <QDebug> #include <QDebug>
#include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QRegularExpression> #include <QRegularExpression>
#include <QSettings> #include <QSettings>
@@ -59,14 +60,30 @@ static inline QString detectApp(const char *defaultExe)
{ {
const QString defaultApp = HostOsInfo::withExecutableSuffix(QLatin1String(defaultExe)); const QString defaultApp = HostOsInfo::withExecutableSuffix(QLatin1String(defaultExe));
QString app = QStandardPaths::findExecutable(defaultApp); QString app = QStandardPaths::findExecutable(defaultApp);
if (!app.isEmpty()) if (!app.isEmpty() || !HostOsInfo::isWindowsHost())
return app; return app;
if (HostOsInfo::isWindowsHost()) { // Windows: Use app.exe from git if it cannot be found. // Windows: Use app.exe from git if it cannot be found.
FileName path = GerritPlugin::gitBinDirectory(); const FileName gitBinDir = GerritPlugin::gitBinDirectory();
if (!path.isEmpty()) if (gitBinDir.isEmpty())
app = path.appendPath(defaultApp).toString(); return QString();
} FileName path = gitBinDir;
return app; path.appendPath(defaultApp);
if (path.exists())
return path.toString();
// If app was not found, and git bin is Git/usr/bin (Git for Windows),
// search also in Git/mingw{32,64}/bin
if (!gitBinDir.endsWith("/usr/bin"))
return QString();
path = gitBinDir.parentDir().parentDir();
QDir dir(path.toString());
const QStringList entries = dir.entryList({"mingw*"});
if (entries.isEmpty())
return QString();
path.appendPath(entries.first()).appendPath("bin").appendPath(defaultApp);
if (path.exists())
return path.toString();
return QString();
} }
static inline QString detectSsh() static inline QString detectSsh()