diff --git a/src/plugins/git/Git.json.in b/src/plugins/git/Git.json.in index 6c129f9b4ab..244ed2f8435 100644 --- a/src/plugins/git/Git.json.in +++ b/src/plugins/git/Git.json.in @@ -15,6 +15,13 @@ \"Category\" : \"Version Control\", \"Description\" : \"Git integration.\", \"Url\" : \"http://www.qt.io\", + \"Arguments\" : [ + { + \"Name\" : \"-git-show\", + \"Parameter\" : \"git commit hash\", + \"Description\" : \"Show given commit hash\" + } + ], $$dependencyList, \"Mimetypes\" : [ diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index ddab8cd2fed..4657b68ac24 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -289,7 +289,6 @@ QAction *GitPlugin::createRepositoryAction(ActionContainer *ac, const QString &t bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) { - Q_UNUSED(arguments) Q_UNUSED(errorMessage) Context context(Constants::GIT_CONTEXT); @@ -668,6 +667,12 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) m_gerritPlugin->updateActions(currentState()); m_gerritPlugin->addToLocator(m_commandLocator); + auto cmdContext = new QObject(this); + connect(Core::ICore::instance(), &Core::ICore::coreOpened, cmdContext, [this, cmdContext, arguments] { + remoteCommand(arguments, QDir::currentPath(), {}); + cmdContext->deleteLater(); + }); + return ok; } @@ -1418,6 +1423,17 @@ void GitPlugin::updateBranches(const QString &repository) m_branchDialog->refreshIfSame(repository); } +QObject *GitPlugin::remoteCommand(const QStringList &options, const QString &workingDirectory, + const QStringList &) +{ + if (!m_gitClient || options.size() < 2) + return nullptr; + + if (options.first() == "-git-show") + m_gitClient->show(workingDirectory, options.at(1)); + return nullptr; +} + void GitPlugin::updateRepositoryBrowserAction() { const bool repositoryEnabled = currentState().hasTopLevel(); diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index aa157c4c87b..f382e3a0abc 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -89,6 +89,9 @@ public: void startCommit(CommitType commitType = SimpleCommit); void updateBranches(const QString &repository); + QObject *remoteCommand(const QStringList &options, const QString &workingDirectory, + const QStringList &args) override; + protected: void updateActions(VcsBase::VcsBasePlugin::ActionState) override; bool submitEditorAboutToClose() override;