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>
This commit is contained in:
Orgad Shaneh
2014-07-16 00:46:07 +03:00
committed by Orgad Shaneh
parent 36d2f47dcc
commit 54db877297
5 changed files with 32 additions and 8 deletions

View File

@@ -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);