From 96e06a9fbbaa8eb5ee4ac9d53bee09126f9dc269 Mon Sep 17 00:00:00 2001 From: Robert Loehning <robert.loehning@nokia.com> Date: Fri, 17 Sep 2010 12:49:33 +0200 Subject: [PATCH] git: Fixed launching of gitk In cases where binary 'wish' is not in PATH variable this could not be started. --- src/plugins/git/gitclient.cpp | 26 ++++++++++++++++++++++++-- src/plugins/git/gitclient.h | 4 ++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 0406b6eaa1a..1b49ccdce95 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -1330,6 +1330,21 @@ void GitClient::launchGitK(const QString &workingDirectory) return; } const QString gitBinDirectory = QFileInfo(fullGitBinary).absolutePath(); + QDir foundBinDir = gitBinDirectory; + const bool foundBinDirIsCmdDir = foundBinDir.dirName() == "cmd"; + if (!tryLauchingGitK(env, workingDirectory, gitBinDirectory, foundBinDirIsCmdDir)) { + if (foundBinDirIsCmdDir) { + foundBinDir.cdUp(); + tryLauchingGitK(env, workingDirectory, foundBinDir.path() + "/bin", false); + } + } +} + +bool GitClient::tryLauchingGitK(const QProcessEnvironment &env, + const QString &workingDirectory, + const QString &gitBinDirectory, + bool silent) +{ #ifdef Q_OS_WIN // Launch 'wish' shell from git binary directory with the gitk located there const QString binary = gitBinDirectory + QLatin1String("/wish"); @@ -1339,6 +1354,7 @@ void GitClient::launchGitK(const QString &workingDirectory) const QString binary = gitBinDirectory + QLatin1String("/gitk"); QStringList arguments; #endif + VCSBase::VCSBaseOutputWindow *outwin = VCSBase::VCSBaseOutputWindow::instance(); if (!m_settings.gitkOptions.isEmpty()) arguments.append(m_settings.gitkOptions.split(QLatin1Char(' '))); outwin->appendCommand(workingDirectory, binary, arguments); @@ -1359,8 +1375,14 @@ void GitClient::launchGitK(const QString &workingDirectory) } else { success = QProcess::startDetached(binary, arguments, workingDirectory); } - if (!success) - outwin->appendError(tr("Unable to launch %1.").arg(binary)); + if (!success) { + const QString error = tr("Unable to launch %1.").arg(binary); + if (silent) + outwin->appendSilently(error); + else + outwin->appendError(error); + } + return success; } bool GitClient::getCommitData(const QString &workingDirectory, diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index f5d1c749954..75228eaf3b0 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -271,6 +271,10 @@ private: void connectRepositoryChanged(const QString & repository, GitCommand *cmd); bool synchronousPull(const QString &workingDirectory, bool rebase); void syncAbortPullRebase(const QString &workingDir); + bool tryLauchingGitK(const QProcessEnvironment &env, + const QString &workingDirectory, + const QString &gitBinDirectory, + bool silent); const QString m_msgWait; GitPlugin *m_plugin; -- GitLab