diff options
| author | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
|---|---|---|
| committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
| commit | 9f831dde07cb2411808534e76669b28a1b76e21d (patch) | |
| tree | ed6252d64c9a3ab27aa93786272cda1b6008f3c7 /src/plugins/git | |
| parent | cdac81f896ef4b052d76f96485a08e6ec13696b8 (diff) | |
| parent | ea1a92484ac99057b06130a012164bf9788650e9 (diff) | |
| download | qt-creator-wip/clang.tar.gz | |
Merge remote-tracking branch 'origin/master' into wip/clangwip/clang
Change-Id: I8a2c8068a3f2b15034fb1bf6304c9a0f3f0e3c8f
Diffstat (limited to 'src/plugins/git')
| -rw-r--r-- | src/plugins/git/branchdialog.cpp | 15 | ||||
| -rw-r--r-- | src/plugins/git/gerrit/gerritpushdialog.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/git/git.qrc | 1 | ||||
| -rw-r--r-- | src/plugins/git/gitclient.cpp | 52 | ||||
| -rw-r--r-- | src/plugins/git/gitclient.h | 6 | ||||
| -rw-r--r-- | src/plugins/git/gitplugin.cpp | 15 | ||||
| -rw-r--r-- | src/plugins/git/images/arrowup.png | bin | 0 -> 376 bytes | |||
| -rw-r--r-- | src/plugins/git/logchangedialog.cpp | 3 | ||||
| -rw-r--r-- | src/plugins/git/logchangedialog.h | 2 |
9 files changed, 67 insertions, 31 deletions
diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp index 9fadf16934..09e21ba2c8 100644 --- a/src/plugins/git/branchdialog.cpp +++ b/src/plugins/git/branchdialog.cpp @@ -38,11 +38,14 @@ #include "stashdialog.h" // Label helpers #include <utils/qtcassert.h> +#include <utils/execmenu.h> #include <vcsbase/vcsbaseoutputwindow.h> +#include <QAction> #include <QItemSelectionModel> #include <QMessageBox> #include <QList> +#include <QMenu> #include <QDebug> @@ -321,8 +324,18 @@ void BranchDialog::merge() const QString branch = m_model->fullName(idx, true); GitClient *client = GitPlugin::instance()->gitClient(); + bool allowFastForward = true; + if (client->isFastForwardMerge(m_repository, branch)) { + QMenu popup; + QAction *fastForward = popup.addAction(tr("Fast-Forward")); + popup.addAction(tr("No Fast-Forward")); + QAction *chosen = Utils::execMenuAtWidget(&popup, m_ui->mergeButton); + if (!chosen) + return; + allowFastForward = (chosen == fastForward); + } if (client->beginStashScope(m_repository, QLatin1String("merge"), AllowUnstashed)) - client->synchronousMerge(m_repository, branch); + client->synchronousMerge(m_repository, branch, allowFastForward); } void BranchDialog::rebase() diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp index 466048cfa5..bfb06b38bd 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.cpp +++ b/src/plugins/git/gerrit/gerritpushdialog.cpp @@ -33,8 +33,6 @@ #include "../gitplugin.h" #include "../gitclient.h" -#include <coreplugin/coreconstants.h> - #include <QDateTime> #include <QDir> #include <QRegExpValidator> @@ -46,7 +44,7 @@ class PushItemDelegate : public Git::Internal::IconItemDelegate { public: PushItemDelegate(Git::Internal::LogChangeWidget *widget) - : IconItemDelegate(widget, QLatin1String(Core::Constants::ICON_PLUS)) + : IconItemDelegate(widget, QLatin1String(":/git/images/arrowup.png")) { } diff --git a/src/plugins/git/git.qrc b/src/plugins/git/git.qrc index 3371b45cd8..15b93521a3 100644 --- a/src/plugins/git/git.qrc +++ b/src/plugins/git/git.qrc @@ -2,6 +2,7 @@ <qresource prefix="/git"> <file>images/git.png</file> <file>images/gitorious.png</file> + <file>images/arrowup.png</file> <file>Git.mimetypes.xml</file> </qresource> </RCC> diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 1b3d521559..6842489a82 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -85,6 +85,12 @@ static const char decorateOption[] = "--decorate"; namespace Git { namespace Internal { +// Suppress git diff warnings about "LF will be replaced by CRLF..." on Windows. +static inline unsigned diffExecutionFlags() +{ + return Utils::HostOsInfo::isWindowsHost() ? unsigned(VcsBase::VcsBasePlugin::SuppressStdErrInLogWindow) : 0u; +} + using VcsBase::VcsBasePlugin; class GitDiffSwitcher : public QObject @@ -391,6 +397,7 @@ void GitDiffHandler::collectFilesList(const QStringList &additionalArguments) QStringList arguments; arguments << QLatin1String("diff") << QLatin1String("--name-only") << additionalArguments; command->addJob(arguments, m_timeout); + command->addFlags(diffExecutionFlags()); command->execute(); } @@ -972,7 +979,7 @@ QString GitClient::findRepositoryForDirectory(const QString &dir) else if (directory.exists(QLatin1String(".git/config"))) return directory.absolutePath(); } - } while (directory.cdUp()); + } while (!directory.isRoot() && directory.cdUp()); return QString(); } @@ -1186,6 +1193,7 @@ void GitClient::diff(const QString &workingDirectory, command->addJob(arguments, timeout); } } + command->addFlags(diffExecutionFlags()); command->execute(); } if (newEditor) { @@ -1256,7 +1264,7 @@ void GitClient::diff(const QString &workingDirectory, const QString &fileName) if (!fileName.isEmpty()) cmdArgs << QLatin1String("--") << fileName; - executeGit(workingDirectory, cmdArgs, vcsEditor); + executeGit(workingDirectory, cmdArgs, vcsEditor, false, diffExecutionFlags()); } if (newEditor) { GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this); @@ -1315,7 +1323,7 @@ void GitClient::diffBranch(const QString &workingDirectory, << vcsEditor->configurationWidget()->arguments() << branchName; - executeGit(workingDirectory, cmdArgs, vcsEditor); + executeGit(workingDirectory, cmdArgs, vcsEditor, false, diffExecutionFlags()); } if (newEditor) { GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this); @@ -1537,7 +1545,7 @@ void GitClient::blame(const QString &workingDirectory, arguments << QLatin1String("--") << fileName; if (!revision.isEmpty()) arguments << revision; - executeGit(workingDirectory, arguments, editor, false, false, lineNumber); + executeGit(workingDirectory, arguments, editor, false, 0, lineNumber); } bool GitClient::synchronousCheckout(const QString &workingDirectory, @@ -1626,7 +1634,10 @@ void GitClient::reset(const QString &workingDirectory, const QString &argument, if (!commit.isEmpty()) arguments << commit; - executeGit(workingDirectory, arguments, 0, true, argument == QLatin1String("--hard")); + unsigned flags = 0; + if (argument == QLatin1String("--hard")) + flags |= VcsBasePlugin::ExpectRepoChanges; + executeGit(workingDirectory, arguments, 0, true, flags); } void GitClient::addFile(const QString &workingDirectory, const QString &fileName) @@ -2095,6 +2106,17 @@ bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &c return !outputText.isEmpty(); } +bool GitClient::isFastForwardMerge(const QString &workingDirectory, const QString &branch) +{ + QStringList arguments; + QByteArray outputText; + arguments << QLatin1String("merge-base") << QLatin1String(HEAD) << branch; + fullySynchronousGit(workingDirectory, arguments, &outputText, 0, + VcsBasePlugin::SuppressCommandLogging); + return commandOutputFromLocal8Bit(outputText).trimmed() + == synchronousTopRevision(workingDirectory); +} + // Format an entry in a one-liner for selection list using git log. QString GitClient::synchronousShortDescription(const QString &workingDirectory, const QString &revision, const QString &format) @@ -2489,14 +2511,13 @@ VcsBase::Command *GitClient::executeGit(const QString &workingDirectory, const QStringList &arguments, VcsBase::VcsBaseEditorWidget* editor, bool useOutputToWindow, - bool expectChanges, + unsigned additionalFlags, int editorLineNumber) { outputWindow()->appendCommand(workingDirectory, settings()->stringValue(GitSettings::binaryPathKey), arguments); VcsBase::Command *command = createCommand(workingDirectory, editor, useOutputToWindow, editorLineNumber); command->addJob(arguments, settings()->intValue(GitSettings::timeoutKey)); - if (expectChanges) - command->addFlags(VcsBasePlugin::ExpectRepoChanges); + command->addFlags(additionalFlags); command->execute(); return command; } @@ -2626,7 +2647,8 @@ void GitClient::updateSubmodulesIfNeeded(const QString &workingDirectory, bool p QStringList arguments; arguments << QLatin1String("submodule") << QLatin1String("update"); - VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true, true); + VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true, + VcsBasePlugin::ExpectRepoChanges); connect(cmd, SIGNAL(finished(bool,int,QVariant)), this, SLOT(finishSubmoduleUpdate())); } @@ -3474,12 +3496,15 @@ void GitClient::push(const QString &workingDirectory, const QStringList &pushArg executeGit(workingDirectory, arguments, 0, true); } -bool GitClient::synchronousMerge(const QString &workingDirectory, const QString &branch) +bool GitClient::synchronousMerge(const QString &workingDirectory, const QString &branch, + bool allowFastForward) { QString command = QLatin1String("merge"); - QStringList arguments; + QStringList arguments(command); - arguments << command << branch; + if (!allowFastForward) + arguments << QLatin1String("--no-ff"); + arguments << branch; return executeAndHandleConflicts(workingDirectory, arguments, command); } @@ -3578,7 +3603,8 @@ void GitClient::stashPop(const QString &workingDirectory, const QString &stash) arguments << QLatin1String("pop"); if (!stash.isEmpty()) arguments << stash; - VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true, true); + VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true, + VcsBasePlugin::ExpectRepoChanges); new ConflictHandler(cmd, workingDirectory); } diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index de86aea73b..69f11e9553 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -244,13 +244,15 @@ public: QStringList synchronousBranchesForCommit(const QString &workingDirectory, const QString &revision); bool isRemoteCommit(const QString &workingDirectory, const QString &commit); + bool isFastForwardMerge(const QString &workingDirectory, const QString &branch); bool cloneRepository(const QString &directory, const QByteArray &url); QString vcsGetRepositoryURL(const QString &directory); void fetch(const QString &workingDirectory, const QString &remote); bool synchronousPull(const QString &workingDirectory, bool rebase); void push(const QString &workingDirectory, const QStringList &pushArgs = QStringList()); - bool synchronousMerge(const QString &workingDirectory, const QString &branch); + bool synchronousMerge(const QString &workingDirectory, const QString &branch, + bool allowFastForward = true); bool canRebase(const QString &workingDirectory) const; void rebase(const QString &workingDirectory, const QString &baseBranch); bool synchronousRevert(const QString &workingDirectory, const QString &commit); @@ -374,7 +376,7 @@ private: const QStringList &arguments, VcsBase::VcsBaseEditorWidget* editor = 0, bool useOutputToWindow = false, - bool expectChanges = false, + unsigned additionalFlags = 0, int editorLineNumber = -1); // Fully synchronous git execution (QProcess-based). diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index f055c3f4b3..ae52a8a085 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -807,12 +807,11 @@ class ResetItemDelegate : public LogItemDelegate { public: ResetItemDelegate(LogChangeWidget *widget) : LogItemDelegate(widget) {} - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const + void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const { - QStyleOptionViewItem o = option; if (index.row() < currentRow()) - o.font.setStrikeOut(true); - QStyledItemDelegate::paint(painter, o, index); + option->font.setStrikeOut(true); + LogItemDelegate::initStyleOption(option, index); } }; @@ -855,15 +854,13 @@ void GitPlugin::startRebase() const QString topLevel = state.topLevel(); if (topLevel.isEmpty() || !m_gitClient->canRebase(topLevel)) return; - if (!m_gitClient->beginStashScope(topLevel, QLatin1String("Rebase-i"))) - return; LogChangeDialog dialog(false, Core::ICore::mainWindow()); RebaseItemDelegate delegate(dialog.widget()); dialog.setWindowTitle(tr("Interactive Rebase")); - if (dialog.runDialog(topLevel, QString(), false)) + if (!dialog.runDialog(topLevel, QString(), false)) + return; + if (m_gitClient->beginStashScope(topLevel, QLatin1String("Rebase-i"))) m_gitClient->interactiveRebase(topLevel, dialog.commit(), false); - else - m_gitClient->endStashScope(topLevel); } void GitPlugin::startChangeRelatedAction() diff --git a/src/plugins/git/images/arrowup.png b/src/plugins/git/images/arrowup.png Binary files differnew file mode 100644 index 0000000000..5cdbc6ed9e --- /dev/null +++ b/src/plugins/git/images/arrowup.png diff --git a/src/plugins/git/logchangedialog.cpp b/src/plugins/git/logchangedialog.cpp index 6a316765b1..a52e1b7e9f 100644 --- a/src/plugins/git/logchangedialog.cpp +++ b/src/plugins/git/logchangedialog.cpp @@ -130,7 +130,8 @@ void LogChangeWidget::selectionChanged(const QItemSelection &selected, if (!m_hasCustomDelegate) return; const QModelIndexList previousIndexes = deselected.indexes(); - QTC_ASSERT(!previousIndexes.isEmpty(), return); + if (previousIndexes.isEmpty()) + return; const QModelIndex current = currentIndex(); int row = current.row(); int previousRow = previousIndexes.first().row(); diff --git a/src/plugins/git/logchangedialog.h b/src/plugins/git/logchangedialog.h index f95604d84c..9996c2f5bb 100644 --- a/src/plugins/git/logchangedialog.h +++ b/src/plugins/git/logchangedialog.h @@ -102,8 +102,6 @@ protected: LogItemDelegate(LogChangeWidget *widget); int currentRow() const; - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const = 0; private: LogChangeWidget *m_widget; |
