Git: Prepend to PATH instead of replacing it

Change-Id: Ia6d783e97d7f4c80a3838b0167dcdcfce5fe4a6e
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
Orgad Shaneh
2012-01-27 09:52:06 +02:00
committed by Tobias Hunger
parent e2ace515e2
commit d3f889df7d
6 changed files with 11 additions and 33 deletions

View File

@@ -1408,8 +1408,12 @@ QProcessEnvironment GitClient::processEnvironment() const
{
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
if (settings()->boolValue(GitSettings::adoptPathKey))
environment.insert(QLatin1String("PATH"), settings()->stringValue(GitSettings::pathKey));
QString gitPath = settings()->stringValue(GitSettings::pathKey);
if (!gitPath.isEmpty()) {
gitPath += Utils::SynchronousProcess::pathSeparator();
gitPath += environment.value(QLatin1String("PATH"));
environment.insert(QLatin1String("PATH"), gitPath);
}
#ifdef Q_OS_WIN
if (settings()->boolValue(GitSettings::winSetHomeEnvironmentKey))
environment.insert(QLatin1String("HOME"), QDir::toNativeSeparators(QDir::homePath()));
@@ -1620,7 +1624,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
// This should always use QProcess::startDetached (as not to kill
// the child), but that does not have an environment parameter.
bool success = false;
if (settings()->boolValue(GitSettings::adoptPathKey)) {
if (!settings()->stringValue(GitSettings::pathKey).isEmpty()) {
QProcess *process = new QProcess(this);
process->setWorkingDirectory(workingDirectory);
process->setProcessEnvironment(env);

View File

@@ -39,7 +39,6 @@
namespace Git {
namespace Internal {
const QLatin1String GitSettings::adoptPathKey("SysEnv");
const QLatin1String GitSettings::pathKey("Path");
const QLatin1String GitSettings::pullRebaseKey("PullRebase");
const QLatin1String GitSettings::omitAnnotationDateKey("OmitAnnotationDate");
@@ -61,7 +60,6 @@ GitSettings::GitSettings()
#else
declareKey(timeoutKey, 30);
#endif
declareKey(adoptPathKey, false);
declareKey(pathKey, QString());
declareKey(pullRebaseKey, false);
declareKey(omitAnnotationDateKey, false);
@@ -87,7 +85,7 @@ QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
const QString binary = stringValue(binaryPathKey);
QString currentPath = stringValue(pathKey);
// Easy, git is assumed to be elsewhere accessible
if (!boolValue(adoptPathKey))
if (currentPath.isEmpty())
currentPath = QString::fromLocal8Bit(qgetenv("PATH"));
// Search in path?
m_binaryPath = Utils::SynchronousProcess::locateBinary(currentPath, binary);

View File

@@ -46,7 +46,6 @@ class GitSettings : public VcsBase::VcsBaseClientSettings
public:
GitSettings();
static const QLatin1String adoptPathKey;
static const QLatin1String pathKey;
static const QLatin1String pullRebaseKey;
static const QLatin1String omitAnnotationDateKey;

View File

@@ -52,7 +52,6 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
QWidget(parent)
{
m_ui.setupUi(this);
connect(m_ui.adoptButton, SIGNAL(clicked()), this, SLOT(setSystemPath()));
#ifdef Q_OS_WIN
const QByteArray currentHome = qgetenv("HOME");
const QString toolTip
@@ -72,8 +71,6 @@ GitSettings SettingsPageWidget::settings() const
{
GitSettings rc;
rc.setValue(GitSettings::pathKey, m_ui.pathLineEdit->text());
rc.setValue(GitSettings::adoptPathKey, m_ui.environmentGroupBox->isChecked()
&& !rc.stringValue(GitSettings::pathKey).isEmpty());
rc.setValue(GitSettings::logCountKey, m_ui.logCountSpinBox->value());
rc.setValue(GitSettings::timeoutKey, m_ui.timeoutSpinBox->value());
rc.setValue(GitSettings::pullRebaseKey, m_ui.pullRebaseCheckBox->isChecked());
@@ -85,7 +82,6 @@ GitSettings SettingsPageWidget::settings() const
void SettingsPageWidget::setSettings(const GitSettings &s)
{
m_ui.environmentGroupBox->setChecked(s.boolValue(GitSettings::adoptPathKey));
m_ui.pathLineEdit->setText(s.stringValue(GitSettings::pathKey));
m_ui.logCountSpinBox->setValue(s.intValue(GitSettings::logCountKey));
m_ui.timeoutSpinBox->setValue(s.intValue(GitSettings::timeoutKey));
@@ -95,17 +91,11 @@ void SettingsPageWidget::setSettings(const GitSettings &s)
m_ui.gitkOptionsLineEdit->setText(s.stringValue(GitSettings::gitkOptionsKey));
}
void SettingsPageWidget::setSystemPath()
{
m_ui.pathLineEdit->setText(QLatin1String(qgetenv("PATH")));
}
QString SettingsPageWidget::searchKeywords() const
{
QString rc;
QLatin1Char sep(' ');
QTextStream(&rc)
<< sep << m_ui.environmentGroupBox->title()
<< sep << m_ui.pathlabel->text()
<< sep << m_ui.winHomeCheckBox->text()
<< sep << m_ui.groupBox->title()

View File

@@ -59,9 +59,6 @@ public:
QString searchKeywords() const;
private slots:
void setSystemPath();
private:
Ui::SettingsPage m_ui;
};

View File

@@ -12,34 +12,24 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="environmentGroupBox">
<widget class="QGroupBox" name="configurationGroupBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Customize Environment:</string>
</property>
<property name="checkable">
<bool>true</bool>
<string>Configuration</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="pathlabel">
<property name="text">
<string>PATH:</string>
<string>Prepend to PATH:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="pathLineEdit"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="adoptButton">
<property name="text">
<string>From System</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="winHomeCheckBox">
<property name="text">