diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp index 0b0e9e2e9ca..25a8f77988e 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -116,6 +116,9 @@ GitSettings::GitSettings() refLogShowDate.setSettingsKey("RefLogShowDate"); timeout.setDefaultValue(Utils::HostOsInfo::isWindowsHost() ? 60 : 30); + + connect(&binaryPath, &StringAspect::valueChanged, this, [this] { tryResolve = true; }); + connect(&path, &StringAspect::valueChanged, this, [this] { tryResolve = true; }); } FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const @@ -126,18 +129,21 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const if (errorMessage) errorMessage->clear(); - FilePath binPath = binaryPath.filePath(); - if (!binPath.isAbsolutePath()) - binPath = binPath.searchInPath({path.filePath()}, FilePath::PrependToPath); + if (tryResolve) { + resolvedBinPath = binaryPath.filePath(); + if (!resolvedBinPath.isAbsolutePath()) + resolvedBinPath = resolvedBinPath.searchInPath({path.filePath()}, FilePath::PrependToPath); + tryResolve = false; + } - if (binPath.isEmpty()) { + if (resolvedBinPath.isEmpty()) { if (ok) *ok = false; if (errorMessage) *errorMessage = Tr::tr("The binary \"%1\" could not be located in the path \"%2\"") .arg(binaryPath.value(), path.value()); } - return binPath; + return resolvedBinPath; } // GitSettingsPage diff --git a/src/plugins/git/gitsettings.h b/src/plugins/git/gitsettings.h index d4d5c60fb69..c03deadeb9b 100644 --- a/src/plugins/git/gitsettings.h +++ b/src/plugins/git/gitsettings.h @@ -40,6 +40,9 @@ public: Utils::BoolAspect refLogShowDate; Utils::BoolAspect instantBlame; + mutable Utils::FilePath resolvedBinPath; + mutable bool tryResolve = true; + Utils::FilePath gitExecutable(bool *ok = nullptr, QString *errorMessage = nullptr) const; };