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
+1 -4
View File
@@ -25,15 +25,12 @@
#include "annotationhighlighter.h" #include "annotationhighlighter.h"
#include <QDebug>
namespace Git { namespace Git {
namespace Internal { namespace Internal {
GitAnnotationHighlighter::GitAnnotationHighlighter(const ChangeNumbers &changeNumbers, GitAnnotationHighlighter::GitAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document) : QTextDocument *document) :
VcsBase::BaseAnnotationHighlighter(changeNumbers, document), VcsBase::BaseAnnotationHighlighter(changeNumbers, document)
m_blank(QLatin1Char(' '))
{ {
} }
+1 -1
View File
@@ -41,7 +41,7 @@ public:
private: private:
QString changeNumber(const QString &block) const override; QString changeNumber(const QString &block) const override;
const QChar m_blank; const QChar m_blank = ' ';
}; };
} // namespace Internal } // namespace Internal
+18 -18
View File
@@ -46,20 +46,20 @@ class BranchNameValidator : public QValidator
public: public:
BranchNameValidator(const QStringList &localBranches, QObject *parent = 0) : BranchNameValidator(const QStringList &localBranches, QObject *parent = 0) :
QValidator(parent), QValidator(parent),
m_invalidChars(QLatin1String( m_invalidChars(
"\\s" // no whitespace "\\s" // no whitespace
"|~" // no "~" "|~" // no "~"
"|\\^" // no "^" "|\\^" // no "^"
"|\\[" // no "[" "|\\[" // no "["
"|\\.\\." // no ".." "|\\.\\." // no ".."
"|/\\." // no slashdot "|/\\." // no slashdot
"|:" // no ":" "|:" // no ":"
"|@\\{" // no "@{" sequence "|@\\{" // no "@{" sequence
"|\\\\" // no backslash "|\\\\" // no backslash
"|//" // no double slash "|//" // no double slash
"|^[/-]" // no leading slash or dash "|^[/-]" // no leading slash or dash
"|\"" // no quotes "|\"" // no quotes
)), ),
m_localBranches(localBranches) m_localBranches(localBranches)
{ {
} }
@@ -70,17 +70,17 @@ public:
{ {
Q_UNUSED(pos) Q_UNUSED(pos)
input.replace(m_invalidChars, QLatin1String("_")); input.replace(m_invalidChars, "_");
// "Intermediate" patterns, may change to Acceptable when user edits further: // "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; 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; 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; return Intermediate;
if (m_localBranches.contains(input, Utils::HostOsInfo::isWindowsHost() if (m_localBranches.contains(input, Utils::HostOsInfo::isWindowsHost()
+7 -9
View File
@@ -172,7 +172,7 @@ void BranchDialog::add()
QString suggestedName; QString suggestedName;
if (!isTag) { if (!isTag) {
QString suggestedNameBase; QString suggestedNameBase;
suggestedNameBase = trackedBranch.mid(trackedBranch.lastIndexOf(QLatin1Char('/')) + 1); suggestedNameBase = trackedBranch.mid(trackedBranch.lastIndexOf('/') + 1);
suggestedName = suggestedNameBase; suggestedName = suggestedNameBase;
int i = 2; int i = 2;
while (localNames.contains(suggestedName)) { while (localNames.contains(suggestedName)) {
@@ -208,7 +208,7 @@ void BranchDialog::checkout()
const QString currentBranch = m_model->fullName(m_model->currentBranch()); const QString currentBranch = m_model->fullName(m_model->currentBranch());
const QString nextBranch = m_model->fullName(idx); const QString nextBranch = m_model->fullName(idx);
const QString popMessageStart = QCoreApplication::applicationName() + const QString popMessageStart = QCoreApplication::applicationName() +
QLatin1Char(' ') + nextBranch + QLatin1String("-AutoStash "); ' ' + nextBranch + "-AutoStash ";
BranchCheckoutDialog branchCheckoutDialog(this, currentBranch, nextBranch); BranchCheckoutDialog branchCheckoutDialog(this, currentBranch, nextBranch);
GitClient *client = GitPlugin::client(); GitClient *client = GitPlugin::client();
@@ -232,12 +232,10 @@ void BranchDialog::checkout()
} else if (branchCheckoutDialog.exec() == QDialog::Accepted) { } else if (branchCheckoutDialog.exec() == QDialog::Accepted) {
if (branchCheckoutDialog.makeStashOfCurrentBranch()) { if (branchCheckoutDialog.makeStashOfCurrentBranch()) {
if (client->synchronousStash(m_repository, if (client->synchronousStash(m_repository, currentBranch + "-AutoStash").isEmpty())
currentBranch + QLatin1String("-AutoStash")).isEmpty()) {
return; return;
}
} else if (branchCheckoutDialog.moveLocalChangesToNextBranch()) { } else if (branchCheckoutDialog.moveLocalChangesToNextBranch()) {
if (!client->beginStashScope(m_repository, QLatin1String("Checkout"), NoPrompt)) if (!client->beginStashScope(m_repository, "Checkout", NoPrompt))
return; return;
} else if (branchCheckoutDialog.discardLocalChanges()) { } else if (branchCheckoutDialog.discardLocalChanges()) {
if (!client->synchronousReset(m_repository)) 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\"?") if (QMessageBox::question(this, tr("Git Reset"), tr("Hard reset branch \"%1\" to \"%2\"?")
.arg(currentName).arg(branchName), .arg(currentName).arg(branchName),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { 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; return;
allowFastForward = (chosen == fastForward); allowFastForward = (chosen == fastForward);
} }
if (client->beginStashScope(m_repository, QLatin1String("merge"), AllowUnstashed)) if (client->beginStashScope(m_repository, "merge", AllowUnstashed))
client->synchronousMerge(m_repository, branch, allowFastForward); client->synchronousMerge(m_repository, branch, allowFastForward);
} }
@@ -387,7 +385,7 @@ void BranchDialog::rebase()
const QString baseBranch = m_model->fullName(idx, true); const QString baseBranch = m_model->fullName(idx, true);
GitClient *client = GitPlugin::client(); GitClient *client = GitPlugin::client();
if (client->beginStashScope(m_repository, QLatin1String("rebase"))) if (client->beginStashScope(m_repository, "rebase"))
client->rebase(m_repository, baseBranch); client->rebase(m_repository, baseBranch);
} }
+31 -42
View File
@@ -54,7 +54,7 @@ class BranchNode
public: public:
BranchNode() : BranchNode() :
parent(0), parent(0),
name(QLatin1String("<ROOT>")) name("<ROOT>")
{ } { }
BranchNode(const QString &n, const QString &s = QString(), const QString &t = QString(), BranchNode(const QString &n, const QString &s = QString(), const QString &t = QString(),
@@ -172,7 +172,7 @@ public:
} }
return names; return names;
} }
return QStringList(fullName().join(QLatin1Char('/'))); return QStringList(fullName().join('/'));
} }
int rowOf(BranchNode *node) int rowOf(BranchNode *node)
@@ -202,8 +202,8 @@ BranchModel::BranchModel(GitClient *client, QObject *parent) :
QTC_CHECK(m_client); QTC_CHECK(m_client);
// Abuse the sha field for ref prefix // Abuse the sha field for ref prefix
m_rootNode->append(new BranchNode(tr("Local Branches"), QLatin1String("refs/heads"))); m_rootNode->append(new BranchNode(tr("Local Branches"), "refs/heads"));
m_rootNode->append(new BranchNode(tr("Remote Branches"), QLatin1String("refs/remotes"))); m_rootNode->append(new BranchNode(tr("Remote Branches"), "refs/remotes"));
} }
BranchModel::~BranchModel() BranchModel::~BranchModel()
@@ -260,7 +260,7 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
case 0: { case 0: {
res = node->name; res = node->name;
if (!node->tracking.isEmpty()) if (!node->tracking.isEmpty())
res += QLatin1String(" [") + node->tracking + QLatin1Char(']'); res += " [" + node->tracking + ']';
break; break;
} }
case 1: case 1:
@@ -316,9 +316,7 @@ bool BranchModel::setData(const QModelIndex &index, const QVariant &value, int r
QString output; QString output;
QString errorMessage; QString errorMessage;
if (!m_client->synchronousBranchCmd(m_workingDirectory, if (!m_client->synchronousBranchCmd(m_workingDirectory,
QStringList() << QLatin1String("-m") { "-m", oldFullName.last(), newFullName.last() },
<< oldFullName.last()
<< newFullName.last(),
&output, &errorMessage)) { &output, &errorMessage)) {
node->name = oldFullName.last(); node->name = oldFullName.last();
VcsOutputWindow::appendError(errorMessage); VcsOutputWindow::appendError(errorMessage);
@@ -362,15 +360,14 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage
} }
m_currentSha = m_client->synchronousTopRevision(workingDirectory); m_currentSha = m_client->synchronousTopRevision(workingDirectory);
QStringList args; const QStringList args = { "--format=%(objectname)\t%(refname)\t%(upstream:short)\t"
args << QLatin1String("--format=%(objectname)\t%(refname)\t%(upstream:short)\t" "%(*objectname)\t%(committerdate:raw)\t%(*committerdate:raw)" };
"%(*objectname)\t%(committerdate:raw)\t%(*committerdate:raw)");
QString output; QString output;
if (!m_client->synchronousForEachRefCmd(workingDirectory, args, &output, errorMessage)) if (!m_client->synchronousForEachRefCmd(workingDirectory, args, &output, errorMessage))
VcsOutputWindow::appendError(*errorMessage); VcsOutputWindow::appendError(*errorMessage);
m_workingDirectory = workingDirectory; m_workingDirectory = workingDirectory;
const QStringList lines = output.split(QLatin1Char('\n')); const QStringList lines = output.split('\n');
foreach (const QString &l, lines) foreach (const QString &l, lines)
parseOutputLine(l); parseOutputLine(l);
@@ -403,8 +400,7 @@ void BranchModel::renameBranch(const QString &oldName, const QString &newName)
{ {
QString errorMessage; QString errorMessage;
QString output; QString output;
if (!m_client->synchronousBranchCmd(m_workingDirectory, if (!m_client->synchronousBranchCmd(m_workingDirectory, { "-m", oldName, newName },
QStringList() << QLatin1String("-m") << oldName << newName,
&output, &errorMessage)) &output, &errorMessage))
VcsOutputWindow::appendError(errorMessage); VcsOutputWindow::appendError(errorMessage);
else else
@@ -415,11 +411,10 @@ void BranchModel::renameTag(const QString &oldName, const QString &newName)
{ {
QString errorMessage; QString errorMessage;
QString output; QString output;
if (!m_client->synchronousTagCmd(m_workingDirectory, QStringList() << newName << oldName, if (!m_client->synchronousTagCmd(m_workingDirectory, { newName, oldName },
&output, &errorMessage) &output, &errorMessage)
|| !m_client->synchronousTagCmd(m_workingDirectory, || !m_client->synchronousTagCmd(m_workingDirectory, { "-d", oldName },
QStringList() << QLatin1String("-d") << oldName, &output, &errorMessage)) {
&output, &errorMessage)) {
VcsOutputWindow::appendError(errorMessage); VcsOutputWindow::appendError(errorMessage);
} else { } else {
refresh(m_workingDirectory, &errorMessage); refresh(m_workingDirectory, &errorMessage);
@@ -451,7 +446,7 @@ QString BranchModel::fullName(const QModelIndex &idx, bool includePrefix) const
if (!node || !node->isLeaf()) if (!node || !node->isLeaf())
return QString(); return QString();
QStringList path = node->fullName(includePrefix); QStringList path = node->fullName(includePrefix);
return path.join(QLatin1Char('/')); return path.join('/');
} }
QStringList BranchModel::localBranchNames() const QStringList BranchModel::localBranchNames() const
@@ -514,10 +509,8 @@ void BranchModel::removeBranch(const QModelIndex &idx)
QString errorMessage; QString errorMessage;
QString output; QString output;
QStringList args;
args << QLatin1String("-D") << branch; if (!m_client->synchronousBranchCmd(m_workingDirectory, { "-D", branch }, &output, &errorMessage)) {
if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage)) {
VcsOutputWindow::appendError(errorMessage); VcsOutputWindow::appendError(errorMessage);
return; return;
} }
@@ -532,10 +525,8 @@ void BranchModel::removeTag(const QModelIndex &idx)
QString errorMessage; QString errorMessage;
QString output; QString output;
QStringList args;
args << QLatin1String("-d") << tag; if (!m_client->synchronousTagCmd(m_workingDirectory, { "-d", tag }, &output, &errorMessage)) {
if (!m_client->synchronousTagCmd(m_workingDirectory, args, &output, &errorMessage)) {
VcsOutputWindow::appendError(errorMessage); VcsOutputWindow::appendError(errorMessage);
return; return;
} }
@@ -561,13 +552,13 @@ bool BranchModel::branchIsMerged(const QModelIndex &idx)
QString errorMessage; QString errorMessage;
QString output; QString output;
QStringList args;
args << QLatin1String("-a") << QLatin1String("--contains") << sha(idx); if (!m_client->synchronousBranchCmd(m_workingDirectory, { "-a", "--contains", sha(idx) },
if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage)) &output, &errorMessage)) {
VcsOutputWindow::appendError(errorMessage); VcsOutputWindow::appendError(errorMessage);
}
QStringList lines = output.split(QLatin1Char('\n'), QString::SkipEmptyParts); QStringList lines = output.split('\n', QString::SkipEmptyParts);
foreach (const QString &l, lines) { foreach (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
@@ -600,9 +591,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
QString errorMessage; QString errorMessage;
QDateTime branchDateTime; QDateTime branchDateTime;
QStringList args; QStringList args = { QLatin1String(track ? "--track" : "--no-track"), name };
args << (track ? QLatin1String("--track") : QLatin1String("--no-track"));
args << name;
if (!fullTrackedBranch.isEmpty()) { if (!fullTrackedBranch.isEmpty()) {
args << fullTrackedBranch; args << fullTrackedBranch;
startSha = sha(startPoint); startSha = sha(startPoint);
@@ -625,7 +614,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
} }
BranchNode *local = m_rootNode->children.at(LocalBranches); 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); const QString leafName = slash == -1 ? name : name.mid(slash + 1);
bool added = false; bool added = false;
if (slash != -1) { if (slash != -1) {
@@ -675,7 +664,7 @@ void BranchModel::parseOutputLine(const QString &line)
return; return;
// objectname, refname, upstream:short, *objectname, committerdate:raw, *committerdate:raw // 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 shaDeref = lineParts.at(3);
const QString sha = shaDeref.isEmpty() ? lineParts.at(0) : shaDeref; const QString sha = shaDeref.isEmpty() ? lineParts.at(0) : shaDeref;
const QString fullName = lineParts.at(1); const QString fullName = lineParts.at(1);
@@ -686,7 +675,7 @@ void BranchModel::parseOutputLine(const QString &line)
if (strDateTime.isEmpty()) if (strDateTime.isEmpty())
strDateTime = lineParts.at(4); strDateTime = lineParts.at(4);
if (!strDateTime.isEmpty()) { 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); dateTime = QDateTime::fromTime_t(timeT);
} }
@@ -702,17 +691,17 @@ void BranchModel::parseOutputLine(const QString &line)
bool showTags = m_client->settings().boolValue(GitSettings::showTagsKey); bool showTags = m_client->settings().boolValue(GitSettings::showTagsKey);
// insert node into tree: // insert node into tree:
QStringList nameParts = fullName.split(QLatin1Char('/')); QStringList nameParts = fullName.split('/');
nameParts.removeFirst(); // remove refs... nameParts.removeFirst(); // remove refs...
BranchNode *root = 0; BranchNode *root = 0;
if (nameParts.first() == QLatin1String("heads")) { if (nameParts.first() == "heads") {
root = m_rootNode->children.at(LocalBranches); root = m_rootNode->children.at(LocalBranches);
} else if (nameParts.first() == QLatin1String("remotes")) { } else if (nameParts.first() == "remotes") {
root = m_rootNode->children.at(RemoteBranches); 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 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); root = m_rootNode->children.at(Tags);
} else { } else {
return; 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 // limit depth of list. Git basically only ever wants one / and considers the rest as part of
// the name. // the name.
while (nameParts.count() > 3) { while (nameParts.count() > 3) {
nameParts[2] = nameParts.at(2) + QLatin1Char('/') + nameParts.at(3); nameParts[2] = nameParts.at(2) + '/' + nameParts.at(3);
nameParts.removeAt(3); nameParts.removeAt(3);
} }
@@ -774,7 +763,7 @@ QString BranchModel::toolTip(const QString &sha) const
// Show the sha description excluding diff as toolTip // Show the sha description excluding diff as toolTip
QString output; QString output;
QString errorMessage; QString errorMessage;
QStringList arguments(QLatin1String("-n1")); QStringList arguments("-n1");
arguments << sha; arguments << sha;
if (!m_client->synchronousLog(m_workingDirectory, arguments, &output, &errorMessage, if (!m_client->synchronousLog(m_workingDirectory, arguments, &output, &errorMessage,
VcsCommand::SuppressCommandLogging)) { VcsCommand::SuppressCommandLogging)) {
+5 -9
View File
@@ -119,7 +119,7 @@ void ChangeSelectionDialog::selectCommitFromRecentHistory()
return; return;
QString commit = change(); QString commit = change();
int tilde = commit.indexOf(QLatin1Char('~')); int tilde = commit.indexOf('~');
if (tilde != -1) if (tilde != -1)
commit.truncate(tilde); commit.truncate(tilde);
LogChangeDialog dialog(false, this); LogChangeDialog dialog(false, this);
@@ -219,12 +219,11 @@ void ChangeSelectionDialog::recalculateCompletion()
return; return;
GitClient *client = GitPlugin::client(); GitClient *client = GitPlugin::client();
QStringList args; VcsBase::VcsCommand *command = client->asyncForEachRefCmd(
args << QLatin1String("--format=%(refname:short)"); workingDir, { "--format=%(refname:short)" });
VcsBase::VcsCommand *command = client->asyncForEachRefCmd(workingDir, args);
connect(this, &QObject::destroyed, command, &VcsBase::VcsCommand::abort); connect(this, &QObject::destroyed, command, &VcsBase::VcsCommand::abort);
connect(command, &VcsBase::VcsCommand::stdOutText, [this](const QString &output) { 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; return;
} }
QStringList args;
args << QLatin1String("show") << QLatin1String("--stat=80") << ref;
m_process = new QProcess(this); m_process = new QProcess(this);
m_process->setWorkingDirectory(workingDir); m_process->setWorkingDirectory(workingDir);
m_process->setProcessEnvironment(m_gitEnvironment); m_process->setProcessEnvironment(m_gitEnvironment);
@@ -255,7 +251,7 @@ void ChangeSelectionDialog::recalculateDetails()
connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
this, &ChangeSelectionDialog::setDetails); this, &ChangeSelectionDialog::setDetails);
m_process->start(m_gitExecutable.toString(), args); m_process->start(m_gitExecutable.toString(), { "show", "--stat=80", ref });
m_process->closeWriteChannel(); m_process->closeWriteChannel();
if (!m_process->waitForStarted()) if (!m_process->waitForStarted())
m_ui->detailsText->setPlainText(tr("Error: Could not start Git.")); m_ui->detailsText->setPlainText(tr("Error: Could not start Git."));
+8 -8
View File
@@ -54,9 +54,9 @@ QString GitSubmitEditorPanelData::authorString() const
if (email.isEmpty()) if (email.isEmpty())
return rc; return rc;
rc += QLatin1String(" <"); rc += " <";
rc += email; rc += email;
rc += QLatin1Char('>'); rc += '>';
return rc; return rc;
} }
@@ -114,7 +114,7 @@ bool CommitData::checkLine(const QString &stateInfo, const QString &file)
{ {
QTC_ASSERT(stateInfo.count() == 2, return false); QTC_ASSERT(stateInfo.count() == 2, return false);
if (stateInfo == QLatin1String("??")) { if (stateInfo == "??") {
files.append(qMakePair(FileStates(UntrackedFile), file)); files.append(qMakePair(FileStates(UntrackedFile), file));
return true; return true;
} }
@@ -143,7 +143,7 @@ bool CommitData::checkLine(const QString &stateInfo, const QString &file)
if (yState != EmptyFileState) { if (yState != EmptyFileState) {
QString newFile = file; QString newFile = file;
if (xState & (RenamedFile | CopiedFile)) if (xState & (RenamedFile | CopiedFile))
newFile = file.mid(file.indexOf(QLatin1String(" -> ")) + 4); newFile = file.mid(file.indexOf(" -> ") + 4);
files.append(qMakePair(yState, newFile)); files.append(qMakePair(yState, newFile));
} }
@@ -159,20 +159,20 @@ bool CommitData::checkLine(const QString &stateInfo, const QString &file)
\endcode */ \endcode */
bool CommitData::parseFilesFromStatus(const QString &output) bool CommitData::parseFilesFromStatus(const QString &output)
{ {
const QStringList lines = output.split(QLatin1Char('\n')); const QStringList lines = output.split('\n');
foreach (const QString &line, lines) { foreach (const QString &line, lines) {
if (line.isEmpty()) if (line.isEmpty())
continue; continue;
if (line.startsWith(QLatin1String("## "))) { if (line.startsWith("## ")) {
// Branch indication: // Branch indication:
panelInfo.branch = line.mid(3); panelInfo.branch = line.mid(3);
continue; continue;
} }
QTC_ASSERT(line.at(2) == QLatin1Char(' '), continue); QTC_ASSERT(line.at(2) == ' ', continue);
QString file = line.mid(3); QString file = line.mid(3);
if (file.startsWith(QLatin1Char('"'))) if (file.startsWith('"'))
file.remove(0, 1).chop(1); file.remove(0, 1).chop(1);
if (!checkLine(line.mid(0, 2), file)) if (!checkLine(line.mid(0, 2), file))
return false; return false;
+6 -6
View File
@@ -39,16 +39,16 @@ void BranchComboBox::init(const QString &repository)
QString currentBranch = GitPlugin::client()->synchronousCurrentLocalBranch(repository); QString currentBranch = GitPlugin::client()->synchronousCurrentLocalBranch(repository);
if (currentBranch.isEmpty()) { if (currentBranch.isEmpty()) {
m_detached = true; m_detached = true;
currentBranch = QLatin1String("HEAD"); currentBranch = "HEAD";
addItem(currentBranch); addItem(currentBranch);
} }
QString output; QString output;
const QString branchPrefix(QLatin1String("refs/heads/")); const QString branchPrefix("refs/heads/");
QStringList args; if (!GitPlugin::client()->synchronousForEachRefCmd(
args << QLatin1String("--format=%(refname)") << branchPrefix; m_repository, { "--format=%(refname)", branchPrefix }, &output)) {
if (!GitPlugin::client()->synchronousForEachRefCmd(m_repository, args, &output))
return; return;
QStringList branches = output.trimmed().split(QLatin1Char('\n')); }
QStringList branches = output.trimmed().split('\n');
foreach (const QString &ref, branches) { foreach (const QString &ref, branches) {
const QString branch = ref.mid(branchPrefix.size()); const QString branch = ref.mid(branchPrefix.size());
addItem(branch); addItem(branch);
+2 -2
View File
@@ -69,7 +69,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
, m_filterLineEdit(new Utils::FancyLineEdit) , m_filterLineEdit(new Utils::FancyLineEdit)
, m_repositoryChooser(new Utils::PathChooser) , m_repositoryChooser(new Utils::PathChooser)
, m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Close)) , 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) , m_fetchRunning(false)
{ {
setWindowTitle(tr("Gerrit %1@%2").arg(p->user, p->host)); setWindowTitle(tr("Gerrit %1@%2").arg(p->user, p->host));
@@ -144,7 +144,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
detailsLayout->addWidget(m_detailsBrowser); detailsLayout->addWidget(m_detailsBrowser);
m_repositoryChooser->setExpectedKind(Utils::PathChooser::Directory); m_repositoryChooser->setExpectedKind(Utils::PathChooser::Directory);
m_repositoryChooser->setHistoryCompleter(QLatin1String("Git.RepoDir.History")); m_repositoryChooser->setHistoryCompleter("Git.RepoDir.History");
QHBoxLayout *repoPathLayout = new QHBoxLayout; QHBoxLayout *repoPathLayout = new QHBoxLayout;
repoPathLayout->addWidget(m_repositoryChooserLabel); repoPathLayout->addWidget(m_repositoryChooserLabel);
repoPathLayout->addWidget(m_repositoryChooser); repoPathLayout->addWidget(m_repositoryChooser);
+39 -39
View File
@@ -86,9 +86,9 @@ QDebug operator<<(QDebug d, const GerritChange &c)
// Format default Url for a change // Format default Url for a change
static inline QString defaultUrl(const QSharedPointer<GerritParameters> &p, int gerritNumber) 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 += p->host;
result += QLatin1Char('/'); result += '/';
result += QString::number(gerritNumber); result += QString::number(gerritNumber);
return result; return result;
} }
@@ -146,7 +146,7 @@ QString GerritPatchSet::approvalsColumn() const
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) { 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); const QChar typeChar = a.type.at(0);
TypeReviewMapIterator it = reviews.find(typeChar); TypeReviewMapIterator it = reviews.find(typeChar);
if (it == reviews.end()) if (it == reviews.end())
@@ -183,7 +183,7 @@ int GerritPatchSet::approvalLevel() const
QString GerritChange::filterString() const QString GerritChange::filterString() const
{ {
const QChar blank = QLatin1Char(' '); const QChar blank = ' ';
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;
@@ -197,10 +197,10 @@ QString GerritChange::filterString() const
QStringList GerritChange::gitFetchArguments(const QSharedPointer<GerritParameters> &p) const QStringList GerritChange::gitFetchArguments(const QSharedPointer<GerritParameters> &p) const
{ {
QStringList arguments; QStringList arguments;
const QString url = QLatin1String("ssh://") + p->sshHostArgument() const QString url = "ssh://" + p->sshHostArgument()
+ QLatin1Char(':') + QString::number(p->port) + QLatin1Char('/') + ':' + QString::number(p->port) + '/'
+ project; + project;
arguments << QLatin1String("fetch") << url << currentPatchSet.ref; arguments << "fetch" << url << currentPatchSet.ref;
return arguments; return arguments;
} }
@@ -276,9 +276,9 @@ QueryContext::QueryContext(const QStringList &queries,
m_progress.setProgressRange(0, m_queries.size()); m_progress.setProgressRange(0, m_queries.size());
// Determine binary and common command line arguments. // Determine binary and common command line arguments.
m_baseArguments << QLatin1String("query") << QLatin1String("--dependencies") m_baseArguments << "query" << "--dependencies"
<< QLatin1String("--current-patch-set") << "--current-patch-set"
<< QLatin1String("--format=JSON"); << "--format=JSON";
m_binary = m_baseArguments.front(); m_binary = m_baseArguments.front();
m_baseArguments.pop_front(); m_baseArguments.pop_front();
@@ -404,7 +404,7 @@ GerritModel::GerritModel(const QSharedPointer<GerritParameters> &p, QObject *par
, m_parameters(p) , m_parameters(p)
{ {
QStringList headers; // Keep in sync with GerritChange::toHtml() QStringList headers; // Keep in sync with GerritChange::toHtml()
headers << QLatin1String("#") << tr("Subject") << tr("Owner") headers << "#" << tr("Subject") << tr("Owner")
<< tr("Updated") << tr("Project") << tr("Updated") << tr("Project")
<< tr("Approvals") << tr("Status"); << tr("Approvals") << tr("Status");
setHorizontalHeaderLabels(headers); setHorizontalHeaderLabels(headers);
@@ -463,7 +463,7 @@ QString GerritModel::toHtml(const QModelIndex& index) const
if (!index.isValid()) if (!index.isValid())
return QString(); return QString();
const GerritChangePtr c = change(index); 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; QString result;
QTextStream str(&result); QTextStream str(&result);
str << "<html><head/><body><table>" str << "<html><head/><body><table>"
@@ -522,14 +522,14 @@ void GerritModel::refresh(const QString &query)
queries.push_back(query); queries.push_back(query);
else else
{ {
const QString statusOpenQuery = QLatin1String("status:open"); const QString statusOpenQuery = "status:open";
if (m_parameters->user.isEmpty()) { if (m_parameters->user.isEmpty()) {
queries.push_back(statusOpenQuery); queries.push_back(statusOpenQuery);
} else { } else {
// Owned by: // Owned by:
queries.push_back(statusOpenQuery + QLatin1String(" owner:") + m_parameters->user); queries.push_back(statusOpenQuery + " owner:" + m_parameters->user);
// For Review by: // 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) QList<GerritChangePtr> &result)
{ {
// The output consists of separate lines containing a document each // The output consists of separate lines containing a document each
const QString typeKey = QLatin1String("type"); const QString typeKey = "type";
const QString dependsOnKey = QLatin1String("dependsOn"); const QString dependsOnKey = "dependsOn";
const QString neededByKey = QLatin1String("neededBy"); const QString neededByKey = "neededBy";
const QString branchKey = QLatin1String("branch"); const QString branchKey = "branch";
const QString numberKey = QLatin1String("number"); const QString numberKey = "number";
const QString ownerKey = QLatin1String("owner"); const QString ownerKey = "owner";
const QString ownerNameKey = QLatin1String("name"); const QString ownerNameKey = "name";
const QString ownerEmailKey = QLatin1String("email"); const QString ownerEmailKey = "email";
const QString statusKey = QLatin1String("status"); const QString statusKey = "status";
const QString projectKey = QLatin1String("project"); const QString projectKey = "project";
const QString titleKey = QLatin1String("subject"); const QString titleKey = "subject";
const QString urlKey = QLatin1String("url"); const QString urlKey = "url";
const QString patchSetKey = QLatin1String("currentPatchSet"); const QString patchSetKey = "currentPatchSet";
const QString refKey = QLatin1String("ref"); const QString refKey = "ref";
const QString approvalsKey = QLatin1String("approvals"); const QString approvalsKey = "approvals";
const QString approvalsValueKey = QLatin1String("value"); const QString approvalsValueKey = "value";
const QString approvalsByKey = QLatin1String("by"); const QString approvalsByKey = "by";
const QString lastUpdatedKey = QLatin1String("lastUpdated"); const QString lastUpdatedKey = "lastUpdated";
const QList<QByteArray> lines = output.split('\n'); const QList<QByteArray> lines = output.split('\n');
const QString approvalsTypeKey = QLatin1String("type"); const QString approvalsTypeKey = "type";
const QString approvalsDescriptionKey = QLatin1String("description"); const QString approvalsDescriptionKey = "description";
bool res = true; bool res = true;
result.clear(); result.clear();
@@ -712,8 +712,8 @@ QList<QStandardItem *> GerritModel::changeToRow(const GerritChangePtr &c) const
row[DateColumn]->setData(c->lastUpdated, SortRole); row[DateColumn]->setData(c->lastUpdated, SortRole);
QString project = c->project; QString project = c->project;
if (c->branch != QLatin1String("master")) if (c->branch != "master")
project += QLatin1String(" (") + c->branch + QLatin1Char(')'); project += " (" + c->branch + ')';
row[ProjectColumn]->setText(project); row[ProjectColumn]->setText(project);
row[StatusColumn]->setText(c->status); row[StatusColumn]->setText(c->status);
row[ApprovalsColumn]->setText(c->currentPatchSet.approvalsColumn()); row[ApprovalsColumn]->setText(c->currentPatchSet.approvalsColumn());
@@ -759,7 +759,7 @@ void GerritModel::queryFinished(const QByteArray &output)
changes.at(i)->depth = 0; changes.at(i)->depth = 0;
} else { } else {
const int dependsOnIndex = numberIndexHash.value(changes.at(i)->dependsOnNumber, -1); 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; changes.at(i)->depth = 0;
} }
} }
@@ -798,7 +798,7 @@ void GerritModel::queryFinished(const QByteArray &output)
for (; changeFromItem(parent)->depth >= 1; parent = parent->parent()) {} for (; changeFromItem(parent)->depth >= 1; parent = parent->parent()) {}
parent->appendRow(newRow); parent->appendRow(newRow);
QString parentFilterString = parent->data(FilterRole).toString(); QString parentFilterString = parent->data(FilterRole).toString();
parentFilterString += QLatin1Char(' '); parentFilterString += ' ';
parentFilterString += newRow.first()->data(FilterRole).toString(); parentFilterString += newRow.first()->data(FilterRole).toString();
parent->setData(QVariant(parentFilterString), FilterRole); parent->setData(QVariant(parentFilterString), FilterRole);
} else { } else {
+2 -2
View File
@@ -93,8 +93,8 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent)
formLayout->addRow(tr("&Host:"), m_hostLineEdit); formLayout->addRow(tr("&Host:"), m_hostLineEdit);
formLayout->addRow(tr("&User:"), m_userLineEdit); formLayout->addRow(tr("&User:"), m_userLineEdit);
m_sshChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); m_sshChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_sshChooser->setCommandVersionArguments(QStringList(QLatin1String("-V"))); m_sshChooser->setCommandVersionArguments(QStringList("-V"));
m_sshChooser->setHistoryCompleter(QLatin1String("Git.SshCommand.History")); m_sshChooser->setHistoryCompleter("Git.SshCommand.History");
formLayout->addRow(tr("&ssh:"), m_sshChooser); formLayout->addRow(tr("&ssh:"), m_sshChooser);
m_portSpinBox->setMinimum(1); m_portSpinBox->setMinimum(1);
m_portSpinBox->setMaximum(65535); m_portSpinBox->setMaximum(65535);
+27 -27
View File
@@ -57,13 +57,13 @@ static inline QString detectSsh()
const QByteArray gitSsh = qgetenv("GIT_SSH"); const QByteArray gitSsh = qgetenv("GIT_SSH");
if (!gitSsh.isEmpty()) if (!gitSsh.isEmpty())
return QString::fromLocal8Bit(gitSsh); return QString::fromLocal8Bit(gitSsh);
QString ssh = QStandardPaths::findExecutable(QLatin1String(defaultSshC)); QString ssh = QStandardPaths::findExecutable(defaultSshC);
if (!ssh.isEmpty()) if (!ssh.isEmpty())
return ssh; return ssh;
if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found. if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found.
Utils::FileName path = GerritPlugin::gitBinDirectory(); Utils::FileName path = GerritPlugin::gitBinDirectory();
if (!path.isEmpty()) if (!path.isEmpty())
ssh = path.appendPath(QLatin1String(defaultSshC)).toString(); ssh = path.appendPath(defaultSshC).toString();
} }
return ssh; return ssh;
} }
@@ -72,17 +72,17 @@ void GerritParameters::setPortFlagBySshType()
{ {
bool isPlink = false; bool isPlink = false;
if (!ssh.isEmpty()) { if (!ssh.isEmpty()) {
const QString version = Utils::PathChooser::toolVersion(ssh, QStringList(QLatin1String("-V"))); const QString version = Utils::PathChooser::toolVersion(ssh, QStringList("-V"));
isPlink = version.contains(QLatin1String("plink"), Qt::CaseInsensitive); isPlink = version.contains("plink", Qt::CaseInsensitive);
} }
portFlag = isPlink ? QLatin1String("-P") : QLatin1String(defaultPortFlag); portFlag = isPlink ? "-P" : defaultPortFlag;
} }
GerritParameters::GerritParameters() GerritParameters::GerritParameters()
: host(QLatin1String(defaultHostC)) : host(defaultHostC)
, port(defaultPort) , port(defaultPort)
, https(true) , https(true)
, portFlag(QLatin1String(defaultPortFlag)) , portFlag(defaultPortFlag)
{ {
} }
@@ -90,13 +90,13 @@ QStringList GerritParameters::baseCommandArguments() const
{ {
QStringList result; QStringList result;
result << ssh << portFlag << QString::number(port) result << ssh << portFlag << QString::number(port)
<< sshHostArgument() << QLatin1String("gerrit"); << sshHostArgument() << "gerrit";
return result; return result;
} }
QString GerritParameters::sshHostArgument() const QString GerritParameters::sshHostArgument() const
{ {
return user.isEmpty() ? host : (user + QLatin1Char('@') + host); return user.isEmpty() ? host : (user + '@' + host);
} }
bool GerritParameters::equals(const GerritParameters &rhs) const bool GerritParameters::equals(const GerritParameters &rhs) const
@@ -107,34 +107,34 @@ bool GerritParameters::equals(const GerritParameters &rhs) const
void GerritParameters::toSettings(QSettings *s) const void GerritParameters::toSettings(QSettings *s) const
{ {
s->beginGroup(QLatin1String(settingsGroupC)); s->beginGroup(settingsGroupC);
s->setValue(QLatin1String(hostKeyC), host); s->setValue(hostKeyC, host);
s->setValue(QLatin1String(userKeyC), user); s->setValue(userKeyC, user);
s->setValue(QLatin1String(portKeyC), port); s->setValue(portKeyC, port);
s->setValue(QLatin1String(portFlagKeyC), portFlag); s->setValue(portFlagKeyC, portFlag);
s->setValue(QLatin1String(sshKeyC), ssh); s->setValue(sshKeyC, ssh);
s->setValue(QLatin1String(httpsKeyC), https); s->setValue(httpsKeyC, https);
s->endGroup(); s->endGroup();
} }
void GerritParameters::saveQueries(QSettings *s) const void GerritParameters::saveQueries(QSettings *s) const
{ {
s->beginGroup(QLatin1String(settingsGroupC)); s->beginGroup(settingsGroupC);
s->setValue(QLatin1String(savedQueriesKeyC), savedQueries.join(QLatin1Char(','))); s->setValue(savedQueriesKeyC, savedQueries.join(','));
s->endGroup(); s->endGroup();
} }
void GerritParameters::fromSettings(const QSettings *s) void GerritParameters::fromSettings(const QSettings *s)
{ {
const QString rootKey = QLatin1String(settingsGroupC) + QLatin1Char('/'); const QString rootKey = QLatin1String(settingsGroupC) + '/';
host = s->value(rootKey + QLatin1String(hostKeyC), QLatin1String(defaultHostC)).toString(); host = s->value(rootKey + hostKeyC, defaultHostC).toString();
user = s->value(rootKey + QLatin1String(userKeyC), QString()).toString(); user = s->value(rootKey + userKeyC, QString()).toString();
ssh = s->value(rootKey + QLatin1String(sshKeyC), QString()).toString(); ssh = s->value(rootKey + sshKeyC, QString()).toString();
port = s->value(rootKey + QLatin1String(portKeyC), QVariant(int(defaultPort))).toInt(); port = s->value(rootKey + portKeyC, QVariant(int(defaultPort))).toInt();
portFlag = s->value(rootKey + QLatin1String(portFlagKeyC), QLatin1String(defaultPortFlag)).toString(); portFlag = s->value(rootKey + portFlagKeyC, defaultPortFlag).toString();
savedQueries = s->value(rootKey + QLatin1String(savedQueriesKeyC), QString()).toString() savedQueries = s->value(rootKey + savedQueriesKeyC, QString()).toString()
.split(QLatin1Char(',')); .split(',');
https = s->value(rootKey + QLatin1String(httpsKeyC), QVariant(true)).toBool(); https = s->value(rootKey + httpsKeyC, QVariant(true)).toBool();
if (ssh.isEmpty()) if (ssh.isEmpty())
ssh = detectSsh(); ssh = detectSsh();
} }
+22 -27
View File
@@ -243,9 +243,9 @@ void FetchContext::processError(QProcess::ProcessError e)
void FetchContext::show() 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); + 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() void FetchContext::cherryPick()
@@ -253,12 +253,12 @@ void FetchContext::cherryPick()
// Point user to errors. // Point user to errors.
VcsBase::VcsOutputWindow::instance()->popup(IOutputPane::ModeSwitch VcsBase::VcsOutputWindow::instance()->popup(IOutputPane::ModeSwitch
| IOutputPane::WithFocus); | IOutputPane::WithFocus);
GitPlugin::client()->synchronousCherryPick(m_repository, QLatin1String("FETCH_HEAD")); GitPlugin::client()->synchronousCherryPick(m_repository, "FETCH_HEAD");
} }
void FetchContext::checkout() void FetchContext::checkout()
{ {
GitPlugin::client()->stashAndCheckout(m_repository, QLatin1String("FETCH_HEAD")); GitPlugin::client()->stashAndCheckout(m_repository, "FETCH_HEAD");
} }
void FetchContext::terminate() void FetchContext::terminate()
@@ -326,31 +326,26 @@ void GerritPlugin::push(const QString &topLevel)
if (dialog.exec() == QDialog::Rejected) if (dialog.exec() == QDialog::Rejected)
return; return;
QStringList args;
m_reviewers = dialog.reviewers(); m_reviewers = dialog.reviewers();
args << dialog.selectedRemoteName();
QString target = dialog.selectedCommit(); QString target = dialog.selectedCommit();
if (target.isEmpty()) if (target.isEmpty())
target = QLatin1String("HEAD"); target = "HEAD";
target += QLatin1String(":refs/") + dialog.selectedPushType() + target += ":refs/" + dialog.selectedPushType() +
QLatin1Char('/') + dialog.selectedRemoteBranchName(); '/' + dialog.selectedRemoteBranchName();
const QString topic = dialog.selectedTopic(); const QString topic = dialog.selectedTopic();
if (!topic.isEmpty()) if (!topic.isEmpty())
target += QLatin1Char('/') + topic; target += '/' + topic;
QStringList options; QStringList options;
const QStringList reviewers = m_reviewers.split(QLatin1Char(','), QString::SkipEmptyParts); const QStringList reviewers = m_reviewers.split(',', QString::SkipEmptyParts);
foreach (const QString &reviewer, reviewers) foreach (const QString &reviewer, reviewers)
options << QLatin1String("r=") + reviewer; options << "r=" + reviewer;
if (!options.isEmpty()) if (!options.isEmpty())
target += QLatin1Char('%') + options.join(QLatin1Char(',')); target += '%' + options.join(',');
args << target; GitPlugin::client()->push(topLevel, { dialog.selectedRemoteName(), target });
GitPlugin::client()->push(topLevel, args);
} }
// Open or raise the Gerrit dialog window. // Open or raise the Gerrit dialog window.
@@ -432,7 +427,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
if (!remotesList.isEmpty()) { if (!remotesList.isEmpty()) {
QStringList remotes = remotesList.values(); QStringList remotes = remotesList.values();
foreach (QString remote, remotes) { foreach (QString remote, remotes) {
if (remote.endsWith(QLatin1String(".git"))) if (remote.endsWith(".git"))
remote.chop(4); remote.chop(4);
if (remote.contains(m_parameters->host) && remote.endsWith(change->project)) { if (remote.contains(m_parameters->host) && remote.endsWith(change->project)) {
verifiedRepository = true; verifiedRepository = true;
@@ -444,11 +439,11 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
SubmoduleDataMap submodules = GitPlugin::client()->submoduleList(repository); SubmoduleDataMap submodules = GitPlugin::client()->submoduleList(repository);
foreach (const SubmoduleData &submoduleData, submodules) { foreach (const SubmoduleData &submoduleData, submodules) {
QString remote = submoduleData.url; QString remote = submoduleData.url;
if (remote.endsWith(QLatin1String(".git"))) if (remote.endsWith(".git"))
remote.chop(4); remote.chop(4);
if (remote.contains(m_parameters->host) && remote.endsWith(change->project) if (remote.contains(m_parameters->host) && remote.endsWith(change->project)
&& QFile::exists(repository + QLatin1Char('/') + submoduleData.dir)) { && QFile::exists(repository + '/' + submoduleData.dir)) {
repository = QDir::cleanPath(repository + QLatin1Char('/') repository = QDir::cleanPath(repository + '/'
+ submoduleData.dir); + submoduleData.dir);
verifiedRepository = true; verifiedRepository = true;
break; break;
@@ -504,18 +499,18 @@ QString GerritPlugin::findLocalRepository(QString project, const QString &branch
{ {
const QStringList gitRepositories = VcsManager::repositories(GitPlugin::instance()->gitVersionControl()); const QStringList gitRepositories = VcsManager::repositories(GitPlugin::instance()->gitVersionControl());
// Determine key (file name) to look for (qt/qtbase->'qtbase'). // Determine key (file name) to look for (qt/qtbase->'qtbase').
const int slashPos = project.lastIndexOf(QLatin1Char('/')); const int slashPos = project.lastIndexOf('/');
if (slashPos != -1) if (slashPos != -1)
project.remove(0, slashPos + 1); project.remove(0, slashPos + 1);
// When looking at branch 1.7, try to check folders // When looking at branch 1.7, try to check folders
// "qtbase_17", 'qtbase1.7' with a semi-smart regular expression. // "qtbase_17", 'qtbase1.7' with a semi-smart regular expression.
QScopedPointer<QRegExp> branchRegexp; QScopedPointer<QRegExp> branchRegexp;
if (!branch.isEmpty() && branch != QLatin1String("master")) { if (!branch.isEmpty() && branch != "master") {
QString branchPattern = branch; QString branchPattern = branch;
branchPattern.replace(QLatin1Char('.'), QLatin1String("[\\.-_]?")); branchPattern.replace('.', "[\\.-_]?");
const QString pattern = QLatin1Char('^') + project const QString pattern = '^' + project
+ QLatin1String("[-_]?") + "[-_]?"
+ branchPattern + QLatin1Char('$'); + branchPattern + '$';
branchRegexp.reset(new QRegExp(pattern)); branchRegexp.reset(new QRegExp(pattern));
if (!branchRegexp->isValid()) if (!branchRegexp->isValid())
branchRegexp.reset(); // Oops. branchRegexp.reset(); // Oops.
+25 -29
View File
@@ -45,7 +45,7 @@ class PushItemDelegate : public IconItemDelegate
{ {
public: public:
PushItemDelegate(LogChangeWidget *widget) 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 output;
QString error; 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(); return QString();
const QString head = QLatin1String("/HEAD"); }
QStringList refs = output.split(QLatin1Char('\n')); const QString head = "/HEAD";
QStringList refs = output.split('\n');
QString remoteTrackingBranch; QString remoteTrackingBranch;
if (localBranch != QLatin1String("HEAD")) if (localBranch != "HEAD")
remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch); remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch);
QString remoteBranch; QString remoteBranch;
@@ -94,31 +93,30 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
void GerritPushDialog::initRemoteBranches() void GerritPushDialog::initRemoteBranches()
{ {
QString output; QString output;
QStringList args; const QString head = "/HEAD";
const QString head = QLatin1String("/HEAD");
QString remotesPrefix(QLatin1String("refs/remotes/")); QString remotesPrefix("refs/remotes/");
args << QLatin1String("--format=%(refname)\t%(committerdate:raw)") if (!GitPlugin::client()->synchronousForEachRefCmd(
<< remotesPrefix; m_workingDir, { "--format=%(refname)\t%(committerdate:raw)", remotesPrefix }, &output)) {
if (!GitPlugin::client()->synchronousForEachRefCmd(m_workingDir, args, &output))
return; return;
}
const QStringList refs = output.split(QLatin1String("\n")); const QStringList refs = output.split("\n");
foreach (const QString &reference, refs) { foreach (const QString &reference, refs) {
QStringList entries = reference.split(QLatin1Char('\t')); QStringList entries = reference.split('\t');
if (entries.count() < 2 || entries.first().endsWith(head)) if (entries.count() < 2 || entries.first().endsWith(head))
continue; continue;
const QString ref = entries.at(0).mid(remotesPrefix.size()); const QString ref = entries.at(0).mid(remotesPrefix.size());
int refBranchIndex = ref.indexOf(QLatin1Char('/')); int refBranchIndex = ref.indexOf('/');
int timeT = entries.at(1).leftRef(entries.at(1).indexOf(QLatin1Char(' '))).toInt(); int timeT = entries.at(1).leftRef(entries.at(1).indexOf(' ')).toInt();
BranchDate bd(ref.mid(refBranchIndex + 1), QDateTime::fromTime_t(timeT).date()); BranchDate bd(ref.mid(refBranchIndex + 1), QDateTime::fromTime_t(timeT).date());
m_remoteBranches.insertMulti(ref.left(refBranchIndex), bd); m_remoteBranches.insertMulti(ref.left(refBranchIndex), bd);
} }
QStringList remotes = GitPlugin::client()->synchronousRemotesList(m_workingDir).keys(); QStringList remotes = GitPlugin::client()->synchronousRemotesList(m_workingDir).keys();
remotes.removeDuplicates(); remotes.removeDuplicates();
{ {
const QString origin = QLatin1String("origin"); const QString origin = "origin";
const QString gerrit = QLatin1String("gerrit"); const QString gerrit = "gerrit";
if (remotes.removeOne(origin)) if (remotes.removeOne(origin))
remotes.prepend(origin); remotes.prepend(origin);
if (remotes.removeOne(gerrit)) if (remotes.removeOne(gerrit))
@@ -155,7 +153,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
updateCommits(m_ui->localBranchComboBox->currentIndex()); updateCommits(m_ui->localBranchComboBox->currentIndex());
setRemoteBranches(); setRemoteBranches();
QRegExpValidator *noSpaceValidator = new QRegExpValidator(QRegExp(QLatin1String("^\\S+$")), this); QRegExpValidator *noSpaceValidator = new QRegExpValidator(QRegExp("^\\S+$"), this);
m_ui->reviewersLineEdit->setText(reviewerList); m_ui->reviewersLineEdit->setText(reviewerList);
m_ui->reviewersLineEdit->setValidator(noSpaceValidator); m_ui->reviewersLineEdit->setValidator(noSpaceValidator);
m_ui->topicLineEdit->setValidator(noSpaceValidator); m_ui->topicLineEdit->setValidator(noSpaceValidator);
@@ -179,16 +177,14 @@ QString GerritPushDialog::selectedCommit() const
QString GerritPushDialog::calculateChangeRange(const QString &branch) QString GerritPushDialog::calculateChangeRange(const QString &branch)
{ {
QString remote = selectedRemoteName(); QString remote = selectedRemoteName();
remote += QLatin1Char('/'); remote += '/';
remote += selectedRemoteBranchName(); remote += selectedRemoteBranchName();
QStringList args(remote + QLatin1String("..") + branch);
args << QLatin1String("--count");
QString number; QString number;
QString error; QString error;
GitPlugin::client()->synchronousRevListCmd(m_workingDir, args, &number, &error); GitPlugin::client()->synchronousRevListCmd(m_workingDir, { remote + ".." + branch, "--count" },
&number, &error);
number.chop(1); number.chop(1);
return number; return number;
@@ -210,7 +206,7 @@ void GerritPushDialog::setChangeRange()
return; return;
} }
m_ui->infoLabel->show(); m_ui->infoLabel->show();
const QString remote = selectedRemoteName() + QLatin1Char('/') + remoteBranchName; const QString remote = selectedRemoteName() + '/' + remoteBranchName;
m_ui->infoLabel->setText( m_ui->infoLabel->setText(
tr("Number of commits between %1 and %2: %3").arg(branch, remote, range)); 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); const QString remoteBranch = determineRemoteBranch(branch);
if (!remoteBranch.isEmpty()) { if (!remoteBranch.isEmpty()) {
const int slash = remoteBranch.indexOf(QLatin1Char('/')); const int slash = remoteBranch.indexOf('/');
m_suggestedRemoteBranch = remoteBranch.mid(slash + 1); m_suggestedRemoteBranch = remoteBranch.mid(slash + 1);
const QString remote = remoteBranch.left(slash); const QString remote = remoteBranch.left(slash);
@@ -285,7 +281,7 @@ QString GerritPushDialog::selectedRemoteBranchName() const
QString GerritPushDialog::selectedPushType() 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 QString GerritPushDialog::selectedTopic() const
+12 -14
View File
@@ -80,6 +80,7 @@ const char GIT_DIRECTORY[] = ".git";
const char graphLogFormatC[] = "%h %d %an %s %ci"; const char graphLogFormatC[] = "%h %d %an %s %ci";
const char HEAD[] = "HEAD"; const char HEAD[] = "HEAD";
const char CHERRY_PICK_HEAD[] = "CHERRY_PICK_HEAD"; const char CHERRY_PICK_HEAD[] = "CHERRY_PICK_HEAD";
const char stashNamePrefix[] = "stash@{";
const char noColorOption[] = "--no-color"; const char noColorOption[] = "--no-color";
const char decorateOption[] = "--decorate"; const char decorateOption[] = "--decorate";
const char showFormatC[] = const char showFormatC[] =
@@ -200,14 +201,13 @@ void BaseController::processOutput(const QString &output)
QStringList BaseController::addHeadWhenCommandInProgress() const QStringList BaseController::addHeadWhenCommandInProgress() const
{ {
QStringList args;
// This is workaround for lack of support for merge commits and resolving conflicts, // 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 // we compare the current state of working tree to the HEAD of current branch
// instead of showing unsupported combined diff format. // instead of showing unsupported combined diff format.
GitClient::CommandInProgress commandInProgress = GitPlugin::client()->checkCommandInProgress(m_directory); GitClient::CommandInProgress commandInProgress = GitPlugin::client()->checkCommandInProgress(m_directory);
if (commandInProgress != GitClient::NoCommand) if (commandInProgress != GitClient::NoCommand)
args << HEAD; return { HEAD };
return args; return QStringList();
} }
class RepositoryDiffController : public BaseController class RepositoryDiffController : public BaseController
@@ -446,7 +446,7 @@ public:
m_ignoreWSButton->setVisible(diffButton->isChecked()); m_ignoreWSButton->setVisible(diffButton->isChecked());
const QStringList graphArguments = { const QStringList graphArguments = {
"--graph", "--oneline", "--topo-order", "--graph", "--oneline", "--topo-order",
(QLatin1String("--pretty=format:") + graphLogFormatC) QLatin1String("--pretty=format:") + graphLogFormatC
}; };
QToolButton *graphButton = addToggleButton(graphArguments, tr("Graph"), QToolButton *graphButton = addToggleButton(graphArguments, tr("Graph"),
tr("Show textual graph log.")); tr("Show textual graph log."));
@@ -581,8 +581,6 @@ static inline void msgCannotRun(const QStringList &args, const QString &workingD
// ---------------- GitClient // ---------------- GitClient
const char *GitClient::stashNamePrefix = "stash@{";
GitClient::GitClient() : VcsBase::VcsBaseClientImpl(new GitSettings), GitClient::GitClient() : VcsBase::VcsBaseClientImpl(new GitSettings),
m_cachedGitVersion(0), m_cachedGitVersion(0),
m_disableEditor(false) m_disableEditor(false)
@@ -741,7 +739,7 @@ void GitClient::diffFiles(const QString &workingDirectory,
const QStringList &unstagedFileNames, const QStringList &unstagedFileNames,
const QStringList &stagedFileNames) const const QStringList &stagedFileNames) const
{ {
requestReload(QLatin1String("Files:") + workingDirectory, requestReload("Files:" + workingDirectory,
workingDirectory, tr("Git Diff Files"), workingDirectory, tr("Git Diff Files"),
[this, workingDirectory, stagedFileNames, unstagedFileNames] [this, workingDirectory, stagedFileNames, unstagedFileNames]
(IDocument *doc) -> DiffEditorController* { (IDocument *doc) -> DiffEditorController* {
@@ -752,7 +750,7 @@ void GitClient::diffFiles(const QString &workingDirectory,
void GitClient::diffProject(const QString &workingDirectory, const QString &projectDirectory) const void GitClient::diffProject(const QString &workingDirectory, const QString &projectDirectory) const
{ {
requestReload(QLatin1String("Project:") + workingDirectory, requestReload("Project:" + workingDirectory,
workingDirectory, tr("Git Diff Project"), workingDirectory, tr("Git Diff Project"),
[this, workingDirectory, projectDirectory] [this, workingDirectory, projectDirectory]
(IDocument *doc) -> DiffEditorController* { (IDocument *doc) -> DiffEditorController* {
@@ -763,7 +761,7 @@ void GitClient::diffProject(const QString &workingDirectory, const QString &proj
void GitClient::diffRepository(const QString &workingDirectory) void GitClient::diffRepository(const QString &workingDirectory)
{ {
requestReload(QLatin1String("Repository:") + workingDirectory, requestReload("Repository:" + workingDirectory,
workingDirectory, tr("Git Diff Repository"), workingDirectory, tr("Git Diff Repository"),
[this, workingDirectory](IDocument *doc) -> DiffEditorController* { [this, workingDirectory](IDocument *doc) -> DiffEditorController* {
return new RepositoryDiffController(doc, workingDirectory); 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 title = tr("Git Diff \"%1\"").arg(fileName);
const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName); const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName);
const QString documentId = QLatin1String("File:") + sourceFile; const QString documentId = "File:" + sourceFile;
requestReload(documentId, sourceFile, title, requestReload(documentId, sourceFile, title,
[this, workingDirectory, fileName] [this, workingDirectory, fileName]
(IDocument *doc) -> DiffEditorController* { (IDocument *doc) -> DiffEditorController* {
@@ -786,7 +784,7 @@ void GitClient::diffBranch(const QString &workingDirectory,
const QString &branchName) const const QString &branchName) const
{ {
const QString title = tr("Git Diff Branch \"%1\"").arg(branchName); 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, requestReload(documentId, workingDirectory, title,
[this, workingDirectory, branchName] [this, workingDirectory, branchName]
(IDocument *doc) -> DiffEditorController* { (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); const QString repoDirectory = VcsManager::findTopLevelForDirectory(workingDirectory);
if (!repoDirectory.isEmpty()) if (!repoDirectory.isEmpty())
workingDirectory = repoDirectory; workingDirectory = repoDirectory;
const QString documentId = QLatin1String("Show:") + id; const QString documentId = "Show:" + id;
requestReload(documentId, source, title, requestReload(documentId, source, title,
[this, workingDirectory, id] [this, workingDirectory, id]
(IDocument *doc) -> DiffEditorController* { (IDocument *doc) -> DiffEditorController* {
@@ -1531,7 +1529,7 @@ bool GitClient::stashNameFromMessage(const QString &workingDirectory,
QString *errorMessage) const QString *errorMessage) const
{ {
// All happy // All happy
if (message.startsWith(QLatin1String(stashNamePrefix))) { if (message.startsWith(stashNamePrefix)) {
*name = message; *name = message;
return true; return true;
} }
@@ -2645,7 +2643,7 @@ void GitClient::revert(const QStringList &files, bool revertStaging)
void GitClient::fetch(const QString &workingDirectory, const QString &remote) 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 *command = vcsExec(workingDirectory, arguments, nullptr, true,
VcsCommand::ShowSuccessMessage); VcsCommand::ShowSuccessMessage);
connect(command, &VcsCommand::success, connect(command, &VcsCommand::success,
-2
View File
@@ -121,8 +121,6 @@ public:
PushAction m_pushAction = NoPush; PushAction m_pushAction = NoPush;
}; };
static const char *stashNamePrefix;
explicit GitClient(); explicit GitClient();
Utils::FileName vcsBinary() const override; Utils::FileName vcsBinary() const override;
+15 -18
View File
@@ -59,7 +59,7 @@ namespace Git {
namespace Internal { namespace Internal {
GitEditorWidget::GitEditorWidget() : GitEditorWidget::GitEditorWidget() :
m_changeNumberPattern(QLatin1String(CHANGE_PATTERN)) m_changeNumberPattern(CHANGE_PATTERN)
{ {
QTC_ASSERT(m_changeNumberPattern.isValid(), return); QTC_ASSERT(m_changeNumberPattern.isValid(), return);
/* Diff format: /* Diff format:
@@ -68,8 +68,8 @@ GitEditorWidget::GitEditorWidget() :
--- a/src/plugins/git/giteditor.cpp --- a/src/plugins/git/giteditor.cpp
+++ b/src/plugins/git/giteditor.cpp +++ b/src/plugins/git/giteditor.cpp
*/ */
setDiffFilePattern(QRegExp(QLatin1String("^(?:diff --git a/|index |[+-]{3} (?:/dev/null|[ab]/(.+$)))"))); setDiffFilePattern(QRegExp("^(?:diff --git a/|index |[+-]{3} (?:/dev/null|[ab]/(.+$)))"));
setLogEntryPattern(QRegExp(QLatin1String("^commit ([0-9a-f]{8})[0-9a-f]{32}"))); setLogEntryPattern(QRegExp("^commit ([0-9a-f]{8})[0-9a-f]{32}"));
setAnnotateRevisionTextFormat(tr("&Blame %1")); setAnnotateRevisionTextFormat(tr("&Blame %1"));
setAnnotatePreviousRevisionTextFormat(tr("Blame &Parent Revision %1")); setAnnotatePreviousRevisionTextFormat(tr("Blame &Parent Revision %1"));
} }
@@ -81,11 +81,11 @@ QSet<QString> GitEditorWidget::annotationChanges() const
if (txt.isEmpty()) if (txt.isEmpty())
return changes; return changes;
// Hunt for first change number in annotation: "<change>:" // Hunt for first change number in annotation: "<change>:"
QRegExp r(QLatin1String("^(" CHANGE_PATTERN ") ")); QRegExp r("^(" CHANGE_PATTERN ") ");
QTC_ASSERT(r.isValid(), return changes); QTC_ASSERT(r.isValid(), return changes);
if (r.indexIn(txt) != -1) { if (r.indexIn(txt) != -1) {
changes.insert(r.cap(1)); changes.insert(r.cap(1));
r.setPattern(QLatin1String("\n(" CHANGE_PATTERN ") ")); r.setPattern("\n(" CHANGE_PATTERN ") ");
QTC_ASSERT(r.isValid(), return changes); QTC_ASSERT(r.isValid(), return changes);
int pos = 0; int pos = 0;
while ((pos = r.indexIn(txt, pos)) != -1) { while ((pos = r.indexIn(txt, pos)) != -1) {
@@ -126,8 +126,8 @@ static QString sanitizeBlameOutput(const QString &b)
const bool omitDate = GitPlugin::client()->settings().boolValue( const bool omitDate = GitPlugin::client()->settings().boolValue(
GitSettings::omitAnnotationDateKey); GitSettings::omitAnnotationDateKey);
const QChar space(QLatin1Char(' ')); const QChar space(' ');
const int parenPos = b.indexOf(QLatin1Char(')')); const int parenPos = b.indexOf(')');
if (parenPos == -1) if (parenPos == -1)
return b; 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 // Copy over the parts that have not changed into a new byte array
QString result; QString result;
int prevPos = 0; int prevPos = 0;
int pos = b.indexOf(QLatin1Char('\n'), 0) + 1; int pos = b.indexOf('\n', 0) + 1;
forever { forever {
QTC_CHECK(prevPos < pos); QTC_CHECK(prevPos < pos);
int afterParen = prevPos + parenPos; int afterParen = prevPos + parenPos;
@@ -165,7 +165,7 @@ static QString sanitizeBlameOutput(const QString &b)
if (pos == b.size()) if (pos == b.size())
break; break;
pos = b.indexOf(QLatin1Char('\n'), pos) + 1; pos = b.indexOf('\n', pos) + 1;
if (pos == 0) // indexOf returned -1 if (pos == 0) // indexOf returned -1
pos = b.size(); pos = b.size();
} }
@@ -190,8 +190,7 @@ void GitEditorWidget::setPlainText(const QString &text)
void GitEditorWidget::checkoutChange() void GitEditorWidget::checkoutChange()
{ {
GitPlugin::client()->stashAndCheckout( GitPlugin::client()->stashAndCheckout(sourceWorkingDirectory(), m_currentChange);
sourceWorkingDirectory(), m_currentChange);
} }
void GitEditorWidget::resetChange(const QByteArray &resetType) void GitEditorWidget::resetChange(const QByteArray &resetType)
@@ -202,14 +201,12 @@ void GitEditorWidget::resetChange(const QByteArray &resetType)
void GitEditorWidget::cherryPickChange() void GitEditorWidget::cherryPickChange()
{ {
GitPlugin::client()->synchronousCherryPick( GitPlugin::client()->synchronousCherryPick(sourceWorkingDirectory(), m_currentChange);
sourceWorkingDirectory(), m_currentChange);
} }
void GitEditorWidget::revertChange() void GitEditorWidget::revertChange()
{ {
GitPlugin::client()->synchronousRevert( GitPlugin::client()->synchronousRevert(sourceWorkingDirectory(), m_currentChange);
sourceWorkingDirectory(), m_currentChange);
} }
void GitEditorWidget::logChange() void GitEditorWidget::logChange()
@@ -229,9 +226,9 @@ void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert)
patchFile.write(chunk.chunk); patchFile.write(chunk.chunk);
patchFile.close(); patchFile.close();
QStringList args = QStringList() << QLatin1String("--cached"); QStringList args = { "--cached" };
if (revert) if (revert)
args << QLatin1String("--reverse"); args << "--reverse";
QString errorMessage; QString errorMessage;
if (GitPlugin::client()->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) { if (GitPlugin::client()->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) {
if (errorMessage.isEmpty()) if (errorMessage.isEmpty())
@@ -362,7 +359,7 @@ QString GitEditorWidget::fileNameForLine(int line) const
// 7971b6e7 share/qtcreator/dumper/dumper.py (hjk // 7971b6e7 share/qtcreator/dumper/dumper.py (hjk
QTextBlock block = document()->findBlockByLineNumber(line - 1); QTextBlock block = document()->findBlockByLineNumber(line - 1);
QTC_ASSERT(block.isValid(), return source()); 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) { if (renameExp.indexIn(block.text()) != -1) {
const QString fileName = renameExp.cap(1).trimmed(); const QString fileName = renameExp.cap(1).trimmed();
if (!fileName.isEmpty()) if (!fileName.isEmpty())
+17 -17
View File
@@ -94,7 +94,7 @@ public:
QString filePath = line.left(lineSeparator); QString filePath = line.left(lineSeparator);
if (!m_ref.isEmpty() && filePath.startsWith(m_ref)) if (!m_ref.isEmpty() && filePath.startsWith(m_ref))
filePath.remove(0, m_ref.length()); 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); const int textSeparator = line.indexOf(QChar::Null, lineSeparator + 1);
single.lineNumber = line.mid(lineSeparator + 1, textSeparator - lineSeparator - 1).toInt(); single.lineNumber = line.mid(lineSeparator + 1, textSeparator - lineSeparator - 1).toInt();
QString text = line.mid(textSeparator + 1); QString text = line.mid(textSeparator + 1);
@@ -133,25 +133,25 @@ public:
void exec() void exec()
{ {
QStringList arguments; QStringList arguments;
arguments << QLatin1String("-c") << QLatin1String("color.grep.match=bold red") arguments << "-c" << "color.grep.match=bold red"
<< QLatin1String("grep") << QLatin1String("-zn") << "grep" << "-zn"
<< QLatin1String("--no-full-name") << "--no-full-name"
<< QLatin1String("--color=always"); << "--color=always";
if (!(m_parameters.flags & FindCaseSensitively)) if (!(m_parameters.flags & FindCaseSensitively))
arguments << QLatin1String("-i"); arguments << "-i";
if (m_parameters.flags & FindWholeWords) if (m_parameters.flags & FindWholeWords)
arguments << QLatin1String("-w"); arguments << "-w";
if (m_parameters.flags & FindRegularExpression) if (m_parameters.flags & FindRegularExpression)
arguments << QLatin1String("-P"); arguments << "-P";
else else
arguments << QLatin1String("-F"); arguments << "-F";
arguments << m_parameters.text; arguments << m_parameters.text;
GitGrepParameters params = m_parameters.extensionParameters.value<GitGrepParameters>(); GitGrepParameters params = m_parameters.extensionParameters.value<GitGrepParameters>();
if (!params.ref.isEmpty()) { if (!params.ref.isEmpty()) {
arguments << params.ref; 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)); QScopedPointer<VcsCommand> command(GitPlugin::client()->createCommand(m_directory));
command->addFlags(VcsCommand::SilentOutput | VcsCommand::SuppressFailMessage); command->addFlags(VcsCommand::SilentOutput | VcsCommand::SuppressFailMessage);
command->setProgressiveOutput(true); command->setProgressiveOutput(true);
@@ -212,7 +212,7 @@ GitGrep::GitGrep()
m_treeLineEdit->setPlaceholderText(tr("Tree (optional)")); m_treeLineEdit->setPlaceholderText(tr("Tree (optional)"));
m_treeLineEdit->setToolTip(tr("Can be HEAD, tag, local or remote branch, or a commit hash.\n" 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.")); "Leave empty to search through the file system."));
const QRegularExpression refExpression(QLatin1String("[\\S]*")); const QRegularExpression refExpression("[\\S]*");
m_treeLineEdit->setValidator(new QRegularExpressionValidator(refExpression, this)); m_treeLineEdit->setValidator(new QRegularExpressionValidator(refExpression, this));
layout->addWidget(m_treeLineEdit); layout->addWidget(m_treeLineEdit);
TextEditor::FindInFiles *findInFiles = TextEditor::FindInFiles::instance(); TextEditor::FindInFiles *findInFiles = TextEditor::FindInFiles::instance();
@@ -267,14 +267,14 @@ QVariant GitGrep::parameters() const
void GitGrep::readSettings(QSettings *settings) void GitGrep::readSettings(QSettings *settings)
{ {
m_enabledCheckBox->setChecked(settings->value(QLatin1String(EnableGitGrep), false).toBool()); m_enabledCheckBox->setChecked(settings->value(EnableGitGrep, false).toBool());
m_treeLineEdit->setText(settings->value(QLatin1String(GitGrepRef)).toString()); m_treeLineEdit->setText(settings->value(GitGrepRef).toString());
} }
void GitGrep::writeSettings(QSettings *settings) const void GitGrep::writeSettings(QSettings *settings) const
{ {
settings->setValue(QLatin1String(EnableGitGrep), m_enabledCheckBox->isChecked()); settings->setValue(EnableGitGrep, m_enabledCheckBox->isChecked());
settings->setValue(QLatin1String(GitGrepRef), m_treeLineEdit->text()); settings->setValue(GitGrepRef, m_treeLineEdit->text());
} }
QFuture<FileSearchResultList> GitGrep::executeSearch( QFuture<FileSearchResultList> GitGrep::executeSearch(
@@ -293,7 +293,7 @@ IEditor *GitGrep::openEditor(const SearchResultItem &item,
QByteArray content; QByteArray content;
const QString topLevel = parameters.additionalParameters.toString(); const QString topLevel = parameters.additionalParameters.toString();
const QString relativePath = QDir(topLevel).relativeFilePath(path); 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)) { &content, nullptr)) {
return nullptr; return nullptr;
} }
+10 -10
View File
@@ -42,8 +42,8 @@ GitSubmitHighlighter::GitSubmitHighlighter(QTextEdit * parent) :
categories << TextEditor::C_COMMENT; categories << TextEditor::C_COMMENT;
setTextFormatCategories(categories); setTextFormatCategories(categories);
m_keywordPattern.setPattern(QLatin1String("^[\\w-]+:")); m_keywordPattern.setPattern("^[\\w-]+:");
m_hashChar = QLatin1Char('#'); m_hashChar = '#';
QTC_CHECK(m_keywordPattern.isValid()); QTC_CHECK(m_keywordPattern.isValid());
} }
@@ -95,8 +95,8 @@ GitRebaseHighlighter::RebaseAction::RebaseAction(const QString &regexp,
GitRebaseHighlighter::GitRebaseHighlighter(QTextDocument *parent) : GitRebaseHighlighter::GitRebaseHighlighter(QTextDocument *parent) :
TextEditor::SyntaxHighlighter(parent), TextEditor::SyntaxHighlighter(parent),
m_hashChar(QLatin1Char('#')), m_hashChar('#'),
m_changeNumberPattern(QLatin1String(CHANGE_PATTERN)) m_changeNumberPattern(CHANGE_PATTERN)
{ {
static QVector<TextEditor::TextStyle> categories; static QVector<TextEditor::TextStyle> categories;
if (categories.isEmpty()) { if (categories.isEmpty()) {
@@ -112,12 +112,12 @@ GitRebaseHighlighter::GitRebaseHighlighter(QTextDocument *parent) :
} }
setTextFormatCategories(categories); setTextFormatCategories(categories);
m_actions << RebaseAction(QLatin1String("^(p|pick)\\b"), Format_Pick); m_actions << RebaseAction("^(p|pick)\\b", Format_Pick);
m_actions << RebaseAction(QLatin1String("^(r|reword)\\b"), Format_Reword); m_actions << RebaseAction("^(r|reword)\\b", Format_Reword);
m_actions << RebaseAction(QLatin1String("^(e|edit)\\b"), Format_Edit); m_actions << RebaseAction("^(e|edit)\\b", Format_Edit);
m_actions << RebaseAction(QLatin1String("^(s|squash)\\b"), Format_Squash); m_actions << RebaseAction("^(s|squash)\\b", Format_Squash);
m_actions << RebaseAction(QLatin1String("^(f|fixup)\\b"), Format_Fixup); m_actions << RebaseAction("^(f|fixup)\\b", Format_Fixup);
m_actions << RebaseAction(QLatin1String("^(x|exec)\\b"), Format_Exec); m_actions << RebaseAction("^(x|exec)\\b", Format_Exec);
} }
void GitRebaseHighlighter::highlightBlock(const QString &text) void GitRebaseHighlighter::highlightBlock(const QString &text)
+20 -20
View File
@@ -294,7 +294,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters, addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters,
[]() { return new GitSubmitEditor(&submitParameters); })); []() { return new GitSubmitEditor(&submitParameters); }));
const QString prefix = QLatin1String("git"); const QString prefix = "git";
m_commandLocator = new CommandLocator("Git", prefix, prefix); m_commandLocator = new CommandLocator("Git", prefix, prefix);
addAutoReleasedObject(m_commandLocator); addAutoReleasedObject(m_commandLocator);
@@ -623,7 +623,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(VcsManager::instance(), &VcsManager::repositoryChanged, connect(VcsManager::instance(), &VcsManager::repositoryChanged,
this, &GitPlugin::updateBranches, Qt::QueuedConnection); this, &GitPlugin::updateBranches, Qt::QueuedConnection);
Utils::MimeDatabase::addMimeTypes(QLatin1String(RC_GIT_MIME_XML)); Utils::MimeDatabase::addMimeTypes(RC_GIT_MIME_XML);
/* "Gerrit" */ /* "Gerrit" */
m_gerritPlugin = new Gerrit::Internal::GerritPlugin(this); m_gerritPlugin = new Gerrit::Internal::GerritPlugin(this);
@@ -783,7 +783,7 @@ void GitPlugin::startRebase()
dialog.setWindowTitle(tr("Interactive Rebase")); dialog.setWindowTitle(tr("Interactive Rebase"));
if (!dialog.runDialog(topLevel)) if (!dialog.runDialog(topLevel))
return; return;
if (m_gitClient->beginStashScope(topLevel, QLatin1String("Rebase-i"))) if (m_gitClient->beginStashScope(topLevel, "Rebase-i"))
m_gitClient->interactiveRebase(topLevel, dialog.commit(), false); 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: * 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 * 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. * command, there will be no documents listed in lower right section.
@@ -869,7 +869,7 @@ void GitPlugin::gitkForCurrentFolder()
* *
*/ */
QDir dir(state.currentFileDirectory()); 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()); m_gitClient->launchGitK(state.currentFileDirectory());
} else { } else {
QString folderName = dir.absolutePath(); QString folderName = dir.absolutePath();
@@ -1044,7 +1044,7 @@ bool GitPlugin::submitEditorAboutToClose()
return false; return false;
cleanCommitMessageFile(); cleanCommitMessageFile();
if (commitType == FixupCommit) { if (commitType == FixupCommit) {
if (!m_gitClient->beginStashScope(m_submitRepository, QLatin1String("Rebase-fixup"), if (!m_gitClient->beginStashScope(m_submitRepository, "Rebase-fixup",
NoPrompt, editor->panelData().pushAction)) { NoPrompt, editor->panelData().pushAction)) {
return false; return false;
} }
@@ -1077,13 +1077,13 @@ void GitPlugin::pull()
if (!rebase) { if (!rebase) {
QString currentBranch = m_gitClient->synchronousCurrentLocalBranch(topLevel); QString currentBranch = m_gitClient->synchronousCurrentLocalBranch(topLevel);
if (!currentBranch.isEmpty()) { if (!currentBranch.isEmpty()) {
currentBranch.prepend(QLatin1String("branch.")); currentBranch.prepend("branch.");
currentBranch.append(QLatin1String(".rebase")); currentBranch.append(".rebase");
rebase = (m_gitClient->readConfigValue(topLevel, currentBranch) == QLatin1String("true")); 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; return;
m_gitClient->synchronousPull(topLevel, rebase); m_gitClient->synchronousPull(topLevel, rebase);
} }
@@ -1111,19 +1111,19 @@ void GitPlugin::continueOrAbortCommand()
QObject *action = QObject::sender(); QObject *action = QObject::sender();
if (action == m_abortMergeAction) if (action == m_abortMergeAction)
m_gitClient->synchronousMerge(state.topLevel(), QLatin1String("--abort")); m_gitClient->synchronousMerge(state.topLevel(), "--abort");
else if (action == m_abortRebaseAction) else if (action == m_abortRebaseAction)
m_gitClient->rebase(state.topLevel(), QLatin1String("--abort")); m_gitClient->rebase(state.topLevel(), "--abort");
else if (action == m_abortCherryPickAction) else if (action == m_abortCherryPickAction)
m_gitClient->synchronousCherryPick(state.topLevel(), QLatin1String("--abort")); m_gitClient->synchronousCherryPick(state.topLevel(), "--abort");
else if (action == m_abortRevertAction) else if (action == m_abortRevertAction)
m_gitClient->synchronousRevert(state.topLevel(), QLatin1String("--abort")); m_gitClient->synchronousRevert(state.topLevel(), "--abort");
else if (action == m_continueRebaseAction) else if (action == m_continueRebaseAction)
m_gitClient->rebase(state.topLevel(), QLatin1String("--continue")); m_gitClient->rebase(state.topLevel(), "--continue");
else if (action == m_continueCherryPickAction) else if (action == m_continueCherryPickAction)
m_gitClient->cherryPick(state.topLevel(), QLatin1String("--continue")); m_gitClient->cherryPick(state.topLevel(), "--continue");
else if (action == m_continueRevertAction) else if (action == m_continueRevertAction)
m_gitClient->revert(state.topLevel(), QLatin1String("--continue")); m_gitClient->revert(state.topLevel(), "--continue");
updateContinueAndAbortCommands(); updateContinueAndAbortCommands();
} }
@@ -1201,7 +1201,7 @@ void GitPlugin::promptApplyPatch()
void GitPlugin::applyPatch(const QString &workingDirectory, QString file) void GitPlugin::applyPatch(const QString &workingDirectory, QString file)
{ {
// Ensure user has been notified about pending changes // 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; return;
// Prompt for file // Prompt for file
if (file.isEmpty()) { if (file.isEmpty()) {
@@ -1427,8 +1427,8 @@ void GitPlugin::testStatusParsing()
CommitData data; CommitData data;
QFETCH(FileStates, first); QFETCH(FileStates, first);
QFETCH(FileStates, second); QFETCH(FileStates, second);
QString output = QLatin1String("## master...origin/master [ahead 1]\n"); QString output = "## master...origin/master [ahead 1]\n";
output += QString::fromLatin1(QTest::currentDataTag()) + QLatin1String(" main.cpp\n"); output += QString::fromLatin1(QTest::currentDataTag()) + " main.cpp\n";
data.parseFilesFromStatus(output); data.parseFilesFromStatus(output);
QCOMPARE(data.files.at(0).first, first); QCOMPARE(data.files.at(0).first, first);
if (second == UnknownFileState) if (second == UnknownFileState)
+2 -2
View File
@@ -48,9 +48,9 @@ const QLatin1String GitSettings::lastResetIndexKey("LastResetIndex");
GitSettings::GitSettings() GitSettings::GitSettings()
{ {
setSettingsGroup(QLatin1String("Git")); setSettingsGroup("Git");
declareKey(binaryPathKey, QLatin1String("git")); declareKey(binaryPathKey, "git");
declareKey(timeoutKey, Utils::HostOsInfo::isWindowsHost() ? 60 : 30); declareKey(timeoutKey, Utils::HostOsInfo::isWindowsHost() ? 60 : 30);
declareKey(pullRebaseKey, false); declareKey(pullRebaseKey, false);
declareKey(showTagsKey, false); declareKey(showTagsKey, false);
+2 -2
View File
@@ -189,7 +189,7 @@ void GitSubmitEditor::slotDiffSelected(const QList<int> &rows)
unmergedFiles.push_back(fileName); unmergedFiles.push_back(fileName);
} else if (state & StagedFile) { } else if (state & StagedFile) {
if (state & (RenamedFile | CopiedFile)) { if (state & (RenamedFile | CopiedFile)) {
const int arrow = fileName.indexOf(QLatin1String(" -> ")); const int arrow = fileName.indexOf(" -> ");
if (arrow != -1) { if (arrow != -1) {
stagedFiles.push_back(fileName.left(arrow)); stagedFiles.push_back(fileName.left(arrow));
stagedFiles.push_back(fileName.mid(arrow + 4)); stagedFiles.push_back(fileName.mid(arrow + 4));
@@ -198,7 +198,7 @@ void GitSubmitEditor::slotDiffSelected(const QList<int> &rows)
} }
stagedFiles.push_back(fileName); stagedFiles.push_back(fileName);
} else if (state == UntrackedFile) { } else if (state == UntrackedFile) {
Core::EditorManager::openEditor(m_workingDirectory + QLatin1Char('/') + fileName); Core::EditorManager::openEditor(m_workingDirectory + '/' + fileName);
} else { } else {
unstagedFiles.push_back(fileName); unstagedFiles.push_back(fileName);
} }
+4 -4
View File
@@ -51,7 +51,7 @@ GitSubmitEditorWidget::GitSubmitEditorWidget() :
m_gitSubmitPanelUi.setupUi(m_gitSubmitPanel); m_gitSubmitPanelUi.setupUi(m_gitSubmitPanel);
new GitSubmitHighlighter(descriptionEdit()); 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(); const QPixmap error = Core::Icons::ERROR.pixmap();
m_gitSubmitPanelUi.invalidAuthorLabel->setPixmap(error); m_gitSubmitPanelUi.invalidAuthorLabel->setPixmap(error);
m_gitSubmitPanelUi.invalidEmailLabel->setToolTip(tr("Provide a valid email to commit.")); m_gitSubmitPanelUi.invalidEmailLabel->setToolTip(tr("Provide a valid email to commit."));
@@ -66,7 +66,7 @@ GitSubmitEditorWidget::GitSubmitEditorWidget() :
void GitSubmitEditorWidget::setPanelInfo(const GitSubmitEditorPanelInfo &info) void GitSubmitEditorWidget::setPanelInfo(const GitSubmitEditorPanelInfo &info)
{ {
m_gitSubmitPanelUi.repositoryLabel->setText(QDir::toNativeSeparators(info.repository)); 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>") m_gitSubmitPanelUi.branchLabel->setText(QString::fromLatin1("<span style=\"color:red\">%1</span>")
.arg(tr("Detached HEAD"))); .arg(tr("Detached HEAD")));
else else
@@ -163,8 +163,8 @@ QString GitSubmitEditorWidget::cleanupDescription(const QString &input) const
{ {
// We need to manually purge out comment lines starting with // We need to manually purge out comment lines starting with
// hash '#' since git does not do that when using -F. // hash '#' since git does not do that when using -F.
const QChar newLine = QLatin1Char('\n'); const QChar newLine = '\n';
const QChar hash = QLatin1Char('#'); const QChar hash = '#';
QString message = input; QString message = input;
for (int pos = 0; pos < message.size(); ) { for (int pos = 0; pos < message.size(); ) {
const int newLinePos = message.indexOf(newLine, pos); const int newLinePos = message.indexOf(newLine, pos);
+2 -2
View File
@@ -47,7 +47,7 @@ stash@{2}: On <branch>: <message>
bool Stash::parseStashLine(const QString &l) bool Stash::parseStashLine(const QString &l)
{ {
const QChar colon = QLatin1Char(':'); const QChar colon = ':';
const int branchPos = l.indexOf(colon); const int branchPos = l.indexOf(colon);
if (branchPos < 0) if (branchPos < 0)
return false; return false;
@@ -55,7 +55,7 @@ bool Stash::parseStashLine(const QString &l)
if (messagePos < 0) if (messagePos < 0)
return false; return false;
// Branch spec // 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) if (onIndex == -1 || onIndex >= messagePos)
return false; return false;
// Happy! // Happy!
+4 -4
View File
@@ -47,7 +47,7 @@ protected:
QString trackFile(const QString &repository) override QString trackFile(const QString &repository) override
{ {
const QString gitDir = m_client->findGitDirForRepository(repository); 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 QString refreshTopic(const QString &repository) override
@@ -131,7 +131,7 @@ QString GitVersionControl::vcsTopic(const QString &directory)
QString topic = Core::IVersionControl::vcsTopic(directory); QString topic = Core::IVersionControl::vcsTopic(directory);
const QString commandInProgress = m_client->commandInProgressDescription(directory); const QString commandInProgress = m_client->commandInProgressDescription(directory);
if (!commandInProgress.isEmpty()) if (!commandInProgress.isEmpty())
topic += QLatin1String(" (") + commandInProgress + QLatin1Char(')'); topic += " (" + commandInProgress + ')';
return topic; return topic;
} }
@@ -140,8 +140,8 @@ Core::ShellCommand *GitVersionControl::createInitialCheckoutCommand(const QStrin
const QString &localName, const QString &localName,
const QStringList &extraArgs) const QStringList &extraArgs)
{ {
QStringList args; QStringList args = { "clone", "--progress" };
args << QLatin1String("clone") << QLatin1String("--progress") << extraArgs << url << localName; args << extraArgs << url << localName;
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment()); auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment());
command->addFlags(VcsBase::VcsCommand::SuppressStdErr); command->addFlags(VcsBase::VcsCommand::SuppressStdErr);
+9 -9
View File
@@ -153,21 +153,21 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
// Retrieve log using a custom format "Sha1:Subject [(refs)]" // Retrieve log using a custom format "Sha1:Subject [(refs)]"
QStringList arguments; QStringList arguments;
arguments << QLatin1String("--max-count=1000") << QLatin1String("--format=%h:%s %d"); arguments << "--max-count=1000" << "--format=%h:%s %d";
arguments << (commit.isEmpty() ? QLatin1String("HEAD") : commit); arguments << (commit.isEmpty() ? "HEAD" : commit);
if (!(flags & IncludeRemotes)) if (!(flags & IncludeRemotes))
arguments << QLatin1String("--not") << QLatin1String("--remotes"); arguments << "--not" << "--remotes";
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(QLatin1Char('\n'))) { foreach (const QString &line, output.split('\n')) {
const int colonPos = line.indexOf(QLatin1Char(':')); const int colonPos = line.indexOf(':');
if (colonPos != -1) { if (colonPos != -1) {
QList<QStandardItem *> row; QList<QStandardItem *> row;
for (int c = 0; c < ColumnCount; ++c) { for (int c = 0; c < ColumnCount; ++c) {
auto item = new QStandardItem; auto item = new QStandardItem;
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
if (line.endsWith(QLatin1Char(')'))) { if (line.endsWith(')')) {
QFont font = item->font(); QFont font = item->font();
font.setBold(true); font.setBold(true);
item->setFont(font); item->setFont(font);
@@ -207,9 +207,9 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) :
if (isReset) { if (isReset) {
popUpLayout->addWidget(new QLabel(tr("Reset type:"), this)); popUpLayout->addWidget(new QLabel(tr("Reset type:"), this));
m_resetTypeComboBox = new QComboBox(this); m_resetTypeComboBox = new QComboBox(this);
m_resetTypeComboBox->addItem(tr("Hard"), QLatin1String("--hard")); m_resetTypeComboBox->addItem(tr("Hard"), "--hard");
m_resetTypeComboBox->addItem(tr("Mixed"), QLatin1String("--mixed")); m_resetTypeComboBox->addItem(tr("Mixed"), "--mixed");
m_resetTypeComboBox->addItem(tr("Soft"), QLatin1String("--soft")); m_resetTypeComboBox->addItem(tr("Soft"), "--soft");
m_resetTypeComboBox->setCurrentIndex(GitPlugin::client()->settings().intValue( m_resetTypeComboBox->setCurrentIndex(GitPlugin::client()->settings().intValue(
GitSettings::lastResetIndexKey)); GitSettings::lastResetIndexKey));
popUpLayout->addWidget(m_resetTypeComboBox); popUpLayout->addWidget(m_resetTypeComboBox);
+2 -2
View File
@@ -76,7 +76,7 @@ MergeTool::~MergeTool()
bool MergeTool::start(const QString &workingDirectory, const QStringList &files) bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
{ {
QStringList arguments; QStringList arguments;
arguments << QLatin1String("mergetool") << QLatin1String("-y") << files; arguments << "mergetool" << "-y" << files;
m_process = new MergeToolProcess(this); m_process = new MergeToolProcess(this);
m_process->setWorkingDirectory(workingDirectory); m_process->setWorkingDirectory(workingDirectory);
const Utils::FileName binary = GitPlugin::client()->vcsBinary(); const Utils::FileName binary = GitPlugin::client()->vcsBinary();
@@ -206,7 +206,7 @@ void MergeTool::chooseAction()
key = button->property("key"); key = button->property("key");
// either the message box was closed without clicking anything, or abort was clicked // either the message box was closed without clicking anything, or abort was clicked
if (!key.isValid()) if (!key.isValid())
key = QVariant(QLatin1Char('a')); // abort key = QVariant('a'); // abort
ba.append(key.toChar().toLatin1()); ba.append(key.toChar().toLatin1());
ba.append('\n'); ba.append('\n');
m_process->write(ba); m_process->write(ba);
+1 -2
View File
@@ -165,8 +165,7 @@ void RemoteDialog::pushToRemote()
const int row = indexList.at(0).row(); const int row = indexList.at(0).row();
const QString remoteName = m_remoteModel->remoteName(row); const QString remoteName = m_remoteModel->remoteName(row);
GitPlugin::client()->push(m_remoteModel->workingDirectory(), GitPlugin::client()->push(m_remoteModel->workingDirectory(), { remoteName });
QStringList() << remoteName);
} }
void RemoteDialog::fetchFromRemote() void RemoteDialog::fetchFromRemote()
+8 -12
View File
@@ -48,9 +48,8 @@ bool RemoteModel::removeRemote(int row)
{ {
QString output; QString output;
QString error; QString error;
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory, bool success = GitPlugin::client()->synchronousRemoteCmd(
QStringList() << QLatin1String("rm") << remoteName(row), m_workingDirectory, { "rm", remoteName(row) }, &output, &error);
&output, &error);
if (success) if (success)
success = refresh(m_workingDirectory, &error); success = refresh(m_workingDirectory, &error);
return success; return success;
@@ -63,9 +62,8 @@ bool RemoteModel::addRemote(const QString &name, const QString &url)
if (name.isEmpty() || url.isEmpty()) if (name.isEmpty() || url.isEmpty())
return false; return false;
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory, bool success = GitPlugin::client()->synchronousRemoteCmd(
QStringList() << QLatin1String("add") << name << url, m_workingDirectory, { "add", name, url }, &output, &error);
&output, &error);
if (success) if (success)
success = refresh(m_workingDirectory, &error); success = refresh(m_workingDirectory, &error);
return success; return success;
@@ -75,9 +73,8 @@ bool RemoteModel::renameRemote(const QString &oldName, const QString &newName)
{ {
QString output; QString output;
QString error; QString error;
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory, bool success = GitPlugin::client()->synchronousRemoteCmd(
QStringList() << QLatin1String("rename") << oldName << newName, m_workingDirectory, { "rename", oldName, newName }, &output, &error);
&output, &error);
if (success) if (success)
success = refresh(m_workingDirectory, &error); success = refresh(m_workingDirectory, &error);
return success; return success;
@@ -87,9 +84,8 @@ bool RemoteModel::updateUrl(const QString &name, const QString &newUrl)
{ {
QString output; QString output;
QString error; QString error;
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory, bool success = GitPlugin::client()->synchronousRemoteCmd(
QStringList() << QLatin1String("set-url") << name << newUrl, m_workingDirectory, { "set-url", name, newUrl }, &output, &error);
&output, &error);
if (success) if (success)
success = refresh(m_workingDirectory, &error); success = refresh(m_workingDirectory, &error);
return success; return success;
+1 -1
View File
@@ -59,7 +59,7 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) : VcsClientOptionsPageWi
m_ui.winHomeCheckBox->setVisible(false); m_ui.winHomeCheckBox->setVisible(false);
} }
m_ui.repBrowserCommandPathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); 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")); m_ui.repBrowserCommandPathChooser->setPromptDialogTitle(tr("Git Repository Browser Command"));
} }
+9 -9
View File
@@ -206,7 +206,7 @@ void StashDialog::deleteSelection()
errors.push_back(errorMessage); errors.push_back(errorMessage);
refresh(m_repository, true); refresh(m_repository, true);
if (!errors.isEmpty()) if (!errors.isEmpty())
warning(title, errors.join(QLatin1Char('\n'))); warning(title, errors.join('\n'));
} }
void StashDialog::showCurrent() void StashDialog::showCurrent()
@@ -219,21 +219,21 @@ void StashDialog::showCurrent()
// Suggest Branch name to restore 'stash@{0}' -> 'stash0-date' // Suggest Branch name to restore 'stash@{0}' -> 'stash0-date'
static inline QString stashRestoreDefaultBranch(QString stash) static inline QString stashRestoreDefaultBranch(QString stash)
{ {
stash.remove(QLatin1Char('{')); stash.remove('{');
stash.remove(QLatin1Char('}')); stash.remove('}');
stash.remove(QLatin1Char('@')); stash.remove('@');
stash += QLatin1Char('-'); stash += '-';
stash += QDateTime::currentDateTime().toString(QLatin1String("yyMMddhhmmss")); stash += QDateTime::currentDateTime().toString("yyMMddhhmmss");
return stash; return stash;
} }
// Return next stash id 'stash@{0}' -> 'stash@{1}' // Return next stash id 'stash@{0}' -> 'stash@{1}'
static inline QString nextStash(const QString &stash) static inline QString nextStash(const QString &stash)
{ {
const int openingBracePos = stash.indexOf(QLatin1Char('{')); const int openingBracePos = stash.indexOf('{');
if (openingBracePos == -1) if (openingBracePos == -1)
return QString(); return QString();
const int closingBracePos = stash.indexOf(QLatin1Char('}'), openingBracePos + 2); const int closingBracePos = stash.indexOf('}', openingBracePos + 2);
if (closingBracePos == -1) if (closingBracePos == -1)
return QString(); return QString();
bool ok; bool ok;
@@ -242,7 +242,7 @@ static inline QString nextStash(const QString &stash)
return QString(); return QString();
QString rc = stash.left(openingBracePos + 1); QString rc = stash.left(openingBracePos + 1);
rc += QString::number(n + 1); rc += QString::number(n + 1);
rc += QLatin1Char('}'); rc += '}';
return rc; return rc;
} }