GitClient: Replace for-each-ref command with QtcProcess

There is no need to use VcsCommand when NoOutput is passed.
Get rid of asyncForEachRefCmd().

Change-Id: I91b2226c365c7ce374eccc4884aba7aab5158cb2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-09-01 16:02:53 +02:00
parent 66bfdffe0c
commit 6f3c03f1f9
3 changed files with 9 additions and 13 deletions

View File

@@ -14,8 +14,6 @@
#include <utils/qtcprocess.h>
#include <utils/theme/theme.h>
#include <vcsbase/vcscommand.h>
#include <QApplication>
#include <QCompleter>
#include <QDir>
@@ -211,11 +209,16 @@ void ChangeSelectionDialog::recalculateCompletion()
return;
GitClient *client = GitClient::instance();
VcsCommand *command = client->asyncForEachRefCmd(workingDir, {"--format=%(refname:short)"});
connect(this, &QObject::destroyed, command, &VcsCommand::abort);
connect(command, &VcsCommand::stdOutText, [this](const QString &output) {
m_changeModel->setStringList(output.split('\n'));
QtcProcess *process = new QtcProcess(this);
process->setEnvironment(client->processEnvironment());
process->setCommand({client->vcsBinary(), {"for-each-ref", "--format=%(refname:short)"}});
process->setWorkingDirectory(workingDir);
connect(process, &QtcProcess::done, this, [this, process] {
if (process->result() == ProcessResult::FinishedWithSuccess)
m_changeModel->setStringList(process->cleanedStdOut().split('\n'));
process->deleteLater();
});
process->start();
}
void ChangeSelectionDialog::recalculateDetails()

View File

@@ -2017,12 +2017,6 @@ bool GitClient::synchronousForEachRefCmd(const FilePath &workingDirectory, QStri
return false;
}
VcsCommand *GitClient::asyncForEachRefCmd(const FilePath &workingDirectory, QStringList args) const
{
args.push_front("for-each-ref");
return vcsExec(workingDirectory, args, nullptr, false, VcsCommand::NoOutput);
}
bool GitClient::synchronousRemoteCmd(const FilePath &workingDirectory, QStringList remoteArgs,
QString *output, QString *errorMessage, bool silent) const
{

View File

@@ -208,7 +208,6 @@ public:
QString *output, QString *errorMessage) const;
bool synchronousForEachRefCmd(const Utils::FilePath &workingDirectory, QStringList args,
QString *output, QString *errorMessage = nullptr) const;
VcsBase::VcsCommand *asyncForEachRefCmd(const Utils::FilePath &workingDirectory, QStringList args) const;
bool synchronousRemoteCmd(const Utils::FilePath &workingDirectory, QStringList remoteArgs,
QString *output = nullptr, QString *errorMessage = nullptr,
bool silent = false) const;