Make the git plugin look for the binary in the path specified in the settings. Previously, the environment was passed to the process, but that did not affect the location of the binary.

This commit is contained in:
Friedemann Kleint
2009-02-19 17:47:44 +01:00
committed by unknown
parent 890220d5b4
commit 90b094e832
9 changed files with 173 additions and 13 deletions

View File

@@ -32,9 +32,13 @@
***************************************************************************/
#include "gitsettings.h"
#include "gitconstants.h"
#include <utils/synchronousprocess.h>
#include <QtCore/QSettings>
#include <QtCore/QTextStream>
#include <QtCore/QCoreApplication>
static const char *groupC = "Git";
static const char *sysEnvKeyC = "SysEnv";
@@ -79,5 +83,30 @@ bool GitSettings::equals(const GitSettings &s) const
return adoptPath == s.adoptPath && path == s.path && logCount == s.logCount && timeout == s.timeout;
}
QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
{
// Locate binary in path if one is specified, otherwise default
// to pathless binary
if (ok)
*ok = true;
if (errorMessage)
errorMessage->clear();
const QString binary = QLatin1String(Constants::GIT_BINARY);
// Easy, git is assumed to be elsewhere accessible
if (!adoptPath)
return binary;
// Search in path?
const QString pathBinary = Core::Utils::SynchronousProcess::locateBinary(path, binary);
if (pathBinary.isEmpty()) {
if (ok)
*ok = false;
if (errorMessage)
*errorMessage = QCoreApplication::translate("GitSettings",
"The binary '%1' could not be located in the path '%2'").arg(binary, path);
return binary;
}
return pathBinary;
}
}
}