forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user