forked from qt-creator/qt-creator
Git: search for gitk in path if all else fails
Change-Id: I4799791b2baffa61092c01699a4128f01151b53c Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -2880,12 +2880,31 @@ void GitClient::launchGitK(const QString &workingDirectory, const QString &fileN
|
|||||||
QDir foundBinDir(binaryInfo.dir());
|
QDir foundBinDir(binaryInfo.dir());
|
||||||
const bool foundBinDirIsCmdDir = foundBinDir.dirName() == QLatin1String("cmd");
|
const bool foundBinDirIsCmdDir = foundBinDir.dirName() == QLatin1String("cmd");
|
||||||
QProcessEnvironment env = processEnvironment();
|
QProcessEnvironment env = processEnvironment();
|
||||||
if (tryLauchingGitK(env, workingDirectory, fileName, foundBinDir.path(), foundBinDirIsCmdDir))
|
if (tryLauchingGitK(env, workingDirectory, fileName, foundBinDir.path()))
|
||||||
return;
|
return;
|
||||||
if (!foundBinDirIsCmdDir)
|
|
||||||
|
QString gitkPath = foundBinDir.path() + QLatin1String("/gitk");
|
||||||
|
VcsBase::VcsBaseOutputWindow::instance()->appendSilently(msgCannotLaunch(gitkPath));
|
||||||
|
|
||||||
|
if (foundBinDirIsCmdDir) {
|
||||||
|
foundBinDir.cdUp();
|
||||||
|
if (tryLauchingGitK(env, workingDirectory, fileName,
|
||||||
|
foundBinDir.path() + QLatin1String("/bin"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gitkPath = foundBinDir.path() + QLatin1String("/gitk");
|
||||||
|
VcsBase::VcsBaseOutputWindow::instance()->appendSilently(msgCannotLaunch(gitkPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::Environment sysEnv = Utils::Environment::systemEnvironment();
|
||||||
|
const QString exec = sysEnv.searchInPath(QLatin1String("gitk"));
|
||||||
|
|
||||||
|
if (!exec.isEmpty() && tryLauchingGitK(env, workingDirectory, fileName,
|
||||||
|
QFileInfo(exec).absolutePath())) {
|
||||||
return;
|
return;
|
||||||
foundBinDir.cdUp();
|
}
|
||||||
tryLauchingGitK(env, workingDirectory, fileName, foundBinDir.path() + QLatin1String("/bin"), false);
|
|
||||||
|
VcsBase::VcsBaseOutputWindow::instance()->appendError(msgCannotLaunch(QLatin1String("gitk")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitClient::launchRepositoryBrowser(const QString &workingDirectory)
|
void GitClient::launchRepositoryBrowser(const QString &workingDirectory)
|
||||||
@@ -2898,8 +2917,7 @@ void GitClient::launchRepositoryBrowser(const QString &workingDirectory)
|
|||||||
bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
|
bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
|
||||||
const QString &workingDirectory,
|
const QString &workingDirectory,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const QString &gitBinDirectory,
|
const QString &gitBinDirectory)
|
||||||
bool silent)
|
|
||||||
{
|
{
|
||||||
QString binary = gitBinDirectory + QLatin1String("/gitk");
|
QString binary = gitBinDirectory + QLatin1String("/gitk");
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
@@ -2934,12 +2952,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
|
|||||||
} else {
|
} else {
|
||||||
success = QProcess::startDetached(binary, arguments, workingDirectory);
|
success = QProcess::startDetached(binary, arguments, workingDirectory);
|
||||||
}
|
}
|
||||||
if (!success) {
|
|
||||||
if (silent)
|
|
||||||
outwin->appendSilently(msgCannotLaunch(binary));
|
|
||||||
else
|
|
||||||
outwin->appendError(msgCannotLaunch(binary));
|
|
||||||
}
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -410,8 +410,7 @@ private:
|
|||||||
bool tryLauchingGitK(const QProcessEnvironment &env,
|
bool tryLauchingGitK(const QProcessEnvironment &env,
|
||||||
const QString &workingDirectory,
|
const QString &workingDirectory,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const QString &gitBinDirectory,
|
const QString &gitBinDirectory);
|
||||||
bool silent);
|
|
||||||
bool cleanList(const QString &workingDirectory, const QString &flag, QStringList *files, QString *errorMessage);
|
bool cleanList(const QString &workingDirectory, const QString &flag, QStringList *files, QString *errorMessage);
|
||||||
|
|
||||||
mutable QString m_gitVersionForBinary;
|
mutable QString m_gitVersionForBinary;
|
||||||
|
|||||||
Reference in New Issue
Block a user