Commit 385ea8c9 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

VCS: Polish 91c4b030

Do not clobber environment setting for SSH_ASKPASS.
Pass on QProcessEnvironment to CheckoutWizard.
parent 5364f5c1
......@@ -114,7 +114,7 @@ QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizardPage::createCheckoutJob(
args.pop_front();
VCSBase::AbstractCheckoutJob *job =
new VCSBase::ProcessCheckoutJob(binary, args, workingDirectory,
client->processEnvironment().toStringList());
client->processEnvironment());
return QSharedPointer<VCSBase::AbstractCheckoutJob>(job);
}
......
......@@ -46,7 +46,7 @@ struct ProcessCheckoutJobPrivate {
ProcessCheckoutJobPrivate(const QString &binary,
const QStringList &args,
const QString &workingDirectory,
const QStringList &env);
QProcessEnvironment env);
QSharedPointer<QProcess> process;
const QString binary;
......@@ -65,16 +65,13 @@ static inline QSharedPointer<QProcess> createProcess()
ProcessCheckoutJobPrivate::ProcessCheckoutJobPrivate(const QString &b,
const QStringList &a,
const QString &workingDirectory,
const QStringList &env) :
QProcessEnvironment processEnv) :
process(createProcess()),
binary(b),
args(a)
{
if (!workingDirectory.isEmpty())
process->setWorkingDirectory(workingDirectory);
if (!env.empty())
process->setEnvironment(env);
QProcessEnvironment processEnv = process->processEnvironment();
VCSBasePlugin::setProcessEnvironment(&processEnv);
process->setProcessEnvironment(processEnv);
}
......@@ -82,7 +79,7 @@ ProcessCheckoutJobPrivate::ProcessCheckoutJobPrivate(const QString &b,
ProcessCheckoutJob::ProcessCheckoutJob(const QString &binary,
const QStringList &args,
const QString &workingDirectory,
const QStringList &env,
const QProcessEnvironment &env,
QObject *parent) :
AbstractCheckoutJob(parent),
d(new ProcessCheckoutJobPrivate(binary, args, workingDirectory, env))
......
......@@ -35,6 +35,7 @@
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QProcess>
#include <QtCore/QProcessEnvironment>
QT_BEGIN_NAMESPACE
class QStringList;
......@@ -74,7 +75,7 @@ public:
explicit ProcessCheckoutJob(const QString &binary,
const QStringList &args,
const QString &workingDirectory = QString(),
const QStringList &env = QStringList(),
const QProcessEnvironment &env = QProcessEnvironment::systemEnvironment(),
QObject *parent = 0);
virtual ~ProcessCheckoutJob();
......
......@@ -43,17 +43,24 @@ static const char sshPasswordPromptKeyC[] = "SshPasswordPrompt";
static const int lineWrapWidthDefault = 72;
static const bool lineWrapDefault = true;
// Return default for the ssh-askpass command (default to environment)
static inline QString sshPasswordPromptDefault()
{
const QByteArray envSetting = qgetenv("SSH_ASKPASS");
if (!envSetting.isEmpty())
return QString::fromLocal8Bit(envSetting);
#ifdef Q_OS_WIN
static const char sshPasswordPromptDefaultC[] = "win-ssh-askpass";
return QLatin1String("win-ssh-askpass");
#else
static const char sshPasswordPromptDefaultC[] = "ssh-askpass";
return QLatin1String("ssh-askpass");
#endif
}
namespace VCSBase {
namespace Internal {
CommonVcsSettings::CommonVcsSettings() :
sshPasswordPrompt(QLatin1String(sshPasswordPromptDefaultC)),
sshPasswordPrompt(sshPasswordPromptDefault()),
lineWrap(lineWrapDefault),
lineWrapWidth(lineWrapWidthDefault)
{
......@@ -67,7 +74,12 @@ void CommonVcsSettings::toSettings(QSettings *s) const
s->setValue(QLatin1String(submitMessageCheckScriptKeyC), submitMessageCheckScript);
s->setValue(QLatin1String(lineWrapKeyC), lineWrap);
s->setValue(QLatin1String(lineWrapWidthKeyC), lineWrapWidth);
s->setValue(QLatin1String(sshPasswordPromptKeyC), sshPasswordPrompt);
// Do not store the default setting to avoid clobbering the environment.
if (sshPasswordPrompt != sshPasswordPromptDefault()) {
s->setValue(QLatin1String(sshPasswordPromptKeyC), sshPasswordPrompt);
} else {
s->remove(QLatin1String(sshPasswordPromptKeyC));
}
s->endGroup();
}
......@@ -79,7 +91,7 @@ void CommonVcsSettings::fromSettings(QSettings *s)
submitMessageCheckScript = s->value(QLatin1String(submitMessageCheckScriptKeyC), QString()).toString();
lineWrap = s->value(QLatin1String(lineWrapKeyC), lineWrapDefault).toBool();
lineWrapWidth = s->value(QLatin1String(lineWrapWidthKeyC), lineWrapWidthDefault).toInt();
sshPasswordPrompt = s->value(QLatin1String(sshPasswordPromptKeyC), QLatin1String(sshPasswordPromptDefaultC)).toString();
sshPasswordPrompt = s->value(QLatin1String(sshPasswordPromptKeyC), sshPasswordPromptDefault()).toString();
s->endGroup();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment