diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp index 53810909683..60e994ad485 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -30,14 +30,11 @@ #include "gitsettings.h" -#include - #include namespace Git { namespace Internal { -const QLatin1String GitSettings::pathKey("Path"); const QLatin1String GitSettings::pullRebaseKey("PullRebase"); const QLatin1String GitSettings::omitAnnotationDateKey("OmitAnnotationDate"); const QLatin1String GitSettings::ignoreSpaceChangesInDiffKey("SpaceIgnorantDiff"); @@ -59,7 +56,6 @@ GitSettings::GitSettings() #else declareKey(timeoutKey, 30); #endif - declareKey(pathKey, QString()); declareKey(pullRebaseKey, false); declareKey(omitAnnotationDateKey, false); declareKey(ignoreSpaceChangesInDiffKey, true); @@ -81,33 +77,21 @@ QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const if (errorMessage) errorMessage->clear(); - if (m_binaryPath.isEmpty()) { - const QString binary = binaryPath(); - QString currentPath = stringValue(pathKey); - QString systemPath = QString::fromLocal8Bit(qgetenv("PATH")); - if (!systemPath.isEmpty()) { - if (!currentPath.isEmpty()) - currentPath.append(Utils::SynchronousProcess::pathSeparator()); - currentPath.append(systemPath); - } - // Search in path? - m_binaryPath = Utils::SynchronousProcess::locateBinary(currentPath, binary); - if (m_binaryPath.isEmpty()) { - if (ok) - *ok = false; - if (errorMessage) - *errorMessage = QCoreApplication::translate("Git::Internal::GitSettings", - "The binary '%1' could not be located in the path '%2'") - .arg(binary, currentPath); - } + QString binPath = binaryPath(); + if (binPath.isEmpty()) { + if (ok) + *ok = false; + if (errorMessage) + *errorMessage = QCoreApplication::translate("Git::Internal::GitSettings", + "The binary '%1' could not be located in the path '%2'") + .arg(stringValue(binaryPathKey), stringValue(pathKey)); } - return m_binaryPath; + return binPath; } GitSettings &GitSettings::operator = (const GitSettings &s) { VcsBaseClientSettings::operator =(s); - m_binaryPath.clear(); return *this; } diff --git a/src/plugins/git/gitsettings.h b/src/plugins/git/gitsettings.h index b4340f289b5..5b9e988136c 100644 --- a/src/plugins/git/gitsettings.h +++ b/src/plugins/git/gitsettings.h @@ -44,7 +44,6 @@ class GitSettings : public VcsBase::VcsBaseClientSettings public: GitSettings(); - static const QLatin1String pathKey; static const QLatin1String pullRebaseKey; static const QLatin1String omitAnnotationDateKey; static const QLatin1String ignoreSpaceChangesInDiffKey; @@ -59,9 +58,6 @@ public: QString gitBinaryPath(bool *ok = 0, QString *errorMessage = 0) const; GitSettings &operator = (const GitSettings &s); - -private: - mutable QString m_binaryPath; }; } // namespace Internal diff --git a/src/plugins/vcsbase/vcsbaseclientsettings.cpp b/src/plugins/vcsbase/vcsbaseclientsettings.cpp index e71b242e2af..766a366d74f 100644 --- a/src/plugins/vcsbase/vcsbaseclientsettings.cpp +++ b/src/plugins/vcsbase/vcsbaseclientsettings.cpp @@ -31,6 +31,7 @@ #include "vcsbaseclientsettings.h" #include +#include #include @@ -175,7 +176,7 @@ public: QHash m_valueHash; QVariantHash m_defaultValueHash; QString m_settingsGroup; - QString m_binaryFullPath; + mutable QString m_binaryFullPath; }; } // namespace Internal @@ -194,6 +195,7 @@ const QLatin1String VcsBaseClientSettings::userEmailKey("UserEmail"); const QLatin1String VcsBaseClientSettings::logCountKey("LogCount"); const QLatin1String VcsBaseClientSettings::promptOnSubmitKey("PromptOnSubmit"); const QLatin1String VcsBaseClientSettings::timeoutKey("Timeout"); +const QLatin1String VcsBaseClientSettings::pathKey("Path"); VcsBaseClientSettings::VcsBaseClientSettings() : d(new Internal::VcsBaseClientSettingsPrivate) @@ -204,6 +206,7 @@ VcsBaseClientSettings::VcsBaseClientSettings() : declareKey(logCountKey, 100); declareKey(promptOnSubmitKey, true); declareKey(timeoutKey, 30); + declareKey(pathKey, QString()); } VcsBaseClientSettings::VcsBaseClientSettings(const VcsBaseClientSettings &other) : @@ -332,8 +335,7 @@ void VcsBaseClientSettings::setValue(const QString &key, const QVariant &v) { if (SettingValue::isUsableVariantType(valueType(key))) { d->m_valueHash.insert(key, SettingValue(v)); - if (key == binaryPathKey) - d->m_binaryFullPath = Utils::Environment::systemEnvironment().searchInPath(v.toString()); + d->m_binaryFullPath.clear(); } } @@ -346,6 +348,11 @@ QVariant::Type VcsBaseClientSettings::valueType(const QString &key) const QString VcsBaseClientSettings::binaryPath() const { + if (d->m_binaryFullPath.isEmpty()) { + d->m_binaryFullPath = Utils::Environment::systemEnvironment().searchInPath( + stringValue(binaryPathKey), stringValue(pathKey).split( + Utils::SynchronousProcess::pathSeparator())); + } return d->m_binaryFullPath; } diff --git a/src/plugins/vcsbase/vcsbaseclientsettings.h b/src/plugins/vcsbase/vcsbaseclientsettings.h index f840a085c21..20ed803c547 100644 --- a/src/plugins/vcsbase/vcsbaseclientsettings.h +++ b/src/plugins/vcsbase/vcsbaseclientsettings.h @@ -54,6 +54,7 @@ public: static const QLatin1String logCountKey; static const QLatin1String promptOnSubmitKey; static const QLatin1String timeoutKey; // Seconds + static const QLatin1String pathKey; VcsBaseClientSettings(); VcsBaseClientSettings(const VcsBaseClientSettings &other);