Commit 00a29743 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

ensure process stdin is closed

parent 78ce19f8
......@@ -14,7 +14,7 @@ bool GitUtils::isGitRepo(const QString &repo)
QProcess git;
git.setWorkingDirectory(repo);
QStringList args{QStringLiteral("rev-parse"), QStringLiteral("--is-inside-work-tree")};
git.start(QStringLiteral("git"), args);
git.start(QStringLiteral("git"), args, QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
return git.readAll().trimmed() == "true";
}
......@@ -37,7 +37,7 @@ QString GitUtils::getCurrentBranchName(const QString &repo)
for (int i = 0; i < 3; ++i) {
auto args = argsList[i];
git.start(QStringLiteral("git"), args);
git.start(QStringLiteral("git"), args, QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() == QProcess::NormalExit && git.exitCode() == 0) {
return QString::fromUtf8(git.readAllStandardOutput().trimmed());
......@@ -54,7 +54,7 @@ GitUtils::CheckoutResult GitUtils::checkoutBranch(const QString &repo, const QSt
QProcess git;
git.setWorkingDirectory(repo);
QStringList args{QStringLiteral("checkout"), branch};
git.start(QStringLiteral("git"), args);
git.start(QStringLiteral("git"), args, QProcess::ReadOnly);
CheckoutResult res;
res.branch = branch;
if (git.waitForStarted() && git.waitForFinished(-1)) {
......@@ -72,7 +72,7 @@ GitUtils::CheckoutResult GitUtils::checkoutNewBranch(const QString &repo, const
if (!fromBranch.isEmpty()) {
args.append(fromBranch);
}
git.start(QStringLiteral("git"), args);
git.start(QStringLiteral("git"), args, QProcess::ReadOnly);
CheckoutResult res;
res.branch = newBranch;
if (git.waitForStarted() && git.waitForFinished(-1)) {
......@@ -113,7 +113,7 @@ QVector<GitUtils::Branch> GitUtils::getAllBranchesAndTags(const QString &repo, R
args.append(QStringLiteral("--sort=-taggerdate"));
}
git.start(QStringLiteral("git"), args);
git.start(QStringLiteral("git"), args, QProcess::ReadOnly);
QVector<Branch> branches;
if (git.waitForStarted() && git.waitForFinished(-1)) {
QString gitout = QString::fromUtf8(git.readAllStandardOutput());
......
......@@ -93,7 +93,7 @@ void GitWidget::initGitExe()
// and then calculate the exit .git path
git.setWorkingDirectory(m_project->baseDir());
git.setArguments({QStringLiteral("rev-parse"), QStringLiteral("--absolute-git-dir")});
git.start();
git.start(QProcess::ReadOnly);
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
sendMessage(i18n("Failed to find .git directory. Things may not work correctly. Error:\n%1", QString::fromUtf8(git.readAllStandardError())), true);
......@@ -157,7 +157,7 @@ void GitWidget::getStatus(bool untracked, bool submodules)
args.append(QStringLiteral("--ignore-submodules"));
}
git.setArguments(args);
git.start();
git.start(QProcess::ReadOnly);
}
void GitWidget::runGitCmd(const QStringList &args, const QString &i18error)
......@@ -173,7 +173,7 @@ void GitWidget::runGitCmd(const QStringList &args, const QString &i18error)
}
});
git.setArguments(args);
git.start();
git.start(QProcess::ReadOnly);
}
void GitWidget::stage(const QStringList &files, bool)
......@@ -234,7 +234,7 @@ void GitWidget::openAtHEAD(const QString &file)
auto args = QStringList{QStringLiteral("show"), QStringLiteral("--textconv")};
args.append(QStringLiteral(":") + file);
git.setArguments(args);
git.start();
git.start(QProcess::ReadOnly);
disconnect(&git, &QProcess::finished, nullptr, nullptr);
connect(&git, &QProcess::finished, this, [this, file](int exitCode, QProcess::ExitStatus es) {
......@@ -276,7 +276,7 @@ void GitWidget::openAtHEAD(const QString &file)
});
git.setArguments(args);
git.start();
git.start(QProcess::ReadOnly);
}
void GitWidget::showDiff(const QString &file, bool staged)
......@@ -332,7 +332,7 @@ void GitWidget::showDiff(const QString &file, bool staged)
});
git.setArguments(args);
git.start();
git.start(QProcess::ReadOnly);
}
void GitWidget::launchExternalDiffTool(const QString &file, bool staged)
......@@ -348,7 +348,7 @@ void GitWidget::launchExternalDiffTool(const QString &file, bool staged)
args.append(file);
git.setArguments(args);
git.start();
git.start(QProcess::ReadOnly);
}
void GitWidget::commitChanges(const QString &msg, const QString &desc, bool signOff)
......@@ -377,7 +377,7 @@ void GitWidget::commitChanges(const QString &msg, const QString &desc, bool sign
}
});
git.setArguments(args);
git.start();
git.start(QProcess::ReadOnly);
}
void GitWidget::opencommitChangesDialog()
......
......@@ -48,7 +48,7 @@ static bool isGit(const QString &filename)
// git ls-files -z results a bytearray where each entry is \0-terminated.
// NOTE: Without -z, Umlauts such as "Der Bäcker/Das Brötchen.txt" do not work (#389415, #402213)
args << QStringLiteral("ls-files") << QStringLiteral("-z") << fi.fileName();
git.start(QStringLiteral("git"), args);
git.start(QStringLiteral("git"), args, QProcess::ReadOnly);
bool isGit = false;
if (git.waitForStarted() && git.waitForFinished(-1)) {
const QList<QByteArray> byteArrayList = git.readAllStandardOutput().split('\0');
......
......@@ -421,7 +421,7 @@ QStringList KateProjectWorker::gitLsFiles(const QDir &dir)
QProcess git;
git.setWorkingDirectory(dir.absolutePath());
git.start(QStringLiteral("git"), args);
git.start(QStringLiteral("git"), args, QProcess::ReadOnly);
QStringList files;
if (!git.waitForStarted() || !git.waitForFinished(-1)) {
return files;
......@@ -440,7 +440,7 @@ QStringList KateProjectWorker::gitLsFiles(const QDir &dir)
args.clear();
args << QStringLiteral("ls-files") << QStringLiteral("-z") << QStringLiteral("--others") << QStringLiteral("--exclude-standard") << QStringLiteral(".");
git.setArguments(args);
git.start();
git.start(QProcess::ReadOnly);
if (!git.waitForStarted() || !git.waitForFinished(-1)) {
return files;
......@@ -466,7 +466,7 @@ QStringList KateProjectWorker::filesFromMercurial(const QDir &dir, bool recursiv
hg.setWorkingDirectory(dir.absolutePath());
QStringList args;
args << QStringLiteral("manifest") << QStringLiteral(".");
hg.start(QStringLiteral("hg"), args);
hg.start(QStringLiteral("hg"), args, QProcess::ReadOnly);
if (!hg.waitForStarted() || !hg.waitForFinished(-1)) {
return files;
}
......@@ -502,7 +502,7 @@ QStringList KateProjectWorker::filesFromSubversion(const QDir &dir, bool recursi
} else {
args << QStringLiteral("--depth=files");
}
svn.start(QStringLiteral("svn"), args);
svn.start(QStringLiteral("svn"), args, QProcess::ReadOnly);
if (!svn.waitForStarted() || !svn.waitForFinished(-1)) {
return files;
}
......@@ -567,7 +567,7 @@ QStringList KateProjectWorker::filesFromDarcs(const QDir &dir, bool recursive)
QStringList args;
args << QStringLiteral("list") << QStringLiteral("repo");
darcs.start(cmd, args);
darcs.start(cmd, args, QProcess::ReadOnly);
if (!darcs.waitForStarted() || !darcs.waitForFinished(-1)) {
return files;
......@@ -591,7 +591,7 @@ QStringList KateProjectWorker::filesFromDarcs(const QDir &dir, bool recursive)
darcs.setWorkingDirectory(dir.absolutePath());
args << QStringLiteral("list") << QStringLiteral("files") << QStringLiteral("--no-directories") << QStringLiteral("--pending");
darcs.start(cmd, args);
darcs.start(cmd, args, QProcess::ReadOnly);
if (!darcs.waitForStarted() || !darcs.waitForFinished(-1)) {
return files;
......
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