Git: De-noise

* Remove QLatin1{String|Char} where possible
* Use initializer lists for QStringList

Change-Id: I8479f87f4fc909b5d74d854956885564209538e4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2016-07-21 00:28:18 +03:00
committed by Orgad Shaneh
parent 539e33da02
commit 516161c875
31 changed files with 312 additions and 353 deletions

View File

@@ -25,15 +25,12 @@
#include "annotationhighlighter.h"
#include <QDebug>
namespace Git {
namespace Internal {
GitAnnotationHighlighter::GitAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document) :
VcsBase::BaseAnnotationHighlighter(changeNumbers, document),
m_blank(QLatin1Char(' '))
VcsBase::BaseAnnotationHighlighter(changeNumbers, document)
{
}

View File

@@ -41,7 +41,7 @@ public:
private:
QString changeNumber(const QString &block) const override;
const QChar m_blank;
const QChar m_blank = ' ';
};
} // namespace Internal

View File

@@ -46,20 +46,20 @@ class BranchNameValidator : public QValidator
public:
BranchNameValidator(const QStringList &localBranches, QObject *parent = 0) :
QValidator(parent),
m_invalidChars(QLatin1String(
"\\s" // no whitespace
"|~" // no "~"
"|\\^" // no "^"
"|\\[" // no "["
"|\\.\\." // no ".."
"|/\\." // no slashdot
"|:" // no ":"
"|@\\{" // no "@{" sequence
"|\\\\" // no backslash
"|//" // no double slash
"|^[/-]" // no leading slash or dash
"|\"" // no quotes
)),
m_invalidChars(
"\\s" // no whitespace
"|~" // no "~"
"|\\^" // no "^"
"|\\[" // no "["
"|\\.\\." // no ".."
"|/\\." // no slashdot
"|:" // no ":"
"|@\\{" // no "@{" sequence
"|\\\\" // no backslash
"|//" // no double slash
"|^[/-]" // no leading slash or dash
"|\"" // no quotes
),
m_localBranches(localBranches)
{
}
@@ -70,17 +70,17 @@ public:
{
Q_UNUSED(pos)
input.replace(m_invalidChars, QLatin1String("_"));
input.replace(m_invalidChars, "_");
// "Intermediate" patterns, may change to Acceptable when user edits further:
if (input.endsWith(QLatin1String(".lock"))) //..may not end with ".lock"
if (input.endsWith(".lock")) //..may not end with ".lock"
return Intermediate;
if (input.endsWith(QLatin1Char('.'))) // no dot at the end (but allowed in the middle)
if (input.endsWith('.')) // no dot at the end (but allowed in the middle)
return Intermediate;
if (input.endsWith(QLatin1Char('/'))) // no slash at the end (but allowed in the middle)
if (input.endsWith('/')) // no slash at the end (but allowed in the middle)
return Intermediate;
if (m_localBranches.contains(input, Utils::HostOsInfo::isWindowsHost()

View File

@@ -172,7 +172,7 @@ void BranchDialog::add()
QString suggestedName;
if (!isTag) {
QString suggestedNameBase;
suggestedNameBase = trackedBranch.mid(trackedBranch.lastIndexOf(QLatin1Char('/')) + 1);
suggestedNameBase = trackedBranch.mid(trackedBranch.lastIndexOf('/') + 1);
suggestedName = suggestedNameBase;
int i = 2;
while (localNames.contains(suggestedName)) {
@@ -208,7 +208,7 @@ void BranchDialog::checkout()
const QString currentBranch = m_model->fullName(m_model->currentBranch());
const QString nextBranch = m_model->fullName(idx);
const QString popMessageStart = QCoreApplication::applicationName() +
QLatin1Char(' ') + nextBranch + QLatin1String("-AutoStash ");
' ' + nextBranch + "-AutoStash ";
BranchCheckoutDialog branchCheckoutDialog(this, currentBranch, nextBranch);
GitClient *client = GitPlugin::client();
@@ -232,12 +232,10 @@ void BranchDialog::checkout()
} else if (branchCheckoutDialog.exec() == QDialog::Accepted) {
if (branchCheckoutDialog.makeStashOfCurrentBranch()) {
if (client->synchronousStash(m_repository,
currentBranch + QLatin1String("-AutoStash")).isEmpty()) {
if (client->synchronousStash(m_repository, currentBranch + "-AutoStash").isEmpty())
return;
}
} else if (branchCheckoutDialog.moveLocalChangesToNextBranch()) {
if (!client->beginStashScope(m_repository, QLatin1String("Checkout"), NoPrompt))
if (!client->beginStashScope(m_repository, "Checkout", NoPrompt))
return;
} else if (branchCheckoutDialog.discardLocalChanges()) {
if (!client->synchronousReset(m_repository))
@@ -351,7 +349,7 @@ void BranchDialog::reset()
if (QMessageBox::question(this, tr("Git Reset"), tr("Hard reset branch \"%1\" to \"%2\"?")
.arg(currentName).arg(branchName),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
GitPlugin::client()->reset(m_repository, QLatin1String("--hard"), branchName);
GitPlugin::client()->reset(m_repository, "--hard", branchName);
}
}
@@ -374,7 +372,7 @@ void BranchDialog::merge()
return;
allowFastForward = (chosen == fastForward);
}
if (client->beginStashScope(m_repository, QLatin1String("merge"), AllowUnstashed))
if (client->beginStashScope(m_repository, "merge", AllowUnstashed))
client->synchronousMerge(m_repository, branch, allowFastForward);
}
@@ -387,7 +385,7 @@ void BranchDialog::rebase()
const QString baseBranch = m_model->fullName(idx, true);
GitClient *client = GitPlugin::client();
if (client->beginStashScope(m_repository, QLatin1String("rebase")))
if (client->beginStashScope(m_repository, "rebase"))
client->rebase(m_repository, baseBranch);
}

View File

@@ -54,7 +54,7 @@ class BranchNode
public:
BranchNode() :
parent(0),
name(QLatin1String("<ROOT>"))
name("<ROOT>")
{ }
BranchNode(const QString &n, const QString &s = QString(), const QString &t = QString(),
@@ -172,7 +172,7 @@ public:
}
return names;
}
return QStringList(fullName().join(QLatin1Char('/')));
return QStringList(fullName().join('/'));
}
int rowOf(BranchNode *node)
@@ -202,8 +202,8 @@ BranchModel::BranchModel(GitClient *client, QObject *parent) :
QTC_CHECK(m_client);
// Abuse the sha field for ref prefix
m_rootNode->append(new BranchNode(tr("Local Branches"), QLatin1String("refs/heads")));
m_rootNode->append(new BranchNode(tr("Remote Branches"), QLatin1String("refs/remotes")));
m_rootNode->append(new BranchNode(tr("Local Branches"), "refs/heads"));
m_rootNode->append(new BranchNode(tr("Remote Branches"), "refs/remotes"));
}
BranchModel::~BranchModel()
@@ -260,7 +260,7 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
case 0: {
res = node->name;
if (!node->tracking.isEmpty())
res += QLatin1String(" [") + node->tracking + QLatin1Char(']');
res += " [" + node->tracking + ']';
break;
}
case 1:
@@ -316,9 +316,7 @@ bool BranchModel::setData(const QModelIndex &index, const QVariant &value, int r
QString output;
QString errorMessage;
if (!m_client->synchronousBranchCmd(m_workingDirectory,
QStringList() << QLatin1String("-m")
<< oldFullName.last()
<< newFullName.last(),
{ "-m", oldFullName.last(), newFullName.last() },
&output, &errorMessage)) {
node->name = oldFullName.last();
VcsOutputWindow::appendError(errorMessage);
@@ -362,15 +360,14 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage
}
m_currentSha = m_client->synchronousTopRevision(workingDirectory);
QStringList args;
args << QLatin1String("--format=%(objectname)\t%(refname)\t%(upstream:short)\t"
"%(*objectname)\t%(committerdate:raw)\t%(*committerdate:raw)");
const QStringList args = { "--format=%(objectname)\t%(refname)\t%(upstream:short)\t"
"%(*objectname)\t%(committerdate:raw)\t%(*committerdate:raw)" };
QString output;
if (!m_client->synchronousForEachRefCmd(workingDirectory, args, &output, errorMessage))
VcsOutputWindow::appendError(*errorMessage);
m_workingDirectory = workingDirectory;
const QStringList lines = output.split(QLatin1Char('\n'));
const QStringList lines = output.split('\n');
foreach (const QString &l, lines)
parseOutputLine(l);
@@ -403,8 +400,7 @@ void BranchModel::renameBranch(const QString &oldName, const QString &newName)
{
QString errorMessage;
QString output;
if (!m_client->synchronousBranchCmd(m_workingDirectory,
QStringList() << QLatin1String("-m") << oldName << newName,
if (!m_client->synchronousBranchCmd(m_workingDirectory, { "-m", oldName, newName },
&output, &errorMessage))
VcsOutputWindow::appendError(errorMessage);
else
@@ -415,11 +411,10 @@ void BranchModel::renameTag(const QString &oldName, const QString &newName)
{
QString errorMessage;
QString output;
if (!m_client->synchronousTagCmd(m_workingDirectory, QStringList() << newName << oldName,
if (!m_client->synchronousTagCmd(m_workingDirectory, { newName, oldName },
&output, &errorMessage)
|| !m_client->synchronousTagCmd(m_workingDirectory,
QStringList() << QLatin1String("-d") << oldName,
&output, &errorMessage)) {
|| !m_client->synchronousTagCmd(m_workingDirectory, { "-d", oldName },
&output, &errorMessage)) {
VcsOutputWindow::appendError(errorMessage);
} else {
refresh(m_workingDirectory, &errorMessage);
@@ -451,7 +446,7 @@ QString BranchModel::fullName(const QModelIndex &idx, bool includePrefix) const
if (!node || !node->isLeaf())
return QString();
QStringList path = node->fullName(includePrefix);
return path.join(QLatin1Char('/'));
return path.join('/');
}
QStringList BranchModel::localBranchNames() const
@@ -514,10 +509,8 @@ void BranchModel::removeBranch(const QModelIndex &idx)
QString errorMessage;
QString output;
QStringList args;
args << QLatin1String("-D") << branch;
if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage)) {
if (!m_client->synchronousBranchCmd(m_workingDirectory, { "-D", branch }, &output, &errorMessage)) {
VcsOutputWindow::appendError(errorMessage);
return;
}
@@ -532,10 +525,8 @@ void BranchModel::removeTag(const QModelIndex &idx)
QString errorMessage;
QString output;
QStringList args;
args << QLatin1String("-d") << tag;
if (!m_client->synchronousTagCmd(m_workingDirectory, args, &output, &errorMessage)) {
if (!m_client->synchronousTagCmd(m_workingDirectory, { "-d", tag }, &output, &errorMessage)) {
VcsOutputWindow::appendError(errorMessage);
return;
}
@@ -561,13 +552,13 @@ bool BranchModel::branchIsMerged(const QModelIndex &idx)
QString errorMessage;
QString output;
QStringList args;
args << QLatin1String("-a") << QLatin1String("--contains") << sha(idx);
if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage))
if (!m_client->synchronousBranchCmd(m_workingDirectory, { "-a", "--contains", sha(idx) },
&output, &errorMessage)) {
VcsOutputWindow::appendError(errorMessage);
}
QStringList lines = output.split(QLatin1Char('\n'), QString::SkipEmptyParts);
QStringList lines = output.split('\n', QString::SkipEmptyParts);
foreach (const QString &l, lines) {
QString currentBranch = l.mid(2); // remove first letters (those are either
// " " or "* " depending on whether it is
@@ -600,9 +591,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
QString errorMessage;
QDateTime branchDateTime;
QStringList args;
args << (track ? QLatin1String("--track") : QLatin1String("--no-track"));
args << name;
QStringList args = { QLatin1String(track ? "--track" : "--no-track"), name };
if (!fullTrackedBranch.isEmpty()) {
args << fullTrackedBranch;
startSha = sha(startPoint);
@@ -625,7 +614,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
}
BranchNode *local = m_rootNode->children.at(LocalBranches);
const int slash = name.indexOf(QLatin1Char('/'));
const int slash = name.indexOf('/');
const QString leafName = slash == -1 ? name : name.mid(slash + 1);
bool added = false;
if (slash != -1) {
@@ -675,7 +664,7 @@ void BranchModel::parseOutputLine(const QString &line)
return;
// objectname, refname, upstream:short, *objectname, committerdate:raw, *committerdate:raw
QStringList lineParts = line.split(QLatin1Char('\t'));
QStringList lineParts = line.split('\t');
const QString shaDeref = lineParts.at(3);
const QString sha = shaDeref.isEmpty() ? lineParts.at(0) : shaDeref;
const QString fullName = lineParts.at(1);
@@ -686,7 +675,7 @@ void BranchModel::parseOutputLine(const QString &line)
if (strDateTime.isEmpty())
strDateTime = lineParts.at(4);
if (!strDateTime.isEmpty()) {
const uint timeT = strDateTime.leftRef(strDateTime.indexOf(QLatin1Char(' '))).toUInt();
const uint timeT = strDateTime.leftRef(strDateTime.indexOf(' ')).toUInt();
dateTime = QDateTime::fromTime_t(timeT);
}
@@ -702,17 +691,17 @@ void BranchModel::parseOutputLine(const QString &line)
bool showTags = m_client->settings().boolValue(GitSettings::showTagsKey);
// insert node into tree:
QStringList nameParts = fullName.split(QLatin1Char('/'));
QStringList nameParts = fullName.split('/');
nameParts.removeFirst(); // remove refs...
BranchNode *root = 0;
if (nameParts.first() == QLatin1String("heads")) {
if (nameParts.first() == "heads") {
root = m_rootNode->children.at(LocalBranches);
} else if (nameParts.first() == QLatin1String("remotes")) {
} else if (nameParts.first() == "remotes") {
root = m_rootNode->children.at(RemoteBranches);
} else if (showTags && nameParts.first() == QLatin1String("tags")) {
} else if (showTags && nameParts.first() == "tags") {
if (!hasTags()) // Tags is missing, add it
m_rootNode->append(new BranchNode(tr("Tags"), QLatin1String("refs/tags")));
m_rootNode->append(new BranchNode(tr("Tags"), "refs/tags"));
root = m_rootNode->children.at(Tags);
} else {
return;
@@ -723,7 +712,7 @@ void BranchModel::parseOutputLine(const QString &line)
// limit depth of list. Git basically only ever wants one / and considers the rest as part of
// the name.
while (nameParts.count() > 3) {
nameParts[2] = nameParts.at(2) + QLatin1Char('/') + nameParts.at(3);
nameParts[2] = nameParts.at(2) + '/' + nameParts.at(3);
nameParts.removeAt(3);
}
@@ -774,7 +763,7 @@ QString BranchModel::toolTip(const QString &sha) const
// Show the sha description excluding diff as toolTip
QString output;
QString errorMessage;
QStringList arguments(QLatin1String("-n1"));
QStringList arguments("-n1");
arguments << sha;
if (!m_client->synchronousLog(m_workingDirectory, arguments, &output, &errorMessage,
VcsCommand::SuppressCommandLogging)) {

View File

@@ -119,7 +119,7 @@ void ChangeSelectionDialog::selectCommitFromRecentHistory()
return;
QString commit = change();
int tilde = commit.indexOf(QLatin1Char('~'));
int tilde = commit.indexOf('~');
if (tilde != -1)
commit.truncate(tilde);
LogChangeDialog dialog(false, this);
@@ -219,12 +219,11 @@ void ChangeSelectionDialog::recalculateCompletion()
return;
GitClient *client = GitPlugin::client();
QStringList args;
args << QLatin1String("--format=%(refname:short)");
VcsBase::VcsCommand *command = client->asyncForEachRefCmd(workingDir, args);
VcsBase::VcsCommand *command = client->asyncForEachRefCmd(
workingDir, { "--format=%(refname:short)" });
connect(this, &QObject::destroyed, command, &VcsBase::VcsCommand::abort);
connect(command, &VcsBase::VcsCommand::stdOutText, [this](const QString &output) {
m_changeModel->setStringList(output.split(QLatin1Char('\n')));
m_changeModel->setStringList(output.split('\n'));
});
}
@@ -245,9 +244,6 @@ void ChangeSelectionDialog::recalculateDetails()
return;
}
QStringList args;
args << QLatin1String("show") << QLatin1String("--stat=80") << ref;
m_process = new QProcess(this);
m_process->setWorkingDirectory(workingDir);
m_process->setProcessEnvironment(m_gitEnvironment);
@@ -255,7 +251,7 @@ void ChangeSelectionDialog::recalculateDetails()
connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
this, &ChangeSelectionDialog::setDetails);
m_process->start(m_gitExecutable.toString(), args);
m_process->start(m_gitExecutable.toString(), { "show", "--stat=80", ref });
m_process->closeWriteChannel();
if (!m_process->waitForStarted())
m_ui->detailsText->setPlainText(tr("Error: Could not start Git."));

View File

@@ -54,9 +54,9 @@ QString GitSubmitEditorPanelData::authorString() const
if (email.isEmpty())
return rc;
rc += QLatin1String(" <");
rc += " <";
rc += email;
rc += QLatin1Char('>');
rc += '>';
return rc;
}
@@ -114,7 +114,7 @@ bool CommitData::checkLine(const QString &stateInfo, const QString &file)
{
QTC_ASSERT(stateInfo.count() == 2, return false);
if (stateInfo == QLatin1String("??")) {
if (stateInfo == "??") {
files.append(qMakePair(FileStates(UntrackedFile), file));
return true;
}
@@ -143,7 +143,7 @@ bool CommitData::checkLine(const QString &stateInfo, const QString &file)
if (yState != EmptyFileState) {
QString newFile = file;
if (xState & (RenamedFile | CopiedFile))
newFile = file.mid(file.indexOf(QLatin1String(" -> ")) + 4);
newFile = file.mid(file.indexOf(" -> ") + 4);
files.append(qMakePair(yState, newFile));
}
@@ -159,20 +159,20 @@ bool CommitData::checkLine(const QString &stateInfo, const QString &file)
\endcode */
bool CommitData::parseFilesFromStatus(const QString &output)
{
const QStringList lines = output.split(QLatin1Char('\n'));
const QStringList lines = output.split('\n');
foreach (const QString &line, lines) {
if (line.isEmpty())
continue;
if (line.startsWith(QLatin1String("## "))) {
if (line.startsWith("## ")) {
// Branch indication:
panelInfo.branch = line.mid(3);
continue;
}
QTC_ASSERT(line.at(2) == QLatin1Char(' '), continue);
QTC_ASSERT(line.at(2) == ' ', continue);
QString file = line.mid(3);
if (file.startsWith(QLatin1Char('"')))
if (file.startsWith('"'))
file.remove(0, 1).chop(1);
if (!checkLine(line.mid(0, 2), file))
return false;

View File

@@ -39,16 +39,16 @@ void BranchComboBox::init(const QString &repository)
QString currentBranch = GitPlugin::client()->synchronousCurrentLocalBranch(repository);
if (currentBranch.isEmpty()) {
m_detached = true;
currentBranch = QLatin1String("HEAD");
currentBranch = "HEAD";
addItem(currentBranch);
}
QString output;
const QString branchPrefix(QLatin1String("refs/heads/"));
QStringList args;
args << QLatin1String("--format=%(refname)") << branchPrefix;
if (!GitPlugin::client()->synchronousForEachRefCmd(m_repository, args, &output))
const QString branchPrefix("refs/heads/");
if (!GitPlugin::client()->synchronousForEachRefCmd(
m_repository, { "--format=%(refname)", branchPrefix }, &output)) {
return;
QStringList branches = output.trimmed().split(QLatin1Char('\n'));
}
QStringList branches = output.trimmed().split('\n');
foreach (const QString &ref, branches) {
const QString branch = ref.mid(branchPrefix.size());
addItem(branch);

View File

@@ -69,7 +69,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
, m_filterLineEdit(new Utils::FancyLineEdit)
, m_repositoryChooser(new Utils::PathChooser)
, m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Close))
, m_repositoryChooserLabel(new QLabel(tr("Apply in:") + QLatin1Char(' '), this))
, m_repositoryChooserLabel(new QLabel(tr("Apply in:") + ' ', this))
, m_fetchRunning(false)
{
setWindowTitle(tr("Gerrit %1@%2").arg(p->user, p->host));
@@ -144,7 +144,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
detailsLayout->addWidget(m_detailsBrowser);
m_repositoryChooser->setExpectedKind(Utils::PathChooser::Directory);
m_repositoryChooser->setHistoryCompleter(QLatin1String("Git.RepoDir.History"));
m_repositoryChooser->setHistoryCompleter("Git.RepoDir.History");
QHBoxLayout *repoPathLayout = new QHBoxLayout;
repoPathLayout->addWidget(m_repositoryChooserLabel);
repoPathLayout->addWidget(m_repositoryChooser);

View File

@@ -86,9 +86,9 @@ QDebug operator<<(QDebug d, const GerritChange &c)
// Format default Url for a change
static inline QString defaultUrl(const QSharedPointer<GerritParameters> &p, int gerritNumber)
{
QString result = p->https ? QLatin1String("https://") : QLatin1String("http://");
QString result = QLatin1String(p->https ? "https://" : "http://");
result += p->host;
result += QLatin1Char('/');
result += '/';
result += QString::number(gerritNumber);
return result;
}
@@ -146,7 +146,7 @@ QString GerritPatchSet::approvalsColumn() const
TypeReviewMap reviews; // Sort approvals into a map by type character
foreach (const GerritApproval &a, approvals) {
if (a.type != QLatin1String("STGN")) { // Qt-Project specific: Ignore "STGN" (Staged)
if (a.type != "STGN") { // Qt-Project specific: Ignore "STGN" (Staged)
const QChar typeChar = a.type.at(0);
TypeReviewMapIterator it = reviews.find(typeChar);
if (it == reviews.end())
@@ -183,7 +183,7 @@ int GerritPatchSet::approvalLevel() const
QString GerritChange::filterString() const
{
const QChar blank = QLatin1Char(' ');
const QChar blank = ' ';
QString result = QString::number(number) + blank + title + blank
+ owner + blank + project + blank
+ branch + blank + status;
@@ -197,10 +197,10 @@ QString GerritChange::filterString() const
QStringList GerritChange::gitFetchArguments(const QSharedPointer<GerritParameters> &p) const
{
QStringList arguments;
const QString url = QLatin1String("ssh://") + p->sshHostArgument()
+ QLatin1Char(':') + QString::number(p->port) + QLatin1Char('/')
const QString url = "ssh://" + p->sshHostArgument()
+ ':' + QString::number(p->port) + '/'
+ project;
arguments << QLatin1String("fetch") << url << currentPatchSet.ref;
arguments << "fetch" << url << currentPatchSet.ref;
return arguments;
}
@@ -276,9 +276,9 @@ QueryContext::QueryContext(const QStringList &queries,
m_progress.setProgressRange(0, m_queries.size());
// Determine binary and common command line arguments.
m_baseArguments << QLatin1String("query") << QLatin1String("--dependencies")
<< QLatin1String("--current-patch-set")
<< QLatin1String("--format=JSON");
m_baseArguments << "query" << "--dependencies"
<< "--current-patch-set"
<< "--format=JSON";
m_binary = m_baseArguments.front();
m_baseArguments.pop_front();
@@ -404,7 +404,7 @@ GerritModel::GerritModel(const QSharedPointer<GerritParameters> &p, QObject *par
, m_parameters(p)
{
QStringList headers; // Keep in sync with GerritChange::toHtml()
headers << QLatin1String("#") << tr("Subject") << tr("Owner")
headers << "#" << tr("Subject") << tr("Owner")
<< tr("Updated") << tr("Project")
<< tr("Approvals") << tr("Status");
setHorizontalHeaderLabels(headers);
@@ -463,7 +463,7 @@ QString GerritModel::toHtml(const QModelIndex& index) const
if (!index.isValid())
return QString();
const GerritChangePtr c = change(index);
const QString serverPrefix = c->url.left(c->url.lastIndexOf(QLatin1Char('/')) + 1);
const QString serverPrefix = c->url.left(c->url.lastIndexOf('/') + 1);
QString result;
QTextStream str(&result);
str << "<html><head/><body><table>"
@@ -522,14 +522,14 @@ void GerritModel::refresh(const QString &query)
queries.push_back(query);
else
{
const QString statusOpenQuery = QLatin1String("status:open");
const QString statusOpenQuery = "status:open";
if (m_parameters->user.isEmpty()) {
queries.push_back(statusOpenQuery);
} else {
// Owned by:
queries.push_back(statusOpenQuery + QLatin1String(" owner:") + m_parameters->user);
queries.push_back(statusOpenQuery + " owner:" + m_parameters->user);
// For Review by:
queries.push_back(statusOpenQuery + QLatin1String(" reviewer:") + m_parameters->user);
queries.push_back(statusOpenQuery + " reviewer:" + m_parameters->user);
}
}
@@ -578,27 +578,27 @@ static bool parseOutput(const QSharedPointer<GerritParameters> &parameters,
QList<GerritChangePtr> &result)
{
// The output consists of separate lines containing a document each
const QString typeKey = QLatin1String("type");
const QString dependsOnKey = QLatin1String("dependsOn");
const QString neededByKey = QLatin1String("neededBy");
const QString branchKey = QLatin1String("branch");
const QString numberKey = QLatin1String("number");
const QString ownerKey = QLatin1String("owner");
const QString ownerNameKey = QLatin1String("name");
const QString ownerEmailKey = QLatin1String("email");
const QString statusKey = QLatin1String("status");
const QString projectKey = QLatin1String("project");
const QString titleKey = QLatin1String("subject");
const QString urlKey = QLatin1String("url");
const QString patchSetKey = QLatin1String("currentPatchSet");
const QString refKey = QLatin1String("ref");
const QString approvalsKey = QLatin1String("approvals");
const QString approvalsValueKey = QLatin1String("value");
const QString approvalsByKey = QLatin1String("by");
const QString lastUpdatedKey = QLatin1String("lastUpdated");
const QString typeKey = "type";
const QString dependsOnKey = "dependsOn";
const QString neededByKey = "neededBy";
const QString branchKey = "branch";
const QString numberKey = "number";
const QString ownerKey = "owner";
const QString ownerNameKey = "name";
const QString ownerEmailKey = "email";
const QString statusKey = "status";
const QString projectKey = "project";
const QString titleKey = "subject";
const QString urlKey = "url";
const QString patchSetKey = "currentPatchSet";
const QString refKey = "ref";
const QString approvalsKey = "approvals";
const QString approvalsValueKey = "value";
const QString approvalsByKey = "by";
const QString lastUpdatedKey = "lastUpdated";
const QList<QByteArray> lines = output.split('\n');
const QString approvalsTypeKey = QLatin1String("type");
const QString approvalsDescriptionKey = QLatin1String("description");
const QString approvalsTypeKey = "type";
const QString approvalsDescriptionKey = "description";
bool res = true;
result.clear();
@@ -712,8 +712,8 @@ QList<QStandardItem *> GerritModel::changeToRow(const GerritChangePtr &c) const
row[DateColumn]->setData(c->lastUpdated, SortRole);
QString project = c->project;
if (c->branch != QLatin1String("master"))
project += QLatin1String(" (") + c->branch + QLatin1Char(')');
if (c->branch != "master")
project += " (" + c->branch + ')';
row[ProjectColumn]->setText(project);
row[StatusColumn]->setText(c->status);
row[ApprovalsColumn]->setText(c->currentPatchSet.approvalsColumn());
@@ -759,7 +759,7 @@ void GerritModel::queryFinished(const QByteArray &output)
changes.at(i)->depth = 0;
} else {
const int dependsOnIndex = numberIndexHash.value(changes.at(i)->dependsOnNumber, -1);
if (dependsOnIndex < 0 || changes.at(dependsOnIndex)->status != QLatin1String("NEW"))
if (dependsOnIndex < 0 || changes.at(dependsOnIndex)->status != "NEW")
changes.at(i)->depth = 0;
}
}
@@ -798,7 +798,7 @@ void GerritModel::queryFinished(const QByteArray &output)
for (; changeFromItem(parent)->depth >= 1; parent = parent->parent()) {}
parent->appendRow(newRow);
QString parentFilterString = parent->data(FilterRole).toString();
parentFilterString += QLatin1Char(' ');
parentFilterString += ' ';
parentFilterString += newRow.first()->data(FilterRole).toString();
parent->setData(QVariant(parentFilterString), FilterRole);
} else {

View File

@@ -93,8 +93,8 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent)
formLayout->addRow(tr("&Host:"), m_hostLineEdit);
formLayout->addRow(tr("&User:"), m_userLineEdit);
m_sshChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_sshChooser->setCommandVersionArguments(QStringList(QLatin1String("-V")));
m_sshChooser->setHistoryCompleter(QLatin1String("Git.SshCommand.History"));
m_sshChooser->setCommandVersionArguments(QStringList("-V"));
m_sshChooser->setHistoryCompleter("Git.SshCommand.History");
formLayout->addRow(tr("&ssh:"), m_sshChooser);
m_portSpinBox->setMinimum(1);
m_portSpinBox->setMaximum(65535);

View File

@@ -57,13 +57,13 @@ static inline QString detectSsh()
const QByteArray gitSsh = qgetenv("GIT_SSH");
if (!gitSsh.isEmpty())
return QString::fromLocal8Bit(gitSsh);
QString ssh = QStandardPaths::findExecutable(QLatin1String(defaultSshC));
QString ssh = QStandardPaths::findExecutable(defaultSshC);
if (!ssh.isEmpty())
return ssh;
if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found.
Utils::FileName path = GerritPlugin::gitBinDirectory();
if (!path.isEmpty())
ssh = path.appendPath(QLatin1String(defaultSshC)).toString();
ssh = path.appendPath(defaultSshC).toString();
}
return ssh;
}
@@ -72,17 +72,17 @@ void GerritParameters::setPortFlagBySshType()
{
bool isPlink = false;
if (!ssh.isEmpty()) {
const QString version = Utils::PathChooser::toolVersion(ssh, QStringList(QLatin1String("-V")));
isPlink = version.contains(QLatin1String("plink"), Qt::CaseInsensitive);
const QString version = Utils::PathChooser::toolVersion(ssh, QStringList("-V"));
isPlink = version.contains("plink", Qt::CaseInsensitive);
}
portFlag = isPlink ? QLatin1String("-P") : QLatin1String(defaultPortFlag);
portFlag = isPlink ? "-P" : defaultPortFlag;
}
GerritParameters::GerritParameters()
: host(QLatin1String(defaultHostC))
: host(defaultHostC)
, port(defaultPort)
, https(true)
, portFlag(QLatin1String(defaultPortFlag))
, portFlag(defaultPortFlag)
{
}
@@ -90,13 +90,13 @@ QStringList GerritParameters::baseCommandArguments() const
{
QStringList result;
result << ssh << portFlag << QString::number(port)
<< sshHostArgument() << QLatin1String("gerrit");
<< sshHostArgument() << "gerrit";
return result;
}
QString GerritParameters::sshHostArgument() const
{
return user.isEmpty() ? host : (user + QLatin1Char('@') + host);
return user.isEmpty() ? host : (user + '@' + host);
}
bool GerritParameters::equals(const GerritParameters &rhs) const
@@ -107,34 +107,34 @@ bool GerritParameters::equals(const GerritParameters &rhs) const
void GerritParameters::toSettings(QSettings *s) const
{
s->beginGroup(QLatin1String(settingsGroupC));
s->setValue(QLatin1String(hostKeyC), host);
s->setValue(QLatin1String(userKeyC), user);
s->setValue(QLatin1String(portKeyC), port);
s->setValue(QLatin1String(portFlagKeyC), portFlag);
s->setValue(QLatin1String(sshKeyC), ssh);
s->setValue(QLatin1String(httpsKeyC), https);
s->beginGroup(settingsGroupC);
s->setValue(hostKeyC, host);
s->setValue(userKeyC, user);
s->setValue(portKeyC, port);
s->setValue(portFlagKeyC, portFlag);
s->setValue(sshKeyC, ssh);
s->setValue(httpsKeyC, https);
s->endGroup();
}
void GerritParameters::saveQueries(QSettings *s) const
{
s->beginGroup(QLatin1String(settingsGroupC));
s->setValue(QLatin1String(savedQueriesKeyC), savedQueries.join(QLatin1Char(',')));
s->beginGroup(settingsGroupC);
s->setValue(savedQueriesKeyC, savedQueries.join(','));
s->endGroup();
}
void GerritParameters::fromSettings(const QSettings *s)
{
const QString rootKey = QLatin1String(settingsGroupC) + QLatin1Char('/');
host = s->value(rootKey + QLatin1String(hostKeyC), QLatin1String(defaultHostC)).toString();
user = s->value(rootKey + QLatin1String(userKeyC), QString()).toString();
ssh = s->value(rootKey + QLatin1String(sshKeyC), QString()).toString();
port = s->value(rootKey + QLatin1String(portKeyC), QVariant(int(defaultPort))).toInt();
portFlag = s->value(rootKey + QLatin1String(portFlagKeyC), QLatin1String(defaultPortFlag)).toString();
savedQueries = s->value(rootKey + QLatin1String(savedQueriesKeyC), QString()).toString()
.split(QLatin1Char(','));
https = s->value(rootKey + QLatin1String(httpsKeyC), QVariant(true)).toBool();
const QString rootKey = QLatin1String(settingsGroupC) + '/';
host = s->value(rootKey + hostKeyC, defaultHostC).toString();
user = s->value(rootKey + userKeyC, QString()).toString();
ssh = s->value(rootKey + sshKeyC, QString()).toString();
port = s->value(rootKey + portKeyC, QVariant(int(defaultPort))).toInt();
portFlag = s->value(rootKey + portFlagKeyC, defaultPortFlag).toString();
savedQueries = s->value(rootKey + savedQueriesKeyC, QString()).toString()
.split(',');
https = s->value(rootKey + httpsKeyC, QVariant(true)).toBool();
if (ssh.isEmpty())
ssh = detectSsh();
}

View File

@@ -243,9 +243,9 @@ void FetchContext::processError(QProcess::ProcessError e)
void FetchContext::show()
{
const QString title = QString::number(m_change->number) + QLatin1Char('/')
const QString title = QString::number(m_change->number) + '/'
+ QString::number(m_change->currentPatchSet.patchSetNumber);
GitPlugin::client()->show(m_repository, QLatin1String("FETCH_HEAD"), title);
GitPlugin::client()->show(m_repository, "FETCH_HEAD", title);
}
void FetchContext::cherryPick()
@@ -253,12 +253,12 @@ void FetchContext::cherryPick()
// Point user to errors.
VcsBase::VcsOutputWindow::instance()->popup(IOutputPane::ModeSwitch
| IOutputPane::WithFocus);
GitPlugin::client()->synchronousCherryPick(m_repository, QLatin1String("FETCH_HEAD"));
GitPlugin::client()->synchronousCherryPick(m_repository, "FETCH_HEAD");
}
void FetchContext::checkout()
{
GitPlugin::client()->stashAndCheckout(m_repository, QLatin1String("FETCH_HEAD"));
GitPlugin::client()->stashAndCheckout(m_repository, "FETCH_HEAD");
}
void FetchContext::terminate()
@@ -326,31 +326,26 @@ void GerritPlugin::push(const QString &topLevel)
if (dialog.exec() == QDialog::Rejected)
return;
QStringList args;
m_reviewers = dialog.reviewers();
args << dialog.selectedRemoteName();
QString target = dialog.selectedCommit();
if (target.isEmpty())
target = QLatin1String("HEAD");
target += QLatin1String(":refs/") + dialog.selectedPushType() +
QLatin1Char('/') + dialog.selectedRemoteBranchName();
target = "HEAD";
target += ":refs/" + dialog.selectedPushType() +
'/' + dialog.selectedRemoteBranchName();
const QString topic = dialog.selectedTopic();
if (!topic.isEmpty())
target += QLatin1Char('/') + topic;
target += '/' + topic;
QStringList options;
const QStringList reviewers = m_reviewers.split(QLatin1Char(','), QString::SkipEmptyParts);
const QStringList reviewers = m_reviewers.split(',', QString::SkipEmptyParts);
foreach (const QString &reviewer, reviewers)
options << QLatin1String("r=") + reviewer;
options << "r=" + reviewer;
if (!options.isEmpty())
target += QLatin1Char('%') + options.join(QLatin1Char(','));
target += '%' + options.join(',');
args << target;
GitPlugin::client()->push(topLevel, args);
GitPlugin::client()->push(topLevel, { dialog.selectedRemoteName(), target });
}
// Open or raise the Gerrit dialog window.
@@ -432,7 +427,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
if (!remotesList.isEmpty()) {
QStringList remotes = remotesList.values();
foreach (QString remote, remotes) {
if (remote.endsWith(QLatin1String(".git")))
if (remote.endsWith(".git"))
remote.chop(4);
if (remote.contains(m_parameters->host) && remote.endsWith(change->project)) {
verifiedRepository = true;
@@ -444,11 +439,11 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
SubmoduleDataMap submodules = GitPlugin::client()->submoduleList(repository);
foreach (const SubmoduleData &submoduleData, submodules) {
QString remote = submoduleData.url;
if (remote.endsWith(QLatin1String(".git")))
if (remote.endsWith(".git"))
remote.chop(4);
if (remote.contains(m_parameters->host) && remote.endsWith(change->project)
&& QFile::exists(repository + QLatin1Char('/') + submoduleData.dir)) {
repository = QDir::cleanPath(repository + QLatin1Char('/')
&& QFile::exists(repository + '/' + submoduleData.dir)) {
repository = QDir::cleanPath(repository + '/'
+ submoduleData.dir);
verifiedRepository = true;
break;
@@ -504,18 +499,18 @@ QString GerritPlugin::findLocalRepository(QString project, const QString &branch
{
const QStringList gitRepositories = VcsManager::repositories(GitPlugin::instance()->gitVersionControl());
// Determine key (file name) to look for (qt/qtbase->'qtbase').
const int slashPos = project.lastIndexOf(QLatin1Char('/'));
const int slashPos = project.lastIndexOf('/');
if (slashPos != -1)
project.remove(0, slashPos + 1);
// When looking at branch 1.7, try to check folders
// "qtbase_17", 'qtbase1.7' with a semi-smart regular expression.
QScopedPointer<QRegExp> branchRegexp;
if (!branch.isEmpty() && branch != QLatin1String("master")) {
if (!branch.isEmpty() && branch != "master") {
QString branchPattern = branch;
branchPattern.replace(QLatin1Char('.'), QLatin1String("[\\.-_]?"));
const QString pattern = QLatin1Char('^') + project
+ QLatin1String("[-_]?")
+ branchPattern + QLatin1Char('$');
branchPattern.replace('.', "[\\.-_]?");
const QString pattern = '^' + project
+ "[-_]?"
+ branchPattern + '$';
branchRegexp.reset(new QRegExp(pattern));
if (!branchRegexp->isValid())
branchRegexp.reset(); // Oops.

View File

@@ -45,7 +45,7 @@ class PushItemDelegate : public IconItemDelegate
{
public:
PushItemDelegate(LogChangeWidget *widget)
: IconItemDelegate(widget, QLatin1String(":/git/images/arrowup.png"))
: IconItemDelegate(widget, ":/git/images/arrowup.png")
{
}
@@ -62,17 +62,16 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
QString output;
QString error;
QStringList args;
args << QLatin1String("-r") << QLatin1String("--contains")
<< earliestCommit + QLatin1Char('^');
if (!GitPlugin::client()->synchronousBranchCmd(m_workingDir, args, &output, &error))
if (!GitPlugin::client()->synchronousBranchCmd(
m_workingDir, { "-r", "--contains", earliestCommit + '^' }, &output, &error)) {
return QString();
const QString head = QLatin1String("/HEAD");
QStringList refs = output.split(QLatin1Char('\n'));
}
const QString head = "/HEAD";
QStringList refs = output.split('\n');
QString remoteTrackingBranch;
if (localBranch != QLatin1String("HEAD"))
if (localBranch != "HEAD")
remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch);
QString remoteBranch;
@@ -94,31 +93,30 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
void GerritPushDialog::initRemoteBranches()
{
QString output;
QStringList args;
const QString head = QLatin1String("/HEAD");
const QString head = "/HEAD";
QString remotesPrefix(QLatin1String("refs/remotes/"));
args << QLatin1String("--format=%(refname)\t%(committerdate:raw)")
<< remotesPrefix;
if (!GitPlugin::client()->synchronousForEachRefCmd(m_workingDir, args, &output))
QString remotesPrefix("refs/remotes/");
if (!GitPlugin::client()->synchronousForEachRefCmd(
m_workingDir, { "--format=%(refname)\t%(committerdate:raw)", remotesPrefix }, &output)) {
return;
}
const QStringList refs = output.split(QLatin1String("\n"));
const QStringList refs = output.split("\n");
foreach (const QString &reference, refs) {
QStringList entries = reference.split(QLatin1Char('\t'));
QStringList entries = reference.split('\t');
if (entries.count() < 2 || entries.first().endsWith(head))
continue;
const QString ref = entries.at(0).mid(remotesPrefix.size());
int refBranchIndex = ref.indexOf(QLatin1Char('/'));
int timeT = entries.at(1).leftRef(entries.at(1).indexOf(QLatin1Char(' '))).toInt();
int refBranchIndex = ref.indexOf('/');
int timeT = entries.at(1).leftRef(entries.at(1).indexOf(' ')).toInt();
BranchDate bd(ref.mid(refBranchIndex + 1), QDateTime::fromTime_t(timeT).date());
m_remoteBranches.insertMulti(ref.left(refBranchIndex), bd);
}
QStringList remotes = GitPlugin::client()->synchronousRemotesList(m_workingDir).keys();
remotes.removeDuplicates();
{
const QString origin = QLatin1String("origin");
const QString gerrit = QLatin1String("gerrit");
const QString origin = "origin";
const QString gerrit = "gerrit";
if (remotes.removeOne(origin))
remotes.prepend(origin);
if (remotes.removeOne(gerrit))
@@ -155,7 +153,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
updateCommits(m_ui->localBranchComboBox->currentIndex());
setRemoteBranches();
QRegExpValidator *noSpaceValidator = new QRegExpValidator(QRegExp(QLatin1String("^\\S+$")), this);
QRegExpValidator *noSpaceValidator = new QRegExpValidator(QRegExp("^\\S+$"), this);
m_ui->reviewersLineEdit->setText(reviewerList);
m_ui->reviewersLineEdit->setValidator(noSpaceValidator);
m_ui->topicLineEdit->setValidator(noSpaceValidator);
@@ -179,16 +177,14 @@ QString GerritPushDialog::selectedCommit() const
QString GerritPushDialog::calculateChangeRange(const QString &branch)
{
QString remote = selectedRemoteName();
remote += QLatin1Char('/');
remote += '/';
remote += selectedRemoteBranchName();
QStringList args(remote + QLatin1String("..") + branch);
args << QLatin1String("--count");
QString number;
QString error;
GitPlugin::client()->synchronousRevListCmd(m_workingDir, args, &number, &error);
GitPlugin::client()->synchronousRevListCmd(m_workingDir, { remote + ".." + branch, "--count" },
&number, &error);
number.chop(1);
return number;
@@ -210,7 +206,7 @@ void GerritPushDialog::setChangeRange()
return;
}
m_ui->infoLabel->show();
const QString remote = selectedRemoteName() + QLatin1Char('/') + remoteBranchName;
const QString remote = selectedRemoteName() + '/' + remoteBranchName;
m_ui->infoLabel->setText(
tr("Number of commits between %1 and %2: %3").arg(branch, remote, range));
}
@@ -259,7 +255,7 @@ void GerritPushDialog::updateCommits(int index)
const QString remoteBranch = determineRemoteBranch(branch);
if (!remoteBranch.isEmpty()) {
const int slash = remoteBranch.indexOf(QLatin1Char('/'));
const int slash = remoteBranch.indexOf('/');
m_suggestedRemoteBranch = remoteBranch.mid(slash + 1);
const QString remote = remoteBranch.left(slash);
@@ -285,7 +281,7 @@ QString GerritPushDialog::selectedRemoteBranchName() const
QString GerritPushDialog::selectedPushType() const
{
return m_ui->draftCheckBox->isChecked() ? QLatin1String("drafts") : QLatin1String("for");
return QLatin1String(m_ui->draftCheckBox->isChecked() ? "drafts" : "for");
}
QString GerritPushDialog::selectedTopic() const

View File

@@ -80,6 +80,7 @@ const char GIT_DIRECTORY[] = ".git";
const char graphLogFormatC[] = "%h %d %an %s %ci";
const char HEAD[] = "HEAD";
const char CHERRY_PICK_HEAD[] = "CHERRY_PICK_HEAD";
const char stashNamePrefix[] = "stash@{";
const char noColorOption[] = "--no-color";
const char decorateOption[] = "--decorate";
const char showFormatC[] =
@@ -200,14 +201,13 @@ void BaseController::processOutput(const QString &output)
QStringList BaseController::addHeadWhenCommandInProgress() const
{
QStringList args;
// This is workaround for lack of support for merge commits and resolving conflicts,
// we compare the current state of working tree to the HEAD of current branch
// instead of showing unsupported combined diff format.
GitClient::CommandInProgress commandInProgress = GitPlugin::client()->checkCommandInProgress(m_directory);
if (commandInProgress != GitClient::NoCommand)
args << HEAD;
return args;
return { HEAD };
return QStringList();
}
class RepositoryDiffController : public BaseController
@@ -446,7 +446,7 @@ public:
m_ignoreWSButton->setVisible(diffButton->isChecked());
const QStringList graphArguments = {
"--graph", "--oneline", "--topo-order",
(QLatin1String("--pretty=format:") + graphLogFormatC)
QLatin1String("--pretty=format:") + graphLogFormatC
};
QToolButton *graphButton = addToggleButton(graphArguments, tr("Graph"),
tr("Show textual graph log."));
@@ -581,8 +581,6 @@ static inline void msgCannotRun(const QStringList &args, const QString &workingD
// ---------------- GitClient
const char *GitClient::stashNamePrefix = "stash@{";
GitClient::GitClient() : VcsBase::VcsBaseClientImpl(new GitSettings),
m_cachedGitVersion(0),
m_disableEditor(false)
@@ -741,7 +739,7 @@ void GitClient::diffFiles(const QString &workingDirectory,
const QStringList &unstagedFileNames,
const QStringList &stagedFileNames) const
{
requestReload(QLatin1String("Files:") + workingDirectory,
requestReload("Files:" + workingDirectory,
workingDirectory, tr("Git Diff Files"),
[this, workingDirectory, stagedFileNames, unstagedFileNames]
(IDocument *doc) -> DiffEditorController* {
@@ -752,7 +750,7 @@ void GitClient::diffFiles(const QString &workingDirectory,
void GitClient::diffProject(const QString &workingDirectory, const QString &projectDirectory) const
{
requestReload(QLatin1String("Project:") + workingDirectory,
requestReload("Project:" + workingDirectory,
workingDirectory, tr("Git Diff Project"),
[this, workingDirectory, projectDirectory]
(IDocument *doc) -> DiffEditorController* {
@@ -763,7 +761,7 @@ void GitClient::diffProject(const QString &workingDirectory, const QString &proj
void GitClient::diffRepository(const QString &workingDirectory)
{
requestReload(QLatin1String("Repository:") + workingDirectory,
requestReload("Repository:" + workingDirectory,
workingDirectory, tr("Git Diff Repository"),
[this, workingDirectory](IDocument *doc) -> DiffEditorController* {
return new RepositoryDiffController(doc, workingDirectory);
@@ -774,7 +772,7 @@ void GitClient::diffFile(const QString &workingDirectory, const QString &fileNam
{
const QString title = tr("Git Diff \"%1\"").arg(fileName);
const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName);
const QString documentId = QLatin1String("File:") + sourceFile;
const QString documentId = "File:" + sourceFile;
requestReload(documentId, sourceFile, title,
[this, workingDirectory, fileName]
(IDocument *doc) -> DiffEditorController* {
@@ -786,7 +784,7 @@ void GitClient::diffBranch(const QString &workingDirectory,
const QString &branchName) const
{
const QString title = tr("Git Diff Branch \"%1\"").arg(branchName);
const QString documentId = QLatin1String("Branch:") + branchName;
const QString documentId = "Branch:" + branchName;
requestReload(documentId, workingDirectory, title,
[this, workingDirectory, branchName]
(IDocument *doc) -> DiffEditorController* {
@@ -894,7 +892,7 @@ void GitClient::show(const QString &source, const QString &id, const QString &na
const QString repoDirectory = VcsManager::findTopLevelForDirectory(workingDirectory);
if (!repoDirectory.isEmpty())
workingDirectory = repoDirectory;
const QString documentId = QLatin1String("Show:") + id;
const QString documentId = "Show:" + id;
requestReload(documentId, source, title,
[this, workingDirectory, id]
(IDocument *doc) -> DiffEditorController* {
@@ -1531,7 +1529,7 @@ bool GitClient::stashNameFromMessage(const QString &workingDirectory,
QString *errorMessage) const
{
// All happy
if (message.startsWith(QLatin1String(stashNamePrefix))) {
if (message.startsWith(stashNamePrefix)) {
*name = message;
return true;
}
@@ -2645,7 +2643,7 @@ void GitClient::revert(const QStringList &files, bool revertStaging)
void GitClient::fetch(const QString &workingDirectory, const QString &remote)
{
QStringList const arguments = { "fetch", (remote.isEmpty() ? QLatin1String("--all") : remote) };
QStringList const arguments = { "fetch", (remote.isEmpty() ? "--all" : remote) };
VcsCommand *command = vcsExec(workingDirectory, arguments, nullptr, true,
VcsCommand::ShowSuccessMessage);
connect(command, &VcsCommand::success,

View File

@@ -121,8 +121,6 @@ public:
PushAction m_pushAction = NoPush;
};
static const char *stashNamePrefix;
explicit GitClient();
Utils::FileName vcsBinary() const override;

View File

@@ -59,7 +59,7 @@ namespace Git {
namespace Internal {
GitEditorWidget::GitEditorWidget() :
m_changeNumberPattern(QLatin1String(CHANGE_PATTERN))
m_changeNumberPattern(CHANGE_PATTERN)
{
QTC_ASSERT(m_changeNumberPattern.isValid(), return);
/* Diff format:
@@ -68,8 +68,8 @@ GitEditorWidget::GitEditorWidget() :
--- a/src/plugins/git/giteditor.cpp
+++ b/src/plugins/git/giteditor.cpp
*/
setDiffFilePattern(QRegExp(QLatin1String("^(?:diff --git a/|index |[+-]{3} (?:/dev/null|[ab]/(.+$)))")));
setLogEntryPattern(QRegExp(QLatin1String("^commit ([0-9a-f]{8})[0-9a-f]{32}")));
setDiffFilePattern(QRegExp("^(?:diff --git a/|index |[+-]{3} (?:/dev/null|[ab]/(.+$)))"));
setLogEntryPattern(QRegExp("^commit ([0-9a-f]{8})[0-9a-f]{32}"));
setAnnotateRevisionTextFormat(tr("&Blame %1"));
setAnnotatePreviousRevisionTextFormat(tr("Blame &Parent Revision %1"));
}
@@ -81,11 +81,11 @@ QSet<QString> GitEditorWidget::annotationChanges() const
if (txt.isEmpty())
return changes;
// Hunt for first change number in annotation: "<change>:"
QRegExp r(QLatin1String("^(" CHANGE_PATTERN ") "));
QRegExp r("^(" CHANGE_PATTERN ") ");
QTC_ASSERT(r.isValid(), return changes);
if (r.indexIn(txt) != -1) {
changes.insert(r.cap(1));
r.setPattern(QLatin1String("\n(" CHANGE_PATTERN ") "));
r.setPattern("\n(" CHANGE_PATTERN ") ");
QTC_ASSERT(r.isValid(), return changes);
int pos = 0;
while ((pos = r.indexIn(txt, pos)) != -1) {
@@ -126,8 +126,8 @@ static QString sanitizeBlameOutput(const QString &b)
const bool omitDate = GitPlugin::client()->settings().boolValue(
GitSettings::omitAnnotationDateKey);
const QChar space(QLatin1Char(' '));
const int parenPos = b.indexOf(QLatin1Char(')'));
const QChar space(' ');
const int parenPos = b.indexOf(')');
if (parenPos == -1)
return b;
@@ -154,7 +154,7 @@ static QString sanitizeBlameOutput(const QString &b)
// Copy over the parts that have not changed into a new byte array
QString result;
int prevPos = 0;
int pos = b.indexOf(QLatin1Char('\n'), 0) + 1;
int pos = b.indexOf('\n', 0) + 1;
forever {
QTC_CHECK(prevPos < pos);
int afterParen = prevPos + parenPos;
@@ -165,7 +165,7 @@ static QString sanitizeBlameOutput(const QString &b)
if (pos == b.size())
break;
pos = b.indexOf(QLatin1Char('\n'), pos) + 1;
pos = b.indexOf('\n', pos) + 1;
if (pos == 0) // indexOf returned -1
pos = b.size();
}
@@ -190,8 +190,7 @@ void GitEditorWidget::setPlainText(const QString &text)
void GitEditorWidget::checkoutChange()
{
GitPlugin::client()->stashAndCheckout(
sourceWorkingDirectory(), m_currentChange);
GitPlugin::client()->stashAndCheckout(sourceWorkingDirectory(), m_currentChange);
}
void GitEditorWidget::resetChange(const QByteArray &resetType)
@@ -202,14 +201,12 @@ void GitEditorWidget::resetChange(const QByteArray &resetType)
void GitEditorWidget::cherryPickChange()
{
GitPlugin::client()->synchronousCherryPick(
sourceWorkingDirectory(), m_currentChange);
GitPlugin::client()->synchronousCherryPick(sourceWorkingDirectory(), m_currentChange);
}
void GitEditorWidget::revertChange()
{
GitPlugin::client()->synchronousRevert(
sourceWorkingDirectory(), m_currentChange);
GitPlugin::client()->synchronousRevert(sourceWorkingDirectory(), m_currentChange);
}
void GitEditorWidget::logChange()
@@ -229,9 +226,9 @@ void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert)
patchFile.write(chunk.chunk);
patchFile.close();
QStringList args = QStringList() << QLatin1String("--cached");
QStringList args = { "--cached" };
if (revert)
args << QLatin1String("--reverse");
args << "--reverse";
QString errorMessage;
if (GitPlugin::client()->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) {
if (errorMessage.isEmpty())
@@ -362,7 +359,7 @@ QString GitEditorWidget::fileNameForLine(int line) const
// 7971b6e7 share/qtcreator/dumper/dumper.py (hjk
QTextBlock block = document()->findBlockByLineNumber(line - 1);
QTC_ASSERT(block.isValid(), return source());
static QRegExp renameExp(QLatin1String("^" CHANGE_PATTERN "\\s+([^(]+)"));
static QRegExp renameExp("^" CHANGE_PATTERN "\\s+([^(]+)");
if (renameExp.indexIn(block.text()) != -1) {
const QString fileName = renameExp.cap(1).trimmed();
if (!fileName.isEmpty())

View File

@@ -94,7 +94,7 @@ public:
QString filePath = line.left(lineSeparator);
if (!m_ref.isEmpty() && filePath.startsWith(m_ref))
filePath.remove(0, m_ref.length());
single.fileName = m_directory + QLatin1Char('/') + filePath;
single.fileName = m_directory + '/' + filePath;
const int textSeparator = line.indexOf(QChar::Null, lineSeparator + 1);
single.lineNumber = line.mid(lineSeparator + 1, textSeparator - lineSeparator - 1).toInt();
QString text = line.mid(textSeparator + 1);
@@ -133,25 +133,25 @@ public:
void exec()
{
QStringList arguments;
arguments << QLatin1String("-c") << QLatin1String("color.grep.match=bold red")
<< QLatin1String("grep") << QLatin1String("-zn")
<< QLatin1String("--no-full-name")
<< QLatin1String("--color=always");
arguments << "-c" << "color.grep.match=bold red"
<< "grep" << "-zn"
<< "--no-full-name"
<< "--color=always";
if (!(m_parameters.flags & FindCaseSensitively))
arguments << QLatin1String("-i");
arguments << "-i";
if (m_parameters.flags & FindWholeWords)
arguments << QLatin1String("-w");
arguments << "-w";
if (m_parameters.flags & FindRegularExpression)
arguments << QLatin1String("-P");
arguments << "-P";
else
arguments << QLatin1String("-F");
arguments << "-F";
arguments << m_parameters.text;
GitGrepParameters params = m_parameters.extensionParameters.value<GitGrepParameters>();
if (!params.ref.isEmpty()) {
arguments << params.ref;
m_ref = params.ref + QLatin1Char(':');
m_ref = params.ref + ':';
}
arguments << QLatin1String("--") << m_parameters.nameFilters;
arguments << "--" << m_parameters.nameFilters;
QScopedPointer<VcsCommand> command(GitPlugin::client()->createCommand(m_directory));
command->addFlags(VcsCommand::SilentOutput | VcsCommand::SuppressFailMessage);
command->setProgressiveOutput(true);
@@ -212,7 +212,7 @@ GitGrep::GitGrep()
m_treeLineEdit->setPlaceholderText(tr("Tree (optional)"));
m_treeLineEdit->setToolTip(tr("Can be HEAD, tag, local or remote branch, or a commit hash.\n"
"Leave empty to search through the file system."));
const QRegularExpression refExpression(QLatin1String("[\\S]*"));
const QRegularExpression refExpression("[\\S]*");
m_treeLineEdit->setValidator(new QRegularExpressionValidator(refExpression, this));
layout->addWidget(m_treeLineEdit);
TextEditor::FindInFiles *findInFiles = TextEditor::FindInFiles::instance();
@@ -267,14 +267,14 @@ QVariant GitGrep::parameters() const
void GitGrep::readSettings(QSettings *settings)
{
m_enabledCheckBox->setChecked(settings->value(QLatin1String(EnableGitGrep), false).toBool());
m_treeLineEdit->setText(settings->value(QLatin1String(GitGrepRef)).toString());
m_enabledCheckBox->setChecked(settings->value(EnableGitGrep, false).toBool());
m_treeLineEdit->setText(settings->value(GitGrepRef).toString());
}
void GitGrep::writeSettings(QSettings *settings) const
{
settings->setValue(QLatin1String(EnableGitGrep), m_enabledCheckBox->isChecked());
settings->setValue(QLatin1String(GitGrepRef), m_treeLineEdit->text());
settings->setValue(EnableGitGrep, m_enabledCheckBox->isChecked());
settings->setValue(GitGrepRef, m_treeLineEdit->text());
}
QFuture<FileSearchResultList> GitGrep::executeSearch(
@@ -293,7 +293,7 @@ IEditor *GitGrep::openEditor(const SearchResultItem &item,
QByteArray content;
const QString topLevel = parameters.additionalParameters.toString();
const QString relativePath = QDir(topLevel).relativeFilePath(path);
if (!GitPlugin::client()->synchronousShow(topLevel, params.ref + QLatin1String(":./") + relativePath,
if (!GitPlugin::client()->synchronousShow(topLevel, params.ref + ":./" + relativePath,
&content, nullptr)) {
return nullptr;
}

View File

@@ -42,8 +42,8 @@ GitSubmitHighlighter::GitSubmitHighlighter(QTextEdit * parent) :
categories << TextEditor::C_COMMENT;
setTextFormatCategories(categories);
m_keywordPattern.setPattern(QLatin1String("^[\\w-]+:"));
m_hashChar = QLatin1Char('#');
m_keywordPattern.setPattern("^[\\w-]+:");
m_hashChar = '#';
QTC_CHECK(m_keywordPattern.isValid());
}
@@ -95,8 +95,8 @@ GitRebaseHighlighter::RebaseAction::RebaseAction(const QString &regexp,
GitRebaseHighlighter::GitRebaseHighlighter(QTextDocument *parent) :
TextEditor::SyntaxHighlighter(parent),
m_hashChar(QLatin1Char('#')),
m_changeNumberPattern(QLatin1String(CHANGE_PATTERN))
m_hashChar('#'),
m_changeNumberPattern(CHANGE_PATTERN)
{
static QVector<TextEditor::TextStyle> categories;
if (categories.isEmpty()) {
@@ -112,12 +112,12 @@ GitRebaseHighlighter::GitRebaseHighlighter(QTextDocument *parent) :
}
setTextFormatCategories(categories);
m_actions << RebaseAction(QLatin1String("^(p|pick)\\b"), Format_Pick);
m_actions << RebaseAction(QLatin1String("^(r|reword)\\b"), Format_Reword);
m_actions << RebaseAction(QLatin1String("^(e|edit)\\b"), Format_Edit);
m_actions << RebaseAction(QLatin1String("^(s|squash)\\b"), Format_Squash);
m_actions << RebaseAction(QLatin1String("^(f|fixup)\\b"), Format_Fixup);
m_actions << RebaseAction(QLatin1String("^(x|exec)\\b"), Format_Exec);
m_actions << RebaseAction("^(p|pick)\\b", Format_Pick);
m_actions << RebaseAction("^(r|reword)\\b", Format_Reword);
m_actions << RebaseAction("^(e|edit)\\b", Format_Edit);
m_actions << RebaseAction("^(s|squash)\\b", Format_Squash);
m_actions << RebaseAction("^(f|fixup)\\b", Format_Fixup);
m_actions << RebaseAction("^(x|exec)\\b", Format_Exec);
}
void GitRebaseHighlighter::highlightBlock(const QString &text)

View File

@@ -294,7 +294,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters,
[]() { return new GitSubmitEditor(&submitParameters); }));
const QString prefix = QLatin1String("git");
const QString prefix = "git";
m_commandLocator = new CommandLocator("Git", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
@@ -623,7 +623,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(VcsManager::instance(), &VcsManager::repositoryChanged,
this, &GitPlugin::updateBranches, Qt::QueuedConnection);
Utils::MimeDatabase::addMimeTypes(QLatin1String(RC_GIT_MIME_XML));
Utils::MimeDatabase::addMimeTypes(RC_GIT_MIME_XML);
/* "Gerrit" */
m_gerritPlugin = new Gerrit::Internal::GerritPlugin(this);
@@ -783,7 +783,7 @@ void GitPlugin::startRebase()
dialog.setWindowTitle(tr("Interactive Rebase"));
if (!dialog.runDialog(topLevel))
return;
if (m_gitClient->beginStashScope(topLevel, QLatin1String("Rebase-i")))
if (m_gitClient->beginStashScope(topLevel, "Rebase-i"))
m_gitClient->interactiveRebase(topLevel, dialog.commit(), false);
}
@@ -857,7 +857,7 @@ void GitPlugin::gitkForCurrentFolder()
/*
* entire lower part of the code can be easily replaced with one line:
*
* m_gitClient->launchGitK(dir.currentFileDirectory(), QLatin1String("."));
* m_gitClient->launchGitK(dir.currentFileDirectory(), ".");
*
* However, there is a bug in gitk in version 1.7.9.5, and if you run above
* command, there will be no documents listed in lower right section.
@@ -869,7 +869,7 @@ void GitPlugin::gitkForCurrentFolder()
*
*/
QDir dir(state.currentFileDirectory());
if (QFileInfo(dir,QLatin1String(".git")).exists() || dir.cd(QLatin1String(".git"))) {
if (QFileInfo(dir,".git").exists() || dir.cd(".git")) {
m_gitClient->launchGitK(state.currentFileDirectory());
} else {
QString folderName = dir.absolutePath();
@@ -1044,7 +1044,7 @@ bool GitPlugin::submitEditorAboutToClose()
return false;
cleanCommitMessageFile();
if (commitType == FixupCommit) {
if (!m_gitClient->beginStashScope(m_submitRepository, QLatin1String("Rebase-fixup"),
if (!m_gitClient->beginStashScope(m_submitRepository, "Rebase-fixup",
NoPrompt, editor->panelData().pushAction)) {
return false;
}
@@ -1077,13 +1077,13 @@ void GitPlugin::pull()
if (!rebase) {
QString currentBranch = m_gitClient->synchronousCurrentLocalBranch(topLevel);
if (!currentBranch.isEmpty()) {
currentBranch.prepend(QLatin1String("branch."));
currentBranch.append(QLatin1String(".rebase"));
rebase = (m_gitClient->readConfigValue(topLevel, currentBranch) == QLatin1String("true"));
currentBranch.prepend("branch.");
currentBranch.append(".rebase");
rebase = (m_gitClient->readConfigValue(topLevel, currentBranch) == "true");
}
}
if (!m_gitClient->beginStashScope(topLevel, QLatin1String("Pull"), rebase ? Default : AllowUnstashed))
if (!m_gitClient->beginStashScope(topLevel, "Pull", rebase ? Default : AllowUnstashed))
return;
m_gitClient->synchronousPull(topLevel, rebase);
}
@@ -1111,19 +1111,19 @@ void GitPlugin::continueOrAbortCommand()
QObject *action = QObject::sender();
if (action == m_abortMergeAction)
m_gitClient->synchronousMerge(state.topLevel(), QLatin1String("--abort"));
m_gitClient->synchronousMerge(state.topLevel(), "--abort");
else if (action == m_abortRebaseAction)
m_gitClient->rebase(state.topLevel(), QLatin1String("--abort"));
m_gitClient->rebase(state.topLevel(), "--abort");
else if (action == m_abortCherryPickAction)
m_gitClient->synchronousCherryPick(state.topLevel(), QLatin1String("--abort"));
m_gitClient->synchronousCherryPick(state.topLevel(), "--abort");
else if (action == m_abortRevertAction)
m_gitClient->synchronousRevert(state.topLevel(), QLatin1String("--abort"));
m_gitClient->synchronousRevert(state.topLevel(), "--abort");
else if (action == m_continueRebaseAction)
m_gitClient->rebase(state.topLevel(), QLatin1String("--continue"));
m_gitClient->rebase(state.topLevel(), "--continue");
else if (action == m_continueCherryPickAction)
m_gitClient->cherryPick(state.topLevel(), QLatin1String("--continue"));
m_gitClient->cherryPick(state.topLevel(), "--continue");
else if (action == m_continueRevertAction)
m_gitClient->revert(state.topLevel(), QLatin1String("--continue"));
m_gitClient->revert(state.topLevel(), "--continue");
updateContinueAndAbortCommands();
}
@@ -1201,7 +1201,7 @@ void GitPlugin::promptApplyPatch()
void GitPlugin::applyPatch(const QString &workingDirectory, QString file)
{
// Ensure user has been notified about pending changes
if (!m_gitClient->beginStashScope(workingDirectory, QLatin1String("Apply-Patch"), AllowUnstashed))
if (!m_gitClient->beginStashScope(workingDirectory, "Apply-Patch", AllowUnstashed))
return;
// Prompt for file
if (file.isEmpty()) {
@@ -1427,8 +1427,8 @@ void GitPlugin::testStatusParsing()
CommitData data;
QFETCH(FileStates, first);
QFETCH(FileStates, second);
QString output = QLatin1String("## master...origin/master [ahead 1]\n");
output += QString::fromLatin1(QTest::currentDataTag()) + QLatin1String(" main.cpp\n");
QString output = "## master...origin/master [ahead 1]\n";
output += QString::fromLatin1(QTest::currentDataTag()) + " main.cpp\n";
data.parseFilesFromStatus(output);
QCOMPARE(data.files.at(0).first, first);
if (second == UnknownFileState)

View File

@@ -48,9 +48,9 @@ const QLatin1String GitSettings::lastResetIndexKey("LastResetIndex");
GitSettings::GitSettings()
{
setSettingsGroup(QLatin1String("Git"));
setSettingsGroup("Git");
declareKey(binaryPathKey, QLatin1String("git"));
declareKey(binaryPathKey, "git");
declareKey(timeoutKey, Utils::HostOsInfo::isWindowsHost() ? 60 : 30);
declareKey(pullRebaseKey, false);
declareKey(showTagsKey, false);

View File

@@ -189,7 +189,7 @@ void GitSubmitEditor::slotDiffSelected(const QList<int> &rows)
unmergedFiles.push_back(fileName);
} else if (state & StagedFile) {
if (state & (RenamedFile | CopiedFile)) {
const int arrow = fileName.indexOf(QLatin1String(" -> "));
const int arrow = fileName.indexOf(" -> ");
if (arrow != -1) {
stagedFiles.push_back(fileName.left(arrow));
stagedFiles.push_back(fileName.mid(arrow + 4));
@@ -198,7 +198,7 @@ void GitSubmitEditor::slotDiffSelected(const QList<int> &rows)
}
stagedFiles.push_back(fileName);
} else if (state == UntrackedFile) {
Core::EditorManager::openEditor(m_workingDirectory + QLatin1Char('/') + fileName);
Core::EditorManager::openEditor(m_workingDirectory + '/' + fileName);
} else {
unstagedFiles.push_back(fileName);
}

View File

@@ -51,7 +51,7 @@ GitSubmitEditorWidget::GitSubmitEditorWidget() :
m_gitSubmitPanelUi.setupUi(m_gitSubmitPanel);
new GitSubmitHighlighter(descriptionEdit());
m_emailValidator = new QRegExpValidator(QRegExp(QLatin1String("[^@ ]+@[^@ ]+\\.[a-zA-Z]+")), this);
m_emailValidator = new QRegExpValidator(QRegExp("[^@ ]+@[^@ ]+\\.[a-zA-Z]+"), this);
const QPixmap error = Core::Icons::ERROR.pixmap();
m_gitSubmitPanelUi.invalidAuthorLabel->setPixmap(error);
m_gitSubmitPanelUi.invalidEmailLabel->setToolTip(tr("Provide a valid email to commit."));
@@ -66,7 +66,7 @@ GitSubmitEditorWidget::GitSubmitEditorWidget() :
void GitSubmitEditorWidget::setPanelInfo(const GitSubmitEditorPanelInfo &info)
{
m_gitSubmitPanelUi.repositoryLabel->setText(QDir::toNativeSeparators(info.repository));
if (info.branch.contains(QLatin1String("(no branch)")))
if (info.branch.contains("(no branch)"))
m_gitSubmitPanelUi.branchLabel->setText(QString::fromLatin1("<span style=\"color:red\">%1</span>")
.arg(tr("Detached HEAD")));
else
@@ -163,8 +163,8 @@ QString GitSubmitEditorWidget::cleanupDescription(const QString &input) const
{
// We need to manually purge out comment lines starting with
// hash '#' since git does not do that when using -F.
const QChar newLine = QLatin1Char('\n');
const QChar hash = QLatin1Char('#');
const QChar newLine = '\n';
const QChar hash = '#';
QString message = input;
for (int pos = 0; pos < message.size(); ) {
const int newLinePos = message.indexOf(newLine, pos);

View File

@@ -47,7 +47,7 @@ stash@{2}: On <branch>: <message>
bool Stash::parseStashLine(const QString &l)
{
const QChar colon = QLatin1Char(':');
const QChar colon = ':';
const int branchPos = l.indexOf(colon);
if (branchPos < 0)
return false;
@@ -55,7 +55,7 @@ bool Stash::parseStashLine(const QString &l)
if (messagePos < 0)
return false;
// Branch spec
const int onIndex = l.indexOf(QLatin1String("on "), branchPos + 2, Qt::CaseInsensitive);
const int onIndex = l.indexOf("on ", branchPos + 2, Qt::CaseInsensitive);
if (onIndex == -1 || onIndex >= messagePos)
return false;
// Happy!

View File

@@ -47,7 +47,7 @@ protected:
QString trackFile(const QString &repository) override
{
const QString gitDir = m_client->findGitDirForRepository(repository);
return gitDir.isEmpty() ? QString() : (gitDir + QLatin1String("/HEAD"));
return gitDir.isEmpty() ? QString() : (gitDir + "/HEAD");
}
QString refreshTopic(const QString &repository) override
@@ -131,7 +131,7 @@ QString GitVersionControl::vcsTopic(const QString &directory)
QString topic = Core::IVersionControl::vcsTopic(directory);
const QString commandInProgress = m_client->commandInProgressDescription(directory);
if (!commandInProgress.isEmpty())
topic += QLatin1String(" (") + commandInProgress + QLatin1Char(')');
topic += " (" + commandInProgress + ')';
return topic;
}
@@ -140,8 +140,8 @@ Core::ShellCommand *GitVersionControl::createInitialCheckoutCommand(const QStrin
const QString &localName,
const QStringList &extraArgs)
{
QStringList args;
args << QLatin1String("clone") << QLatin1String("--progress") << extraArgs << url << localName;
QStringList args = { "clone", "--progress" };
args << extraArgs << url << localName;
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment());
command->addFlags(VcsBase::VcsCommand::SuppressStdErr);

View File

@@ -153,21 +153,21 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
// Retrieve log using a custom format "Sha1:Subject [(refs)]"
QStringList arguments;
arguments << QLatin1String("--max-count=1000") << QLatin1String("--format=%h:%s %d");
arguments << (commit.isEmpty() ? QLatin1String("HEAD") : commit);
arguments << "--max-count=1000" << "--format=%h:%s %d";
arguments << (commit.isEmpty() ? "HEAD" : commit);
if (!(flags & IncludeRemotes))
arguments << QLatin1String("--not") << QLatin1String("--remotes");
arguments << "--not" << "--remotes";
QString output;
if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput))
return false;
foreach (const QString &line, output.split(QLatin1Char('\n'))) {
const int colonPos = line.indexOf(QLatin1Char(':'));
foreach (const QString &line, output.split('\n')) {
const int colonPos = line.indexOf(':');
if (colonPos != -1) {
QList<QStandardItem *> row;
for (int c = 0; c < ColumnCount; ++c) {
auto item = new QStandardItem;
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
if (line.endsWith(QLatin1Char(')'))) {
if (line.endsWith(')')) {
QFont font = item->font();
font.setBold(true);
item->setFont(font);
@@ -207,9 +207,9 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) :
if (isReset) {
popUpLayout->addWidget(new QLabel(tr("Reset type:"), this));
m_resetTypeComboBox = new QComboBox(this);
m_resetTypeComboBox->addItem(tr("Hard"), QLatin1String("--hard"));
m_resetTypeComboBox->addItem(tr("Mixed"), QLatin1String("--mixed"));
m_resetTypeComboBox->addItem(tr("Soft"), QLatin1String("--soft"));
m_resetTypeComboBox->addItem(tr("Hard"), "--hard");
m_resetTypeComboBox->addItem(tr("Mixed"), "--mixed");
m_resetTypeComboBox->addItem(tr("Soft"), "--soft");
m_resetTypeComboBox->setCurrentIndex(GitPlugin::client()->settings().intValue(
GitSettings::lastResetIndexKey));
popUpLayout->addWidget(m_resetTypeComboBox);

View File

@@ -76,7 +76,7 @@ MergeTool::~MergeTool()
bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
{
QStringList arguments;
arguments << QLatin1String("mergetool") << QLatin1String("-y") << files;
arguments << "mergetool" << "-y" << files;
m_process = new MergeToolProcess(this);
m_process->setWorkingDirectory(workingDirectory);
const Utils::FileName binary = GitPlugin::client()->vcsBinary();
@@ -206,7 +206,7 @@ void MergeTool::chooseAction()
key = button->property("key");
// either the message box was closed without clicking anything, or abort was clicked
if (!key.isValid())
key = QVariant(QLatin1Char('a')); // abort
key = QVariant('a'); // abort
ba.append(key.toChar().toLatin1());
ba.append('\n');
m_process->write(ba);

View File

@@ -165,8 +165,7 @@ void RemoteDialog::pushToRemote()
const int row = indexList.at(0).row();
const QString remoteName = m_remoteModel->remoteName(row);
GitPlugin::client()->push(m_remoteModel->workingDirectory(),
QStringList() << remoteName);
GitPlugin::client()->push(m_remoteModel->workingDirectory(), { remoteName });
}
void RemoteDialog::fetchFromRemote()

View File

@@ -48,9 +48,8 @@ bool RemoteModel::removeRemote(int row)
{
QString output;
QString error;
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory,
QStringList() << QLatin1String("rm") << remoteName(row),
&output, &error);
bool success = GitPlugin::client()->synchronousRemoteCmd(
m_workingDirectory, { "rm", remoteName(row) }, &output, &error);
if (success)
success = refresh(m_workingDirectory, &error);
return success;
@@ -63,9 +62,8 @@ bool RemoteModel::addRemote(const QString &name, const QString &url)
if (name.isEmpty() || url.isEmpty())
return false;
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory,
QStringList() << QLatin1String("add") << name << url,
&output, &error);
bool success = GitPlugin::client()->synchronousRemoteCmd(
m_workingDirectory, { "add", name, url }, &output, &error);
if (success)
success = refresh(m_workingDirectory, &error);
return success;
@@ -75,9 +73,8 @@ bool RemoteModel::renameRemote(const QString &oldName, const QString &newName)
{
QString output;
QString error;
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory,
QStringList() << QLatin1String("rename") << oldName << newName,
&output, &error);
bool success = GitPlugin::client()->synchronousRemoteCmd(
m_workingDirectory, { "rename", oldName, newName }, &output, &error);
if (success)
success = refresh(m_workingDirectory, &error);
return success;
@@ -87,9 +84,8 @@ bool RemoteModel::updateUrl(const QString &name, const QString &newUrl)
{
QString output;
QString error;
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory,
QStringList() << QLatin1String("set-url") << name << newUrl,
&output, &error);
bool success = GitPlugin::client()->synchronousRemoteCmd(
m_workingDirectory, { "set-url", name, newUrl }, &output, &error);
if (success)
success = refresh(m_workingDirectory, &error);
return success;

View File

@@ -59,7 +59,7 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) : VcsClientOptionsPageWi
m_ui.winHomeCheckBox->setVisible(false);
}
m_ui.repBrowserCommandPathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_ui.repBrowserCommandPathChooser->setHistoryCompleter(QLatin1String("Git.RepoCommand.History"));
m_ui.repBrowserCommandPathChooser->setHistoryCompleter("Git.RepoCommand.History");
m_ui.repBrowserCommandPathChooser->setPromptDialogTitle(tr("Git Repository Browser Command"));
}

View File

@@ -206,7 +206,7 @@ void StashDialog::deleteSelection()
errors.push_back(errorMessage);
refresh(m_repository, true);
if (!errors.isEmpty())
warning(title, errors.join(QLatin1Char('\n')));
warning(title, errors.join('\n'));
}
void StashDialog::showCurrent()
@@ -219,21 +219,21 @@ void StashDialog::showCurrent()
// Suggest Branch name to restore 'stash@{0}' -> 'stash0-date'
static inline QString stashRestoreDefaultBranch(QString stash)
{
stash.remove(QLatin1Char('{'));
stash.remove(QLatin1Char('}'));
stash.remove(QLatin1Char('@'));
stash += QLatin1Char('-');
stash += QDateTime::currentDateTime().toString(QLatin1String("yyMMddhhmmss"));
stash.remove('{');
stash.remove('}');
stash.remove('@');
stash += '-';
stash += QDateTime::currentDateTime().toString("yyMMddhhmmss");
return stash;
}
// Return next stash id 'stash@{0}' -> 'stash@{1}'
static inline QString nextStash(const QString &stash)
{
const int openingBracePos = stash.indexOf(QLatin1Char('{'));
const int openingBracePos = stash.indexOf('{');
if (openingBracePos == -1)
return QString();
const int closingBracePos = stash.indexOf(QLatin1Char('}'), openingBracePos + 2);
const int closingBracePos = stash.indexOf('}', openingBracePos + 2);
if (closingBracePos == -1)
return QString();
bool ok;
@@ -242,7 +242,7 @@ static inline QString nextStash(const QString &stash)
return QString();
QString rc = stash.left(openingBracePos + 1);
rc += QString::number(n + 1);
rc += QLatin1Char('}');
rc += '}';
return rc;
}