VCS[git]: Environment settings.

Make GitClient::synchronousGit use the process environment.

Windows: Add a setting to fake a 'HOME' environment variable
(%HOMEDRIVE%%HOMEPATH%) to make msysgit look for its SSH-keys
there not only when run from git bash, but also from Qt Creator.
Useful in MinGw-setups, where git must not be in the path.
This commit is contained in:
Friedemann Kleint
2010-08-26 13:41:33 +02:00
parent 12feb86975
commit 56e800927e
6 changed files with 55 additions and 4 deletions

View File

@@ -1090,11 +1090,32 @@ QStringList GitClient::binary() const
#endif
}
// Determine a value for the HOME variable on Windows
// working around MSys git not finding it when run outside git bash
// (then looking for the SSH keys under "\program files\git").
QString GitClient::fakeWinHome(const QProcessEnvironment &e)
{
const QString homeDrive = e.value("HOMEDRIVE");
const QString homePath = e.value("HOMEPATH");
QTC_ASSERT(!homeDrive.isEmpty() && !homePath.isEmpty(), return QString())
return homeDrive + homePath;
}
QProcessEnvironment GitClient::processEnvironment() const
{
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
if (m_settings.adoptPath)
environment.insert(QLatin1String("PATH"), m_settings.path);
#ifdef Q_OS_WIN
if (m_settings.winSetHomeEnvironment) {
const QString home = fakeWinHome(environment);
if (Constants::debug)
qDebug("Setting home '%s'", qPrintable(home));
environment.insert(QLatin1String("HOME"), home);
}
#endif // Q_OS_WIN
// Set up SSH and C locale (required by git using perl).
VCSBase::VCSBasePlugin::setProcessEnvironment(&environment, false);
return environment;
@@ -1116,6 +1137,7 @@ Utils::SynchronousProcessResponse
args.append(gitArguments);
return VCSBase::VCSBasePlugin::runVCS(workingDirectory, executable, args,
m_settings.timeoutSeconds * 1000,
processEnvironment(),
flags, stdOutCodec);
}