Utils: Add CommandLine convenience constructors

... taking a QString for the executable.

This weakens the very explicit QString -> FileName conversion via the
named constructors for the special case of constructing a CommandLine.

I think that's worthwhile here, as it reduces the noise on the caller
site under circumstance where the nature of the thing is obvious.

Change-Id: I27b4a73639728893d053b2e7ba65cb745f0ffe83
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-07-23 10:17:57 +02:00
parent 80716610c5
commit 8b72e92167
31 changed files with 55 additions and 53 deletions

View File

@@ -1369,7 +1369,8 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
// Initialize repository
bool GitClient::synchronousInit(const QString &workingDirectory)
{
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory, {"init"});
const SynchronousProcessResponse resp = vcsFullySynchronousExec(workingDirectory,
QStringList{"init"});
// '[Re]Initialized...'
VcsOutputWindow::append(resp.stdOut());
if (resp.result == SynchronousProcessResponse::Finished) {
@@ -1581,7 +1582,7 @@ QString GitClient::synchronousTopic(const QString &workingDirectory) const
// No tag or remote branch - try git describe
const SynchronousProcessResponse resp =
vcsFullySynchronousExec(workingDirectory, {"describe"}, VcsCommand::NoOutput);
vcsFullySynchronousExec(workingDirectory, QStringList{"describe"}, VcsCommand::NoOutput);
if (resp.result == SynchronousProcessResponse::Finished) {
const QString stdOut = resp.stdOut().trimmed();
if (!stdOut.isEmpty())
@@ -2422,7 +2423,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
arguments.append(QtcProcess::splitArgs(gitkOpts, HostOsInfo::hostOs()));
if (!fileName.isEmpty())
arguments << "--" << fileName;
VcsOutputWindow::appendCommand(workingDirectory, {FilePath::fromString(binary), arguments});
VcsOutputWindow::appendCommand(workingDirectory, {binary, arguments});
// This should always use QProcess::startDetached (as not to kill
// the child), but that does not have an environment parameter.
bool success = false;