forked from qt-creator/qt-creator
Git: Eradicate Q_FOREACH loops
Change-Id: I29b6071ea244d1b3ae0701d36c90b1e93cf21fbb Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
e3eee3b2b9
commit
e366e135b7
@@ -33,11 +33,13 @@
|
|||||||
#include "gitconstants.h"
|
#include "gitconstants.h"
|
||||||
#include "ui_branchdialog.h"
|
#include "ui_branchdialog.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
#include <utils/execmenu.h>
|
|
||||||
#include <vcsbase/vcsoutputwindow.h>
|
#include <vcsbase/vcsoutputwindow.h>
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
|
|
||||||
|
#include <utils/asconst.h>
|
||||||
|
#include <utils/execmenu.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@@ -217,7 +219,7 @@ void BranchDialog::checkout()
|
|||||||
|
|
||||||
QList<Stash> stashes;
|
QList<Stash> stashes;
|
||||||
client->synchronousStashList(m_repository, &stashes);
|
client->synchronousStashList(m_repository, &stashes);
|
||||||
foreach (const Stash &stash, stashes) {
|
for (const Stash &stash : Utils::asConst(stashes)) {
|
||||||
if (stash.message.startsWith(popMessageStart)) {
|
if (stash.message.startsWith(popMessageStart)) {
|
||||||
branchCheckoutDialog.foundStashForNextBranch();
|
branchCheckoutDialog.foundStashForNextBranch();
|
||||||
break;
|
break;
|
||||||
@@ -245,7 +247,7 @@ void BranchDialog::checkout()
|
|||||||
|
|
||||||
QString stashName;
|
QString stashName;
|
||||||
client->synchronousStashList(m_repository, &stashes);
|
client->synchronousStashList(m_repository, &stashes);
|
||||||
foreach (const Stash &stash, stashes) {
|
for (const Stash &stash : Utils::asConst(stashes)) {
|
||||||
if (stash.message.startsWith(popMessageStart)) {
|
if (stash.message.startsWith(popMessageStart)) {
|
||||||
stashName = stash.name;
|
stashName = stash.name;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -27,10 +27,12 @@
|
|||||||
#include "gitclient.h"
|
#include "gitclient.h"
|
||||||
#include "gitconstants.h"
|
#include "gitconstants.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
#include <vcsbase/vcsoutputwindow.h>
|
#include <vcsbase/vcsoutputwindow.h>
|
||||||
#include <vcsbase/vcscommand.h>
|
#include <vcsbase/vcscommand.h>
|
||||||
|
|
||||||
|
#include <utils/asconst.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
|
||||||
@@ -137,7 +139,7 @@ public:
|
|||||||
fn.append(nodes.first()->sha);
|
fn.append(nodes.first()->sha);
|
||||||
nodes.removeFirst();
|
nodes.removeFirst();
|
||||||
|
|
||||||
foreach (const BranchNode *n, nodes)
|
for (const BranchNode *n : Utils::asConst(nodes))
|
||||||
fn.append(n->name);
|
fn.append(n->name);
|
||||||
|
|
||||||
return fn;
|
return fn;
|
||||||
@@ -167,7 +169,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (children.count() > 0) {
|
if (children.count() > 0) {
|
||||||
QStringList names;
|
QStringList names;
|
||||||
foreach (BranchNode *n, children) {
|
for (BranchNode *n : children) {
|
||||||
names.append(n->childrenNames());
|
names.append(n->childrenNames());
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
@@ -340,9 +342,10 @@ Qt::ItemFlags BranchModel::flags(const QModelIndex &index) const
|
|||||||
|
|
||||||
void BranchModel::clear()
|
void BranchModel::clear()
|
||||||
{
|
{
|
||||||
foreach (BranchNode *root, m_rootNode->children)
|
for (BranchNode *root : Utils::asConst(m_rootNode->children)) {
|
||||||
while (root->count())
|
while (root->count())
|
||||||
delete root->children.takeLast();
|
delete root->children.takeLast();
|
||||||
|
}
|
||||||
if (hasTags())
|
if (hasTags())
|
||||||
m_rootNode->children.takeLast();
|
m_rootNode->children.takeLast();
|
||||||
|
|
||||||
@@ -368,7 +371,7 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage
|
|||||||
|
|
||||||
m_workingDirectory = workingDirectory;
|
m_workingDirectory = workingDirectory;
|
||||||
const QStringList lines = output.split('\n');
|
const QStringList lines = output.split('\n');
|
||||||
foreach (const QString &l, lines)
|
for (const QString &l : lines)
|
||||||
parseOutputLine(l);
|
parseOutputLine(l);
|
||||||
|
|
||||||
if (m_currentBranch) {
|
if (m_currentBranch) {
|
||||||
@@ -558,8 +561,8 @@ bool BranchModel::branchIsMerged(const QModelIndex &idx)
|
|||||||
VcsOutputWindow::appendError(errorMessage);
|
VcsOutputWindow::appendError(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList lines = output.split('\n', QString::SkipEmptyParts);
|
const QStringList lines = output.split('\n', QString::SkipEmptyParts);
|
||||||
foreach (const QString &l, lines) {
|
for (const QString &l : lines) {
|
||||||
QString currentBranch = l.mid(2); // remove first letters (those are either
|
QString currentBranch = l.mid(2); // remove first letters (those are either
|
||||||
// " " or "* " depending on whether it is
|
// " " or "* " depending on whether it is
|
||||||
// the currently checked out branch or not)
|
// the currently checked out branch or not)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "commitdata.h"
|
#include "commitdata.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -164,7 +165,7 @@ bool CommitData::parseFilesFromStatus(const QString &output)
|
|||||||
{
|
{
|
||||||
const QStringList lines = output.split('\n');
|
const QStringList lines = output.split('\n');
|
||||||
|
|
||||||
foreach (const QString &line, lines) {
|
for (const QString &line : lines) {
|
||||||
if (line.isEmpty())
|
if (line.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -187,7 +188,7 @@ bool CommitData::parseFilesFromStatus(const QString &output)
|
|||||||
QStringList CommitData::filterFiles(const FileStates &state) const
|
QStringList CommitData::filterFiles(const FileStates &state) const
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
foreach (const StateFilePair &p, files) {
|
for (const StateFilePair &p : files) {
|
||||||
if (state == (p.first & ~(UnmergedFile | UnmergedUs | UnmergedThem)))
|
if (state == (p.first & ~(UnmergedFile | UnmergedUs | UnmergedThem)))
|
||||||
result.append(p.second);
|
result.append(p.second);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ void BranchComboBox::init(const QString &repository)
|
|||||||
m_repository, { "--format=%(refname)", branchPrefix }, &output)) {
|
m_repository, { "--format=%(refname)", branchPrefix }, &output)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QStringList branches = output.trimmed().split('\n');
|
const QStringList branches = output.trimmed().split('\n');
|
||||||
foreach (const QString &ref, branches) {
|
for (const QString &ref : branches) {
|
||||||
const QString branch = ref.mid(branchPrefix.size());
|
const QString branch = ref.mid(branchPrefix.size());
|
||||||
addItem(branch);
|
addItem(branch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
#include <coreplugin/progressmanager/futureprogress.h>
|
#include <coreplugin/progressmanager/futureprogress.h>
|
||||||
#include <vcsbase/vcsoutputwindow.h>
|
#include <vcsbase/vcsoutputwindow.h>
|
||||||
|
|
||||||
|
#include <utils/asconst.h>
|
||||||
#include <utils/synchronousprocess.h>
|
#include <utils/synchronousprocess.h>
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
@@ -106,7 +108,7 @@ QString GerritPatchSet::approvalsToHtml() const
|
|||||||
QString result;
|
QString result;
|
||||||
QTextStream str(&result);
|
QTextStream str(&result);
|
||||||
QString lastType;
|
QString lastType;
|
||||||
foreach (const GerritApproval &a, approvals) {
|
for (const GerritApproval &a : approvals) {
|
||||||
if (a.type != lastType) {
|
if (a.type != lastType) {
|
||||||
if (!lastType.isEmpty())
|
if (!lastType.isEmpty())
|
||||||
str << "</tr>\n";
|
str << "</tr>\n";
|
||||||
@@ -147,7 +149,7 @@ QString GerritPatchSet::approvalsColumn() const
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
TypeReviewMap reviews; // Sort approvals into a map by type character
|
TypeReviewMap reviews; // Sort approvals into a map by type character
|
||||||
foreach (const GerritApproval &a, approvals) {
|
for (const GerritApproval &a : approvals) {
|
||||||
if (a.type != "STGN") { // Qt-Project specific: Ignore "STGN" (Staged)
|
if (a.type != "STGN") { // Qt-Project specific: Ignore "STGN" (Staged)
|
||||||
const QChar typeChar = a.type.at(0);
|
const QChar typeChar = a.type.at(0);
|
||||||
TypeReviewMapIterator it = reviews.find(typeChar);
|
TypeReviewMapIterator it = reviews.find(typeChar);
|
||||||
@@ -169,7 +171,7 @@ QString GerritPatchSet::approvalsColumn() const
|
|||||||
|
|
||||||
bool GerritPatchSet::hasApproval(const QString &userName) const
|
bool GerritPatchSet::hasApproval(const QString &userName) const
|
||||||
{
|
{
|
||||||
foreach (const GerritApproval &a, approvals)
|
for (const GerritApproval &a : approvals)
|
||||||
if (a.reviewer == userName)
|
if (a.reviewer == userName)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
@@ -178,7 +180,7 @@ bool GerritPatchSet::hasApproval(const QString &userName) const
|
|||||||
int GerritPatchSet::approvalLevel() const
|
int GerritPatchSet::approvalLevel() const
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
foreach (const GerritApproval &a, approvals)
|
for (const GerritApproval &a : approvals)
|
||||||
applyApproval(a.approval, &value);
|
applyApproval(a.approval, &value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -189,7 +191,7 @@ QString GerritChange::filterString() const
|
|||||||
QString result = QString::number(number) + blank + title + blank
|
QString result = QString::number(number) + blank + title + blank
|
||||||
+ owner + blank + project + blank
|
+ owner + blank + project + blank
|
||||||
+ branch + blank + status;
|
+ branch + blank + status;
|
||||||
foreach (const GerritApproval &a, currentPatchSet.approvals) {
|
for (const GerritApproval &a : currentPatchSet.approvals) {
|
||||||
result += blank;
|
result += blank;
|
||||||
result += a.reviewer;
|
result += a.reviewer;
|
||||||
}
|
}
|
||||||
@@ -613,7 +615,7 @@ static bool parseOutput(const QSharedPointer<GerritParameters> ¶meters,
|
|||||||
result.clear();
|
result.clear();
|
||||||
result.reserve(lines.size());
|
result.reserve(lines.size());
|
||||||
|
|
||||||
foreach (const QByteArray &line, lines) {
|
for (const QByteArray &line : lines) {
|
||||||
if (line.isEmpty())
|
if (line.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
@@ -791,7 +793,7 @@ void GerritModel::queryFinished(const QByteArray &output)
|
|||||||
std::stable_sort(changes.begin(), changes.end(), gerritChangeLessThan);
|
std::stable_sort(changes.begin(), changes.end(), gerritChangeLessThan);
|
||||||
numberIndexHash.clear();
|
numberIndexHash.clear();
|
||||||
|
|
||||||
foreach (const GerritChangePtr &c, changes) {
|
for (const GerritChangePtr &c : Utils::asConst(changes)) {
|
||||||
// Avoid duplicate entries for example in the (unlikely)
|
// Avoid duplicate entries for example in the (unlikely)
|
||||||
// case people do self-reviews.
|
// case people do self-reviews.
|
||||||
if (!itemForNumber(c->number)) {
|
if (!itemForNumber(c->number)) {
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ void GerritPlugin::push(const QString &topLevel)
|
|||||||
|
|
||||||
QStringList options;
|
QStringList options;
|
||||||
const QStringList reviewers = m_reviewers.split(',', QString::SkipEmptyParts);
|
const QStringList reviewers = m_reviewers.split(',', QString::SkipEmptyParts);
|
||||||
foreach (const QString &reviewer, reviewers)
|
for (const QString &reviewer : reviewers)
|
||||||
options << "r=" + reviewer;
|
options << "r=" + reviewer;
|
||||||
|
|
||||||
if (!options.isEmpty())
|
if (!options.isEmpty())
|
||||||
@@ -412,8 +412,8 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
|||||||
// Check if remote from a working dir is the same as remote from patch
|
// Check if remote from a working dir is the same as remote from patch
|
||||||
QMap<QString, QString> remotesList = GitPlugin::client()->synchronousRemotesList(repository);
|
QMap<QString, QString> remotesList = GitPlugin::client()->synchronousRemotesList(repository);
|
||||||
if (!remotesList.isEmpty()) {
|
if (!remotesList.isEmpty()) {
|
||||||
QStringList remotes = remotesList.values();
|
const QStringList remotes = remotesList.values();
|
||||||
foreach (QString remote, remotes) {
|
for (QString remote : remotes) {
|
||||||
if (remote.endsWith(".git"))
|
if (remote.endsWith(".git"))
|
||||||
remote.chop(4);
|
remote.chop(4);
|
||||||
if (remote.contains(m_server->host) && remote.endsWith(change->project)) {
|
if (remote.contains(m_server->host) && remote.endsWith(change->project)) {
|
||||||
@@ -423,8 +423,8 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!verifiedRepository) {
|
if (!verifiedRepository) {
|
||||||
SubmoduleDataMap submodules = GitPlugin::client()->submoduleList(repository);
|
const SubmoduleDataMap submodules = GitPlugin::client()->submoduleList(repository);
|
||||||
foreach (const SubmoduleData &submoduleData, submodules) {
|
for (const SubmoduleData &submoduleData : submodules) {
|
||||||
QString remote = submoduleData.url;
|
QString remote = submoduleData.url;
|
||||||
if (remote.endsWith(".git"))
|
if (remote.endsWith(".git"))
|
||||||
remote.chop(4);
|
remote.chop(4);
|
||||||
@@ -501,7 +501,7 @@ QString GerritPlugin::findLocalRepository(QString project, const QString &branch
|
|||||||
if (!branchRegexp->isValid())
|
if (!branchRegexp->isValid())
|
||||||
branchRegexp.reset(); // Oops.
|
branchRegexp.reset(); // Oops.
|
||||||
}
|
}
|
||||||
foreach (const QString &repository, gitRepositories) {
|
for (const QString &repository : gitRepositories) {
|
||||||
const QString fileName = Utils::FileName::fromString(repository).fileName();
|
const QString fileName = Utils::FileName::fromString(repository).fileName();
|
||||||
if ((!branchRegexp.isNull() && branchRegexp->exactMatch(fileName))
|
if ((!branchRegexp.isNull() && branchRegexp->exactMatch(fileName))
|
||||||
|| fileName == project) {
|
|| fileName == project) {
|
||||||
|
|||||||
@@ -70,14 +70,14 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
const QString head = "/HEAD";
|
const QString head = "/HEAD";
|
||||||
QStringList refs = output.split('\n');
|
const QStringList refs = output.split('\n');
|
||||||
|
|
||||||
QString remoteTrackingBranch;
|
QString remoteTrackingBranch;
|
||||||
if (localBranch != "HEAD")
|
if (localBranch != "HEAD")
|
||||||
remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch);
|
remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch);
|
||||||
|
|
||||||
QString remoteBranch;
|
QString remoteBranch;
|
||||||
foreach (const QString &reference, refs) {
|
for (const QString &reference : refs) {
|
||||||
const QString ref = reference.trimmed();
|
const QString ref = reference.trimmed();
|
||||||
if (ref.contains(head) || ref.isEmpty())
|
if (ref.contains(head) || ref.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
@@ -104,7 +104,7 @@ void GerritPushDialog::initRemoteBranches()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QStringList refs = output.split("\n");
|
const QStringList refs = output.split("\n");
|
||||||
foreach (const QString &reference, refs) {
|
for (const QString &reference : refs) {
|
||||||
QStringList entries = reference.split('\t');
|
QStringList entries = reference.split('\t');
|
||||||
if (entries.count() < 2 || entries.first().endsWith(head))
|
if (entries.count() < 2 || entries.first().endsWith(head))
|
||||||
continue;
|
continue;
|
||||||
@@ -237,7 +237,7 @@ void GerritPushDialog::setRemoteBranches(bool includeOld)
|
|||||||
if (!m_remoteBranches.contains(remoteName)) {
|
if (!m_remoteBranches.contains(remoteName)) {
|
||||||
const QStringList remoteBranches =
|
const QStringList remoteBranches =
|
||||||
GitPlugin::client()->synchronousRepositoryBranches(remoteName, m_workingDir);
|
GitPlugin::client()->synchronousRepositoryBranches(remoteName, m_workingDir);
|
||||||
foreach (const QString &branch, remoteBranches)
|
for (const QString &branch : remoteBranches)
|
||||||
m_remoteBranches.insertMulti(remoteName, qMakePair(branch, QDate()));
|
m_remoteBranches.insertMulti(remoteName, qMakePair(branch, QDate()));
|
||||||
if (remoteBranches.isEmpty()) {
|
if (remoteBranches.isEmpty()) {
|
||||||
m_ui->targetBranchComboBox->setEditable(true);
|
m_ui->targetBranchComboBox->setEditable(true);
|
||||||
@@ -250,7 +250,8 @@ void GerritPushDialog::setRemoteBranches(bool includeOld)
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
bool excluded = false;
|
bool excluded = false;
|
||||||
foreach (const BranchDate &bd, m_remoteBranches.values(remoteName)) {
|
const QList<BranchDate> remoteBranches = m_remoteBranches.values(remoteName);
|
||||||
|
for (const BranchDate &bd : remoteBranches) {
|
||||||
const bool isSuggested = bd.first == m_suggestedRemoteBranch;
|
const bool isSuggested = bd.first == m_suggestedRemoteBranch;
|
||||||
if (includeOld || isSuggested || !bd.second.isValid()
|
if (includeOld || isSuggested || !bd.second.isValid()
|
||||||
|| bd.second.daysTo(QDate::currentDate()) <= Git::Constants::OBSOLETE_COMMIT_AGE_IN_DAYS) {
|
|| bd.second.daysTo(QDate::currentDate()) <= Git::Constants::OBSOLETE_COMMIT_AGE_IN_DAYS) {
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
include(../../qtcreatorplugin.pri)
|
include(../../qtcreatorplugin.pri)
|
||||||
|
|
||||||
|
DEFINES += QT_NO_FOREACH
|
||||||
|
|
||||||
HEADERS += gitplugin.h \
|
HEADERS += gitplugin.h \
|
||||||
gitconstants.h \
|
gitconstants.h \
|
||||||
gitclient.h \
|
gitclient.h \
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ QtcPlugin {
|
|||||||
Depends { name: "VcsBase" }
|
Depends { name: "VcsBase" }
|
||||||
Depends { name: "DiffEditor" }
|
Depends { name: "DiffEditor" }
|
||||||
|
|
||||||
|
cpp.defines: base.concat(["QT_NO_FOREACH"])
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
"annotationhighlighter.cpp",
|
"annotationhighlighter.cpp",
|
||||||
"annotationhighlighter.h",
|
"annotationhighlighter.h",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/asconst.h>
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
@@ -158,7 +159,7 @@ void BaseController::runCommand(const QList<QStringList> &args, QTextCodec *code
|
|||||||
connect(m_command.data(), &VcsCommand::finished, this, &BaseController::reloadFinished);
|
connect(m_command.data(), &VcsCommand::finished, this, &BaseController::reloadFinished);
|
||||||
m_command->addFlags(diffExecutionFlags());
|
m_command->addFlags(diffExecutionFlags());
|
||||||
|
|
||||||
foreach (const QStringList &arg, args) {
|
for (const QStringList &arg : args) {
|
||||||
QTC_ASSERT(!arg.isEmpty(), continue);
|
QTC_ASSERT(!arg.isEmpty(), continue);
|
||||||
|
|
||||||
m_command->addJob(GitPlugin::client()->vcsBinary(), arg, GitPlugin::client()->vcsTimeoutS());
|
m_command->addJob(GitPlugin::client()->vcsBinary(), arg, GitPlugin::client()->vcsTimeoutS());
|
||||||
@@ -1002,7 +1003,8 @@ QStringList GitClient::setupCheckoutArguments(const QString &workingDirectory,
|
|||||||
QString remoteBranch;
|
QString remoteBranch;
|
||||||
const QString head("/HEAD");
|
const QString head("/HEAD");
|
||||||
|
|
||||||
foreach (const QString &singleRef, output.split('\n')) {
|
const QStringList refs = output.split('\n');
|
||||||
|
for (const QString &singleRef : refs) {
|
||||||
if (singleRef.startsWith(refSha)) {
|
if (singleRef.startsWith(refSha)) {
|
||||||
// branch name might be origin/foo/HEAD
|
// branch name might be origin/foo/HEAD
|
||||||
if (!singleRef.endsWith(head) || singleRef.count('/') > 1) {
|
if (!singleRef.endsWith(head) || singleRef.count('/') > 1) {
|
||||||
@@ -1343,7 +1345,7 @@ QString GitClient::synchronousTopic(const QString &workingDirectory) const
|
|||||||
const QString dereference("^{}");
|
const QString dereference("^{}");
|
||||||
QString remoteBranch;
|
QString remoteBranch;
|
||||||
|
|
||||||
foreach (const QString &ref, references) {
|
for (const QString &ref : Utils::asConst(references)) {
|
||||||
int derefInd = ref.indexOf(dereference);
|
int derefInd = ref.indexOf(dereference);
|
||||||
if (ref.startsWith(tagStart))
|
if (ref.startsWith(tagStart))
|
||||||
return ref.mid(tagStart.size(), (derefInd == -1) ? -1 : derefInd - tagStart.size());
|
return ref.mid(tagStart.size(), (derefInd == -1) ? -1 : derefInd - tagStart.size());
|
||||||
@@ -1406,7 +1408,7 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const
|
|||||||
QStringList parents;
|
QStringList parents;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
synchronousParentRevisions(workingDirectory, revision, &parents, &errorMessage);
|
synchronousParentRevisions(workingDirectory, revision, &parents, &errorMessage);
|
||||||
foreach (const QString &p, parents) {
|
for (const QString &p : Utils::asConst(parents)) {
|
||||||
const SynchronousProcessResponse resp2 = vcsFullySynchronousExec(
|
const SynchronousProcessResponse resp2 = vcsFullySynchronousExec(
|
||||||
workingDirectory, { "describe", "--tags", "--abbrev=0", p }, silentFlags);
|
workingDirectory, { "describe", "--tags", "--abbrev=0", p }, silentFlags);
|
||||||
QString pf = resp2.stdOut();
|
QString pf = resp2.stdOut();
|
||||||
@@ -1553,7 +1555,7 @@ bool GitClient::stashNameFromMessage(const QString &workingDirectory,
|
|||||||
QList<Stash> stashes;
|
QList<Stash> stashes;
|
||||||
if (!synchronousStashList(workingDirectory, &stashes, errorMessage))
|
if (!synchronousStashList(workingDirectory, &stashes, errorMessage))
|
||||||
return false;
|
return false;
|
||||||
foreach (const Stash &s, stashes) {
|
for (const Stash &s : Utils::asConst(stashes)) {
|
||||||
if (s.message == message) {
|
if (s.message == message) {
|
||||||
*name = s.name;
|
*name = s.name;
|
||||||
return true;
|
return true;
|
||||||
@@ -1640,9 +1642,9 @@ QMap<QString,QString> GitClient::synchronousRemotesList(const QString &workingDi
|
|||||||
msgCannotRun(error, errorMessage);
|
msgCannotRun(error, errorMessage);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
QStringList remotes = output.split("\n");
|
|
||||||
|
|
||||||
foreach (const QString &remote, remotes) {
|
const QStringList remotes = output.split("\n");
|
||||||
|
for (const QString &remote : remotes) {
|
||||||
if (!remote.endsWith(" (push)"))
|
if (!remote.endsWith(" (push)"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1682,10 +1684,9 @@ SubmoduleDataMap GitClient::submoduleList(const QString &workingDirectory) const
|
|||||||
if (cachedSubmoduleData.contains(workingDirectory))
|
if (cachedSubmoduleData.contains(workingDirectory))
|
||||||
return cachedSubmoduleData.value(workingDirectory);
|
return cachedSubmoduleData.value(workingDirectory);
|
||||||
|
|
||||||
QStringList allConfigs = readConfigValue(workingDirectory, "-l")
|
const QStringList allConfigs = readConfigValue(workingDirectory, "-l").split('\n');
|
||||||
.split('\n');
|
|
||||||
const QString submoduleLineStart = "submodule.";
|
const QString submoduleLineStart = "submodule.";
|
||||||
foreach (const QString &configLine, allConfigs) {
|
for (const QString &configLine : allConfigs) {
|
||||||
if (!configLine.startsWith(submoduleLineStart))
|
if (!configLine.startsWith(submoduleLineStart))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1712,7 +1713,8 @@ SubmoduleDataMap GitClient::submoduleList(const QString &workingDirectory) const
|
|||||||
if (!result.isEmpty()) {
|
if (!result.isEmpty()) {
|
||||||
QSettings gitmodulesFile(gitmodulesFileName, QSettings::IniFormat);
|
QSettings gitmodulesFile(gitmodulesFileName, QSettings::IniFormat);
|
||||||
|
|
||||||
foreach (const QString &submoduleName, result.keys()) {
|
const QList<QString> submodules = result.keys();
|
||||||
|
for (const QString &submoduleName : submodules) {
|
||||||
gitmodulesFile.beginGroup("submodule \"" + submoduleName + '"');
|
gitmodulesFile.beginGroup("submodule \"" + submoduleName + '"');
|
||||||
const QString path = gitmodulesFile.value("path").toString();
|
const QString path = gitmodulesFile.value("path").toString();
|
||||||
if (path.isEmpty()) { // invalid submodule entry in config
|
if (path.isEmpty()) { // invalid submodule entry in config
|
||||||
@@ -1782,8 +1784,8 @@ bool GitClient::synchronousCleanList(const QString &workingDirectory, const QStr
|
|||||||
bool res = cleanList(workingDirectory, modulePath, "-df", files, errorMessage);
|
bool res = cleanList(workingDirectory, modulePath, "-df", files, errorMessage);
|
||||||
res &= cleanList(workingDirectory, modulePath, "-dXf", ignoredFiles, errorMessage);
|
res &= cleanList(workingDirectory, modulePath, "-dXf", ignoredFiles, errorMessage);
|
||||||
|
|
||||||
SubmoduleDataMap submodules = submoduleList(workingDirectory + '/' + modulePath);
|
const SubmoduleDataMap submodules = submoduleList(workingDirectory + '/' + modulePath);
|
||||||
foreach (const SubmoduleData &submodule, submodules) {
|
for (const SubmoduleData &submodule : submodules) {
|
||||||
if (submodule.ignore != "all"
|
if (submodule.ignore != "all"
|
||||||
&& submodule.ignore != "dirty") {
|
&& submodule.ignore != "dirty") {
|
||||||
const QString submodulePath = modulePath.isEmpty() ? submodule.dir
|
const QString submodulePath = modulePath.isEmpty() ? submodule.dir
|
||||||
@@ -1872,12 +1874,12 @@ void GitClient::updateSubmodulesIfNeeded(const QString &workingDirectory, bool p
|
|||||||
if (!m_updatedSubmodules.isEmpty() || submoduleList(workingDirectory).isEmpty())
|
if (!m_updatedSubmodules.isEmpty() || submoduleList(workingDirectory).isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QStringList submoduleStatus = synchronousSubmoduleStatus(workingDirectory);
|
const QStringList submoduleStatus = synchronousSubmoduleStatus(workingDirectory);
|
||||||
if (submoduleStatus.isEmpty())
|
if (submoduleStatus.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool updateNeeded = false;
|
bool updateNeeded = false;
|
||||||
foreach (const QString &status, submoduleStatus) {
|
for (const QString &status : submoduleStatus) {
|
||||||
if (status.startsWith('+')) {
|
if (status.startsWith('+')) {
|
||||||
updateNeeded = true;
|
updateNeeded = true;
|
||||||
break;
|
break;
|
||||||
@@ -1892,7 +1894,7 @@ void GitClient::updateSubmodulesIfNeeded(const QString &workingDirectory, bool p
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString &statusLine, submoduleStatus) {
|
for (const QString &statusLine : submoduleStatus) {
|
||||||
// stash only for lines starting with +
|
// stash only for lines starting with +
|
||||||
// because only they would be updated
|
// because only they would be updated
|
||||||
if (!statusLine.startsWith('+'))
|
if (!statusLine.startsWith('+'))
|
||||||
@@ -1918,7 +1920,7 @@ void GitClient::updateSubmodulesIfNeeded(const QString &workingDirectory, bool p
|
|||||||
|
|
||||||
void GitClient::finishSubmoduleUpdate()
|
void GitClient::finishSubmoduleUpdate()
|
||||||
{
|
{
|
||||||
foreach (const QString &submoduleDir, m_updatedSubmodules)
|
for (const QString &submoduleDir : Utils::asConst(m_updatedSubmodules))
|
||||||
endStashScope(submoduleDir);
|
endStashScope(submoduleDir);
|
||||||
m_updatedSubmodules.clear();
|
m_updatedSubmodules.clear();
|
||||||
}
|
}
|
||||||
@@ -2112,7 +2114,8 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
|
|||||||
// split "82bfad2f51d34e98b18982211c82220b8db049b<tab>refs/heads/master"
|
// split "82bfad2f51d34e98b18982211c82220b8db049b<tab>refs/heads/master"
|
||||||
bool headFound = false;
|
bool headFound = false;
|
||||||
bool branchFound = false;
|
bool branchFound = false;
|
||||||
foreach (const QString &line, resp.stdOut().split('\n')) {
|
const QStringList lines = resp.stdOut().split('\n');
|
||||||
|
for (const QString &line : lines) {
|
||||||
if (line.endsWith("\tHEAD")) {
|
if (line.endsWith("\tHEAD")) {
|
||||||
QTC_CHECK(headSha.isNull());
|
QTC_CHECK(headSha.isNull());
|
||||||
headSha = line.left(line.indexOf('\t'));
|
headSha = line.left(line.indexOf('\t'));
|
||||||
@@ -2988,7 +2991,8 @@ bool GitClient::synchronousStashList(const QString &workingDirectory, QList<Stas
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Stash stash;
|
Stash stash;
|
||||||
foreach (const QString &line, splitLines(resp.stdOut())) {
|
const QStringList lines = splitLines(resp.stdOut());
|
||||||
|
for (const QString &line : lines) {
|
||||||
if (stash.parseStashLine(line))
|
if (stash.parseStashLine(line))
|
||||||
stashes->push_back(stash);
|
stashes->push_back(stash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <vcsbase/vcscommand.h>
|
#include <vcsbase/vcscommand.h>
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
|
|
||||||
|
#include <utils/asconst.h>
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/filesearch.h>
|
#include <utils/filesearch.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
@@ -119,7 +120,7 @@ public:
|
|||||||
QRegularExpressionMatch regexpMatch = regexp.match(line);
|
QRegularExpressionMatch regexpMatch = regexp.match(line);
|
||||||
single.regexpCapturedTexts = regexpMatch.capturedTexts();
|
single.regexpCapturedTexts = regexpMatch.capturedTexts();
|
||||||
}
|
}
|
||||||
foreach (auto match, matches) {
|
for (auto match : Utils::asConst(matches)) {
|
||||||
single.matchStart = match.first;
|
single.matchStart = match.first;
|
||||||
single.matchLength = match.second;
|
single.matchLength = match.second;
|
||||||
resultList->append(single);
|
resultList->append(single);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
|
||||||
|
#include <utils/asconst.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include "githighlighters.h"
|
#include "githighlighters.h"
|
||||||
@@ -130,7 +131,7 @@ void GitRebaseHighlighter::highlightBlock(const QString &text)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const RebaseAction &action, m_actions) {
|
for (const RebaseAction &action : Utils::asConst(m_actions)) {
|
||||||
if (action.exp.indexIn(text) != -1) {
|
if (action.exp.indexIn(text) != -1) {
|
||||||
const int len = action.exp.matchedLength();
|
const int len = action.exp.matchedLength();
|
||||||
setFormat(0, len, formatForCategory(action.formatCategory));
|
setFormat(0, len, formatForCategory(action.formatCategory));
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
|
||||||
#include <coreplugin/messagebox.h>
|
#include <coreplugin/messagebox.h>
|
||||||
|
#include <utils/asconst.h>
|
||||||
#include <utils/mimetypes/mimedatabase.h>
|
#include <utils/mimetypes/mimedatabase.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/parameteraction.h>
|
#include <utils/parameteraction.h>
|
||||||
@@ -1336,15 +1337,15 @@ void GitPlugin::updateActions(VcsBasePlugin::ActionState as)
|
|||||||
// Note: This menu is visible if there is no repository. Only
|
// Note: This menu is visible if there is no repository. Only
|
||||||
// 'Create Repository'/'Show' actions should be available.
|
// 'Create Repository'/'Show' actions should be available.
|
||||||
const QString fileName = state.currentFileName();
|
const QString fileName = state.currentFileName();
|
||||||
foreach (ParameterAction *fileAction, m_fileActions)
|
for (ParameterAction *fileAction : Utils::asConst(m_fileActions))
|
||||||
fileAction->setParameter(fileName);
|
fileAction->setParameter(fileName);
|
||||||
// If the current file looks like a patch, offer to apply
|
// If the current file looks like a patch, offer to apply
|
||||||
m_applyCurrentFilePatchAction->setParameter(state.currentPatchFileDisplayName());
|
m_applyCurrentFilePatchAction->setParameter(state.currentPatchFileDisplayName());
|
||||||
const QString projectName = state.currentProjectName();
|
const QString projectName = state.currentProjectName();
|
||||||
foreach (ParameterAction *projectAction, m_projectActions)
|
for (ParameterAction *projectAction : Utils::asConst(m_projectActions))
|
||||||
projectAction->setParameter(projectName);
|
projectAction->setParameter(projectName);
|
||||||
|
|
||||||
foreach (QAction *repositoryAction, m_repositoryActions)
|
for (QAction *repositoryAction : Utils::asConst(m_repositoryActions))
|
||||||
repositoryAction->setEnabled(repositoryEnabled);
|
repositoryAction->setEnabled(repositoryEnabled);
|
||||||
|
|
||||||
m_submoduleUpdateAction->setVisible(repositoryEnabled
|
m_submoduleUpdateAction->setVisible(repositoryEnabled
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ void GitSubmitEditor::slotDiffSelected(const QList<int> &rows)
|
|||||||
QStringList unmergedFiles;
|
QStringList unmergedFiles;
|
||||||
QStringList unstagedFiles;
|
QStringList unstagedFiles;
|
||||||
QStringList stagedFiles;
|
QStringList stagedFiles;
|
||||||
foreach (int row, rows) {
|
for (int row : rows) {
|
||||||
const QString fileName = m_model->file(row);
|
const QString fileName = m_model->file(row);
|
||||||
const FileStates state = static_cast<FileStates>(m_model->extraData(row).toInt());
|
const FileStates state = static_cast<FileStates>(m_model->extraData(row).toInt());
|
||||||
if (state & UnmergedFile) {
|
if (state & UnmergedFile) {
|
||||||
|
|||||||
@@ -161,7 +161,8 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
|
|||||||
QString output;
|
QString output;
|
||||||
if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput))
|
if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput))
|
||||||
return false;
|
return false;
|
||||||
foreach (const QString &line, output.split('\n')) {
|
const QStringList lines = output.split('\n');
|
||||||
|
for (const QString &line : lines) {
|
||||||
const int colonPos = line.indexOf(':');
|
const int colonPos = line.indexOf(':');
|
||||||
if (colonPos != -1) {
|
if (colonPos != -1) {
|
||||||
QList<QStandardItem *> row;
|
QList<QStandardItem *> row;
|
||||||
|
|||||||
@@ -186,7 +186,8 @@ bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage
|
|||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_remotes.clear();
|
m_remotes.clear();
|
||||||
foreach (const QString &remoteName, remotesList.keys()) {
|
const QList<QString> remotes = remotesList.keys();
|
||||||
|
for (const QString &remoteName : remotes) {
|
||||||
Remote newRemote;
|
Remote newRemote;
|
||||||
newRemote.name = remoteName;
|
newRemote.name = remoteName;
|
||||||
newRemote.url = remotesList.value(remoteName);
|
newRemote.url = remotesList.value(remoteName);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ void StashModel::setStashes(const QList<Stash> &stashes)
|
|||||||
m_stashes = stashes;
|
m_stashes = stashes;
|
||||||
if (const int rows = rowCount())
|
if (const int rows = rowCount())
|
||||||
removeRows(0, rows);
|
removeRows(0, rows);
|
||||||
foreach (const Stash &s, stashes)
|
for (const Stash &s : stashes)
|
||||||
appendRow(stashModelRowItems(s));
|
appendRow(stashModelRowItems(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +354,8 @@ int StashDialog::currentRow() const
|
|||||||
QList<int> StashDialog::selectedRows() const
|
QList<int> StashDialog::selectedRows() const
|
||||||
{
|
{
|
||||||
QList<int> rc;
|
QList<int> rc;
|
||||||
foreach (const QModelIndex &proxyIndex, ui->stashView->selectionModel()->selectedRows()) {
|
const QModelIndexList rows = ui->stashView->selectionModel()->selectedRows();
|
||||||
|
for (const QModelIndex &proxyIndex : rows) {
|
||||||
const QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
const QModelIndex index = m_proxyModel->mapToSource(proxyIndex);
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
rc.push_back(index.row());
|
rc.push_back(index.row());
|
||||||
|
|||||||
Reference in New Issue
Block a user