summaryrefslogtreecommitdiff
path: root/src/plugins/git
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2014-07-16 00:46:07 +0300
committerOrgad Shaneh <orgads@gmail.com>2014-07-16 12:43:32 +0200
commit54db877297259703df1bbe6cbe06e8bbc9ad77c8 (patch)
tree7bd869c8fbb17215ebe7d705c4985b91dfc9611e /src/plugins/git
parent36d2f47dcc6cd91a5303ef213e88c8fcab31e96d (diff)
downloadqt-creator-54db877297259703df1bbe6cbe06e8bbc9ad77c8.tar.gz
Git: Factor out resolving of bin directory on Windows
Change-Id: Ifbafa0f5cb8329faedfd1da3674b87e46001acc3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins/git')
-rw-r--r--src/plugins/git/gerrit/gerritparameters.cpp11
-rw-r--r--src/plugins/git/gerrit/gerritplugin.cpp5
-rw-r--r--src/plugins/git/gerrit/gerritplugin.h3
-rw-r--r--src/plugins/git/gitclient.cpp18
-rw-r--r--src/plugins/git/gitclient.h3
5 files changed, 32 insertions, 8 deletions
diff --git a/src/plugins/git/gerrit/gerritparameters.cpp b/src/plugins/git/gerrit/gerritparameters.cpp
index e5f8922511..d4b2eaee4f 100644
--- a/src/plugins/git/gerrit/gerritparameters.cpp
+++ b/src/plugins/git/gerrit/gerritparameters.cpp
@@ -73,14 +73,9 @@ static inline QString detectSsh()
if (!ssh.isEmpty())
return ssh;
if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found.
- const QString git = GerritPlugin::gitBinary();
- if (!git.isEmpty()) {
- // Is 'git\cmd' in the path (folder containing .bats)?
- QString path = QFileInfo(git).absolutePath();
- if (path.endsWith(QLatin1String("cmd"), Qt::CaseInsensitive))
- path.replace(path.size() - 3, 3, QLatin1String("bin"));
- ssh = path + QLatin1Char('/') + QLatin1String(defaultSshC);
- }
+ Utils::FileName path = GerritPlugin::gitBinDirectory();
+ if (!path.isEmpty())
+ ssh = path.appendPath(QLatin1String(defaultSshC)).toString();
}
return ssh;
}
diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp
index e89c2242da..16b1ff0cf6 100644
--- a/src/plugins/git/gerrit/gerritplugin.cpp
+++ b/src/plugins/git/gerrit/gerritplugin.cpp
@@ -399,6 +399,11 @@ QString GerritPlugin::gitBinary()
return git;
}
+Utils::FileName GerritPlugin::gitBinDirectory()
+{
+ return gitClient()->gitBinDirectory();
+}
+
// Find the branch of a repository.
QString GerritPlugin::branch(const QString &repository)
{
diff --git a/src/plugins/git/gerrit/gerritplugin.h b/src/plugins/git/gerrit/gerritplugin.h
index cc5723c2f7..23ee4fe087 100644
--- a/src/plugins/git/gerrit/gerritplugin.h
+++ b/src/plugins/git/gerrit/gerritplugin.h
@@ -30,6 +30,8 @@
#ifndef GERRIT_INTERNAL_GERRITPLUGIN_H
#define GERRIT_INTERNAL_GERRITPLUGIN_H
+#include <utils/fileutils.h>
+
#include <QObject>
#include <QPointer>
#include <QSharedPointer>
@@ -62,6 +64,7 @@ public:
bool initialize(Core::ActionContainer *ac);
static QString gitBinary();
+ static Utils::FileName gitBinDirectory();
static QString branch(const QString &repository);
void addToLocator(Core::CommandLocator *locator);
void push(const QString &topLevel);
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index da79d36bd7..279124a12e 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -2636,6 +2636,24 @@ bool GitClient::launchGitGui(const QString &workingDirectory) {
return success;
}
+Utils::FileName GitClient::gitBinDirectory()
+{
+ const QString git = gitBinaryPath();
+ if (git.isEmpty())
+ return Utils::FileName();
+
+ // Is 'git\cmd' in the path (folder containing .bats)?
+ QString path = QFileInfo(git).absolutePath();
+ // Git for Windows (msysGit) has git and gitk redirect executables in {setup dir}/cmd
+ // and the real binaries are in {setup dir}/bin. If cmd is configured in PATH
+ // or in Git settings, return bin instead.
+ if (Utils::HostOsInfo::isWindowsHost()
+ && path.endsWith(QLatin1String("/cmd"), Utils::HostOsInfo::fileNameCaseSensitivity())) {
+ path.replace(path.size() - 3, 3, QLatin1String("bin"));
+ }
+ return Utils::FileName::fromString(path);
+}
+
QString GitClient::gitBinaryPath(bool *ok, QString *errorMessage) const
{
return settings()->gitBinaryPath(ok, errorMessage);
diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h
index 9c54da4f94..c174f81298 100644
--- a/src/plugins/git/gitclient.h
+++ b/src/plugins/git/gitclient.h
@@ -35,6 +35,8 @@
#include <coreplugin/editormanager/ieditor.h>
+#include <utils/fileutils.h>
+
#include <QFutureSynchronizer>
#include <QObject>
#include <QString>
@@ -315,6 +317,7 @@ public:
void launchGitK(const QString &workingDirectory, const QString &fileName);
void launchGitK(const QString &workingDirectory) { launchGitK(workingDirectory, QString()); }
bool launchGitGui(const QString &workingDirectory);
+ Utils::FileName gitBinDirectory();
void launchRepositoryBrowser(const QString &workingDirectory);