Commit afd2cb98 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

improve QProcess handling

ensure we take executables from PATH for execution instead possibly from current working directory
or the working directory set for the QProcess
parent ebba1d58
Pipeline #128231 passed with stage
in 5 minutes and 21 seconds
......@@ -9,6 +9,7 @@
#include <KTextEditor/View>
#include <QProcess>
#include <QStandardPaths>
struct CMakeComplData {
std::vector<QByteArray> m_commands;
......@@ -18,8 +19,14 @@ struct CMakeComplData {
static QByteArray runCMake(const QString &arg)
{
// only use cmake from PATH
static const auto cmakeExecutable = QStandardPaths::findExecutable(QStringLiteral("cmake"));
if (cmakeExecutable.isEmpty()) {
return {};
}
QProcess p;
p.start(QStringLiteral("cmake"), {arg});
p.start(cmakeExecutable, {arg});
if (p.waitForStarted() && p.waitForFinished()) {
if (p.exitCode() == 0 && p.exitStatus() == QProcess::NormalExit) {
return p.readAllStandardOutput();
......
......@@ -21,7 +21,9 @@ std::optional<QString> getDotGitPath(const QString &repo)
{
/* This call is intentionally blocking because we need git path for everything else */
QProcess git;
setupGitProcess(git, repo, {QStringLiteral("rev-parse"), QStringLiteral("--absolute-git-dir")});
if (!setupGitProcess(git, repo, {QStringLiteral("rev-parse"), QStringLiteral("--absolute-git-dir")})) {
return std::nullopt;
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
......
......@@ -14,6 +14,7 @@
#include <KTextEditor/View>
#include <QFileInfo>
#include <QRegularExpression>
#include <QStandardPaths>
KateToolRunner::KateToolRunner(std::unique_ptr<KateExternalTool> tool, KTextEditor::View *view, QObject *parent)
: QObject(parent)
......@@ -40,6 +41,12 @@ KateExternalTool *KateToolRunner::tool() const
void KateToolRunner::run()
{
// always only execute the tool from PATH
const auto fullExecutable = QStandardPaths::findExecutable(m_tool->executable);
if (fullExecutable.isEmpty()) {
return;
}
if (!m_tool->workingDir.isEmpty()) {
m_process->setWorkingDirectory(m_tool->workingDir);
} else if (m_view) {
......@@ -72,7 +79,7 @@ void KateToolRunner::run()
});
const QStringList args = KShell::splitArgs(m_tool->arguments);
m_process->start(m_tool->executable, args);
m_process->start(fullExecutable, args);
}
void KateToolRunner::waitForFinished()
......
......@@ -12,7 +12,9 @@
#include "debugview.h"
#include <QFile>
#include <QFileInfo>
#include <QRegularExpression>
#include <QStandardPaths>
#include <QTimer>
#include <KLocalizedString>
......@@ -48,7 +50,20 @@ void DebugView::runDebugger(const GDBTargetConf &conf, const QStringList &ioFifo
if (conf.executable.isEmpty()) {
return;
}
m_targetConf = conf;
// no chance if no debugger configured
if (m_targetConf.gdbCmd.isEmpty()) {
return;
}
// only run debugger from PATH or the absolute executable path we specified
const auto fullExecutable = QFileInfo(m_targetConf.gdbCmd).isAbsolute() ? m_targetConf.gdbCmd : QStandardPaths::findExecutable(m_targetConf.gdbCmd);
if (fullExecutable.isEmpty()) {
return;
}
if (ioFifos.size() == 3) {
m_ioPipeString = QStringLiteral("< %1 1> %2 2> %3").arg(ioFifos[0], ioFifos[1], ioFifos[2]);
}
......@@ -69,7 +84,7 @@ void DebugView::runDebugger(const GDBTargetConf &conf, const QStringList &ioFifo
connect(&m_debugProcess, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &DebugView::slotDebugFinished);
m_debugProcess.start(m_targetConf.gdbCmd, QStringList());
m_debugProcess.start(fullExecutable, QStringList());
m_nextCommands << QStringLiteral("set pagination off");
m_state = ready;
......
......@@ -263,7 +263,9 @@ static void createFileTree(QStandardItem *parent, const QString &basePath, const
static std::optional<QString> getGitCmdOutput(const QString &workDir, const QStringList &args)
{
QProcess git;
setupGitProcess(git, workDir, args);
if (!setupGitProcess(git, workDir, args)) {
return {};
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
......@@ -365,9 +367,12 @@ void CommitDiffTreeView::openCommit(const QString &hash, const QString &filePath
m_commitHash = hash;
QProcess *git = new QProcess(this);
setupGitProcess(*git,
QFileInfo(filePath).absolutePath(),
{QStringLiteral("show"), hash, QStringLiteral("--numstat"), QStringLiteral("--pretty=oneline"), QStringLiteral("-z")});
if (!setupGitProcess(*git,
QFileInfo(filePath).absolutePath(),
{QStringLiteral("show"), hash, QStringLiteral("--numstat"), QStringLiteral("--pretty=oneline"), QStringLiteral("-z")})) {
delete git;
return;
}
connect(git, &QProcess::finished, this, [this, git, filePath](int e, QProcess::ExitStatus s) {
git->deleteLater();
if (e != 0 || s != QProcess::NormalExit) {
......@@ -440,7 +445,9 @@ void CommitDiffTreeView::showDiff(const QModelIndex &idx)
{
const QString file = idx.data(FileItem::Path).toString();
QProcess git;
setupGitProcess(git, m_gitDir, {QStringLiteral("show"), m_commitHash, QStringLiteral("--"), file});
if (!setupGitProcess(git, m_gitDir, {QStringLiteral("show"), m_commitHash, QStringLiteral("--"), file})) {
return;
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
......
......@@ -263,7 +263,9 @@ void KateGitBlamePluginView::startBlameProcess(const QUrl &url)
QDir dir{url.toLocalFile()};
dir.cdUp();
setupGitProcess(m_blameInfoProc, dir.absolutePath(), {QStringLiteral("blame"), QStringLiteral("-p"), QStringLiteral("./%1").arg(fileName)});
if (!setupGitProcess(m_blameInfoProc, dir.absolutePath(), {QStringLiteral("blame"), QStringLiteral("-p"), QStringLiteral("./%1").arg(fileName)})) {
return;
}
m_blameInfoProc.start(QIODevice::ReadOnly);
m_blameUrl = url;
}
......@@ -278,7 +280,9 @@ void KateGitBlamePluginView::startShowProcess(const QUrl &url, const QString &ha
QDir dir{url.toLocalFile()};
dir.cdUp();
setupGitProcess(m_showProc, dir.absolutePath(), {QStringLiteral("show"), hash, QStringLiteral("--numstat")});
if (!setupGitProcess(m_showProc, dir.absolutePath(), {QStringLiteral("show"), hash, QStringLiteral("--numstat")})) {
return;
}
m_showProc.start(QIODevice::ReadOnly);
}
......
......@@ -8,6 +8,7 @@
#include <KLocalizedString>
#include <QDebug>
#include <QProcess>
#include <QStandardPaths>
GotoSymbolModel::GotoSymbolModel(QObject *parent)
: QAbstractTableModel(parent)
......@@ -58,16 +59,24 @@ void GotoSymbolModel::refresh(const QString &filePath)
m_rows.clear();
endResetModel();
// only use ctags from PATH
static const auto fullExecutablePath = QStandardPaths::findExecutable(QStringLiteral("ctags"));
if (fullExecutablePath.isEmpty()) {
beginResetModel();
m_rows.append(SymbolItem{i18n("CTags executable not found."), -1, QIcon()});
endResetModel();
return;
}
QProcess p;
p.start(QStringLiteral("ctags"), {QStringLiteral("-x"), QStringLiteral("--_xformat=%{name}%{signature}\t%{kind}\t%{line}"), filePath});
p.start(fullExecutablePath, {QStringLiteral("-x"), QStringLiteral("--_xformat=%{name}%{signature}\t%{kind}\t%{line}"), filePath});
QByteArray out;
if (p.waitForFinished()) {
out = p.readAllStandardOutput();
} else {
qWarning() << "Ctags failed";
beginResetModel();
m_rows.append(SymbolItem{i18n("CTags executable not found."), -1, QIcon()});
m_rows.append(SymbolItem{i18n("CTags executable failed to execute."), -1, QIcon()});
endResetModel();
return;
}
......
......@@ -158,7 +158,9 @@ void CompareBranchesView::showDiff(const QModelIndex &idx)
{
auto file = idx.data(Qt::UserRole).toString().remove(m_gitDir + QLatin1Char('/'));
QProcess git;
setupGitProcess(git, m_gitDir, {QStringLiteral("diff"), QStringLiteral("%1...%2").arg(m_fromBr).arg(m_toBr), QStringLiteral("--"), file});
if (!setupGitProcess(git, m_gitDir, {QStringLiteral("diff"), QStringLiteral("%1...%2").arg(m_fromBr).arg(m_toBr), QStringLiteral("--"), file})) {
return;
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
......
......@@ -231,9 +231,12 @@ FileHistoryWidget::~FileHistoryWidget()
// git log --format=%H%n%aN%n%aE%n%at%n%ct%n%P%n%B --author-date-order
void FileHistoryWidget::getFileHistory(const QString &file)
{
setupGitProcess(m_git,
QFileInfo(file).absolutePath(),
{QStringLiteral("log"), QStringLiteral("--format=%H%n%aN%n%aE%n%at%n%ct%n%P%n%B"), QStringLiteral("-z"), file});
if (!setupGitProcess(m_git,
QFileInfo(file).absolutePath(),
{QStringLiteral("log"), QStringLiteral("--format=%H%n%aN%n%aE%n%at%n%ct%n%P%n%B"), QStringLiteral("-z"), file})) {
Q_EMIT errorMessage(i18n("Failed to get file history: git executable not found in PATH"), true);
return;
}
connect(&m_git, &QProcess::readyReadStandardOutput, this, [this] {
auto commits = parseCommits(m_git.readAllStandardOutput().split(0x00));
......@@ -258,7 +261,10 @@ void FileHistoryWidget::itemClicked(const QModelIndex &idx)
const auto commit = idx.data(CommitListModel::CommitRole).value<Commit>();
setupGitProcess(git, fi.absolutePath(), {QStringLiteral("show"), QString::fromUtf8(commit.hash), QStringLiteral("--"), m_file});
if (!setupGitProcess(git, fi.absolutePath(), {QStringLiteral("show"), QString::fromUtf8(commit.hash), QStringLiteral("--"), m_file})) {
return;
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
......
......@@ -21,7 +21,9 @@ static void numStatForStatus(QVector<GitUtils::StatusItem> &list, const QString
: QStringList{QStringLiteral("diff"), QStringLiteral("--numstat"), QStringLiteral("--staged"), QStringLiteral("-z")};
QProcess git;
setupGitProcess(git, workDir, args);
if (!setupGitProcess(git, workDir, args)) {
return;
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
......
......@@ -15,7 +15,10 @@
bool GitUtils::isGitRepo(const QString &repo)
{
QProcess git;
setupGitProcess(git, repo, {QStringLiteral("rev-parse"), QStringLiteral("--is-inside-work-tree")});
if (!setupGitProcess(git, repo, {QStringLiteral("rev-parse"), QStringLiteral("--is-inside-work-tree")})) {
return false;
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
return git.readAll().trimmed() == "true";
......@@ -27,7 +30,10 @@ std::optional<QString> GitUtils::getDotGitPath(const QString &repo)
{
/* This call is intentionally blocking because we need git path for everything else */
QProcess git;
setupGitProcess(git, repo, {QStringLiteral("rev-parse"), QStringLiteral("--absolute-git-dir")});
if (!setupGitProcess(git, repo, {QStringLiteral("rev-parse"), QStringLiteral("--absolute-git-dir")})) {
return std::nullopt;
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
......@@ -57,7 +63,10 @@ QString GitUtils::getCurrentBranchName(const QString &repo)
for (int i = 0; i < 3; ++i) {
QProcess git;
setupGitProcess(git, repo, argsList[i]);
if (!setupGitProcess(git, repo, argsList[i])) {
return QString();
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() == QProcess::NormalExit && git.exitCode() == 0) {
......@@ -73,7 +82,10 @@ QString GitUtils::getCurrentBranchName(const QString &repo)
GitUtils::CheckoutResult GitUtils::checkoutBranch(const QString &repo, const QString &branch)
{
QProcess git;
setupGitProcess(git, repo, {QStringLiteral("checkout"), branch});
if (!setupGitProcess(git, repo, {QStringLiteral("checkout"), branch})) {
return CheckoutResult{};
}
git.start(QProcess::ReadOnly);
CheckoutResult res;
res.branch = branch;
......@@ -91,7 +103,11 @@ GitUtils::CheckoutResult GitUtils::checkoutNewBranch(const QString &repo, const
if (!fromBranch.isEmpty()) {
args.append(fromBranch);
}
setupGitProcess(git, repo, args);
if (!setupGitProcess(git, repo, args)) {
return CheckoutResult{};
}
git.start(QProcess::ReadOnly);
CheckoutResult res;
res.branch = newBranch;
......@@ -132,7 +148,10 @@ QVector<GitUtils::Branch> GitUtils::getAllBranchesAndTags(const QString &repo, R
args.append(QStringLiteral("--sort=-taggerdate"));
}
setupGitProcess(git, repo, args);
if (!setupGitProcess(git, repo, args)) {
return {};
}
git.start(QProcess::ReadOnly);
QVector<Branch> branches;
if (git.waitForStarted() && git.waitForFinished(-1)) {
......@@ -168,7 +187,10 @@ QVector<GitUtils::Branch> GitUtils::getAllLocalBranchesWithLastCommitSubject(con
QStringLiteral("--sort=-committerdate"),
QStringLiteral("refs/heads")};
setupGitProcess(git, repo, args);
if (!setupGitProcess(git, repo, args)) {
return {};
}
git.start(QProcess::ReadOnly);
QVector<Branch> branches;
if (git.waitForStarted() && git.waitForFinished(-1)) {
......@@ -202,7 +224,10 @@ std::pair<QString, QString> GitUtils::getLastCommitMessage(const QString &repo)
{
// git log -1 --pretty=%B
QProcess git;
setupGitProcess(git, repo, {QStringLiteral("log"), QStringLiteral("-1"), QStringLiteral("--pretty=%B")});
if (!setupGitProcess(git, repo, {QStringLiteral("log"), QStringLiteral("-1"), QStringLiteral("--pretty=%B")})) {
return {};
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitCode() != 0 || git.exitStatus() != QProcess::NormalExit) {
......@@ -233,7 +258,10 @@ GitUtils::Result GitUtils::deleteBranches(const QStringList &branches, const QSt
args << branches;
QProcess git;
setupGitProcess(git, repo, args);
if (!setupGitProcess(git, repo, args)) {
return {};
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
QString out = QString::fromLatin1(git.readAllStandardError()) + QString::fromLatin1(git.readAllStandardOutput());
......
......@@ -574,8 +574,9 @@ void GitWidget::launchExternalDiffTool(const QString &file, bool staged)
args.append(file);
QProcess git;
setupGitProcess(git, m_gitPath, args);
git.startDetached();
if (setupGitProcess(git, m_gitPath, args)) {
git.startDetached();
}
}
void GitWidget::commitChanges(const QString &msg, const QString &desc, bool signOff, bool amend)
......@@ -777,7 +778,12 @@ void GitWidget::branchCompareFiles(const QString &from, const QString &to)
auto args = QStringList{QStringLiteral("diff"), QStringLiteral("%1...%2").arg(from).arg(to), QStringLiteral("--name-status")};
QProcess git;
setupGitProcess(git, m_gitPath, args);
// early out if we can't find git
if (!setupGitProcess(git, m_gitPath, args)) {
return;
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
......@@ -799,7 +805,12 @@ void GitWidget::branchCompareFiles(const QString &from, const QString &to)
// get --num-stat
args = QStringList{QStringLiteral("diff"), QStringLiteral("%1...%2").arg(from).arg(to), QStringLiteral("--numstat"), QStringLiteral("-z")};
setupGitProcess(git, m_gitPath, args);
// early out if we can't find git
if (!setupGitProcess(git, m_gitPath, args)) {
return;
}
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
......
......@@ -9,6 +9,7 @@
#include <QDir>
#include <QProcess>
#include <QStandardPaths>
/**
* include ctags reading
......@@ -73,6 +74,12 @@ void KateProjectIndex::loadCtags(const QStringList &files, const QVariantMap &ct
*/
m_ctagsIndexFile->close();
// only use ctags from PATH
static const auto fullExecutablePath = QStandardPaths::findExecutable(QStringLiteral("ctags"));
if (fullExecutablePath.isEmpty()) {
return;
}
/**
* try to run ctags for all files in this project
* output to our ctags index file
......@@ -85,7 +92,7 @@ void KateProjectIndex::loadCtags(const QStringList &files, const QVariantMap &ct
for (const QVariant &optVariant : opts) {
args << optVariant.toString();
}
ctags.start(QStringLiteral("ctags"), args);
ctags.start(fullExecutablePath, args);
if (!ctags.waitForStarted()) {
return;
}
......
......@@ -13,6 +13,7 @@
#include <QFileInfo>
#include <QHBoxLayout>
#include <QStandardPaths>
#include <QToolTip>
#include <QVBoxLayout>
......@@ -134,14 +135,18 @@ void KateProjectInfoViewCodeAnalysis::slotStartStopClicked()
connect(m_analyzer, &QProcess::readyRead, this, &KateProjectInfoViewCodeAnalysis::slotReadyRead);
connect(m_analyzer, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &KateProjectInfoViewCodeAnalysis::finished);
m_analyzer->start(m_analysisTool->path(), m_analysisTool->arguments());
// ensure we only run the code analyzer from PATH
const QString fullExecutable = QStandardPaths::findExecutable(m_analysisTool->path());
if (!fullExecutable.isEmpty()) {
m_analyzer->start(fullExecutable, m_analysisTool->arguments());
}
if (m_messageWidget) {
delete m_messageWidget;
m_messageWidget = nullptr;
}
if (!m_analyzer->waitForStarted()) {
if (fullExecutable.isEmpty() || !m_analyzer->waitForStarted()) {
m_messageWidget = new KMessageWidget(this);
m_messageWidget->setCloseButtonVisible(true);
m_messageWidget->setMessageType(KMessageWidget::Warning);
......
......@@ -18,6 +18,7 @@
#include <QRegularExpression>
#include <QSet>
#include <QSettings>
#include <QStandardPaths>
#include <QThread>
#include <QTime>
#include <QtConcurrent>
......@@ -446,10 +447,12 @@ QVector<QString> KateProjectWorker::filesFromGit(const QDir &dir, bool recursive
QVector<QString> KateProjectWorker::gitFiles(const QDir &dir, bool recursive, const QStringList &args, bool ignoreBinaryFiles)
{
QVector<QString> files;
QProcess git;
setupGitProcess(git, dir.absolutePath(), args);
if (!setupGitProcess(git, dir.absolutePath(), args)) {
return files;
}
git.start(QProcess::ReadOnly);
QVector<QString> files;
if (!git.waitForStarted() || !git.waitForFinished(-1)) {
return files;
}
......@@ -482,13 +485,18 @@ QVector<QString> KateProjectWorker::gitFiles(const QDir &dir, bool recursive, co
QVector<QString> KateProjectWorker::filesFromMercurial(const QDir &dir, bool recursive)
{
// only use version control from PATH
QVector<QString> files;
static const auto fullExecutablePath = QStandardPaths::findExecutable(QStringLiteral("hg"));
if (fullExecutablePath.isEmpty()) {
return files;
}
QProcess hg;
hg.setWorkingDirectory(dir.absolutePath());
QStringList args;
args << QStringLiteral("manifest") << QStringLiteral(".");
hg.start(QStringLiteral("hg"), args, QProcess::ReadOnly);
hg.start(fullExecutablePath, args, QProcess::ReadOnly);
if (!hg.waitForStarted() || !hg.waitForFinished(-1)) {
return files;
}
......@@ -509,7 +517,12 @@ QVector<QString> KateProjectWorker::filesFromMercurial(const QDir &dir, bool rec
QVector<QString> KateProjectWorker::filesFromSubversion(const QDir &dir, bool recursive)
{
// only use version control from PATH
QVector<QString> files;
static const auto fullExecutablePath = QStandardPaths::findExecutable(QStringLiteral("svn"));
if (fullExecutablePath.isEmpty()) {
return files;
}
QProcess svn;
svn.setWorkingDirectory(dir.absolutePath());
......@@ -520,7 +533,7 @@ QVector<QString> KateProjectWorker::filesFromSubversion(const QDir &dir, bool re
} else {
args << QStringLiteral("--depth=files");
}
svn.start(QStringLiteral("svn"), args, QProcess::ReadOnly);
svn.start(fullExecutablePath, args, QProcess::ReadOnly);
if (!svn.waitForStarted() || !svn.waitForFinished(-1)) {
return files;
}
......@@ -571,18 +584,21 @@ QVector<QString> KateProjectWorker::filesFromSubversion(const QDir &dir, bool re
QVector<QString> KateProjectWorker::filesFromDarcs(const QDir &dir, bool recursive)
{
// only use version control from PATH
QVector<QString> files;
static const auto fullExecutablePath = QStandardPaths::findExecutable(QStringLiteral("darcs"));
if (fullExecutablePath.isEmpty()) {
return files;
}
const QString cmd = QStringLiteral("darcs");
QString root;
{
QProcess darcs;
darcs.setWorkingDirectory(dir.absolutePath());
QStringList args;
args << QStringLiteral("list") << QStringLiteral("repo");
darcs.start(cmd, args, QProcess::ReadOnly);
darcs.start(fullExecutablePath, args, QProcess::ReadOnly);
if (!darcs.waitForStarted() || !darcs.waitForFinished(-1)) {
return files;
......@@ -606,7 +622,7 @@ QVector<QString> KateProjectWorker::filesFromDarcs(const QDir &dir, bool recursi
darcs.setWorkingDirectory(dir.absolutePath());
args << QStringLiteral("list") << QStringLiteral("files") << QStringLiteral("--no-directories") << QStringLiteral("--pending");
darcs.start(cmd, args, QProcess::ReadOnly);
darcs.start(fullExecutablePath, args, QProcess::ReadOnly);
if (!darcs.waitForStarted() || !darcs.waitForFinished(-1)) {
return files;
......@@ -631,13 +647,18 @@ QVector<QString> KateProjectWorker::filesFromDarcs(const QDir &dir, bool recursi
QVector<QString> KateProjectWorker::filesFromFossil(const QDir &dir, bool recursive)
{
// only use version control from PATH
QVector<QString> files;
static const auto fullExecutablePath = QStandardPaths::findExecutable(QStringLiteral("fossil"));
if (fullExecutablePath.isEmpty()) {
return files;
}
QProcess fossil;
fossil.setWorkingDirectory(dir.absolutePath());
QStringList args;
args << QStringLiteral("ls");
fossil.start(QStringLiteral("fossil"), args, QProcess::ReadOnly);
fossil.start(fullExecutablePath, args, QProcess::ReadOnly);
if (!fossil.waitForStarted() || !fossil.waitForFinished(-1)) {
return files;
}
......
......@@ -32,6 +32,8 @@
#include <kfts_fuzzy_match.h>
#include <gitprocess.h>
constexpr int StashIndexRole = Qt::UserRole + 2;
class StashFilterModel final : public QSortFilterProxyModel
......@@ -218,11 +220,10 @@ void StashDialog::slotReturnPressed()
hide();
}
QProcess *StashDialog::gitp()
QProcess *StashDialog::gitp(const QStringList &arguments)
{
auto git = new QProcess(this);
git->setProgram(QStringLiteral("git"));
git->setWorkingDirectory(m_gitPath);
setupGitProcess(*git, m_gitPath, arguments);