forked from qt-creator/qt-creator
Git: Store singleton instance in GitClient
On many cases, GitPlugin is not required at all, and is only used as a proxy for GitClient. Change-Id: I246012658ab3e8c7a12f1a459b1b1748ff358e0b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
5765bd8507
commit
7c4f0a9b1e
@@ -82,7 +82,7 @@ BranchView::BranchView() :
|
||||
m_refreshButton(new QToolButton(this)),
|
||||
m_repositoryLabel(new Utils::ElidingLabel(this)),
|
||||
m_branchView(new Utils::NavigationTreeView(this)),
|
||||
m_model(new BranchModel(GitPlugin::client(), this)),
|
||||
m_model(new BranchModel(GitClient::instance(), this)),
|
||||
m_filterModel(new BranchFilterModel(this))
|
||||
{
|
||||
m_addButton->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
|
||||
@@ -122,7 +122,7 @@ BranchView::BranchView() :
|
||||
this, &BranchView::setIncludeOldEntries);
|
||||
m_includeTagsAction->setCheckable(true);
|
||||
m_includeTagsAction->setChecked(
|
||||
GitPlugin::client()->settings().boolValue(GitSettings::showTagsKey));
|
||||
GitClient::instance()->settings().boolValue(GitSettings::showTagsKey));
|
||||
connect(m_includeTagsAction, &QAction::toggled,
|
||||
this, &BranchView::setIncludeTags);
|
||||
|
||||
@@ -214,12 +214,12 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
|
||||
const Utils::optional<QString> remote = m_model->remoteName(index);
|
||||
if (remote.has_value()) {
|
||||
contextMenu.addAction(tr("&Fetch"), this, [this, &remote]() {
|
||||
GitPlugin::client()->fetch(m_repository, *remote);
|
||||
GitClient::instance()->fetch(m_repository, *remote);
|
||||
});
|
||||
contextMenu.addSeparator();
|
||||
if (!remote->isEmpty()) {
|
||||
contextMenu.addAction(tr("Remove &Stale Branches"), this, [this, &remote]() {
|
||||
GitPlugin::client()->removeStaleRemoteBranches(m_repository, *remote);
|
||||
GitClient::instance()->removeStaleRemoteBranches(m_repository, *remote);
|
||||
});
|
||||
contextMenu.addSeparator();
|
||||
}
|
||||
@@ -238,7 +238,7 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
|
||||
contextMenu.addAction(tr("&Diff"), this, [this] {
|
||||
const QString fullName = m_model->fullName(selectedIndex(), true);
|
||||
if (!fullName.isEmpty())
|
||||
GitPlugin::client()->diffBranch(m_repository, fullName);
|
||||
GitClient::instance()->diffBranch(m_repository, fullName);
|
||||
});
|
||||
contextMenu.addAction(tr("&Log"), this, [this] { log(selectedIndex()); });
|
||||
contextMenu.addAction(tr("Reflo&g"), this, [this] { reflog(selectedIndex()); });
|
||||
@@ -289,7 +289,7 @@ void BranchView::setIncludeOldEntries(bool filter)
|
||||
|
||||
void BranchView::setIncludeTags(bool includeTags)
|
||||
{
|
||||
GitPlugin::client()->settings().setValue(GitSettings::showTagsKey, includeTags);
|
||||
GitClient::instance()->settings().setValue(GitSettings::showTagsKey, includeTags);
|
||||
refreshCurrentRepository();
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ bool BranchView::checkout()
|
||||
' ' + nextBranch + "-AutoStash ";
|
||||
|
||||
BranchCheckoutDialog branchCheckoutDialog(this, currentBranch, nextBranch);
|
||||
GitClient *client = GitPlugin::client();
|
||||
GitClient *client = GitClient::instance();
|
||||
|
||||
if (client->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules)) != GitClient::StatusChanged)
|
||||
branchCheckoutDialog.foundNoLocalChanges();
|
||||
@@ -500,7 +500,7 @@ bool BranchView::reset(const QByteArray &resetType)
|
||||
if (QMessageBox::question(this, tr("Git Reset"), tr("Reset branch \"%1\" to \"%2\"?")
|
||||
.arg(currentName).arg(branchName),
|
||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||
GitPlugin::client()->reset(m_repository, QLatin1String("--" + resetType), branchName);
|
||||
GitClient::instance()->reset(m_repository, QLatin1String("--" + resetType), branchName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -512,7 +512,7 @@ bool BranchView::isFastForwardMerge()
|
||||
QTC_CHECK(selected != m_model->currentBranch());
|
||||
|
||||
const QString branch = m_model->fullName(selected, true);
|
||||
return GitPlugin::client()->isFastForwardMerge(m_repository, branch);
|
||||
return GitClient::instance()->isFastForwardMerge(m_repository, branch);
|
||||
}
|
||||
|
||||
bool BranchView::merge(bool allowFastForward)
|
||||
@@ -523,7 +523,7 @@ bool BranchView::merge(bool allowFastForward)
|
||||
QTC_CHECK(selected != m_model->currentBranch());
|
||||
|
||||
const QString branch = m_model->fullName(selected, true);
|
||||
GitClient *client = GitPlugin::client();
|
||||
GitClient *client = GitClient::instance();
|
||||
if (client->beginStashScope(m_repository, "merge", AllowUnstashed))
|
||||
return client->synchronousMerge(m_repository, branch, allowFastForward);
|
||||
|
||||
@@ -538,7 +538,7 @@ void BranchView::rebase()
|
||||
QTC_CHECK(selected != m_model->currentBranch());
|
||||
|
||||
const QString baseBranch = m_model->fullName(selected, true);
|
||||
GitClient *client = GitPlugin::client();
|
||||
GitClient *client = GitClient::instance();
|
||||
if (client->beginStashScope(m_repository, "rebase"))
|
||||
client->rebase(m_repository, baseBranch);
|
||||
}
|
||||
@@ -551,21 +551,21 @@ bool BranchView::cherryPick()
|
||||
QTC_CHECK(selected != m_model->currentBranch());
|
||||
|
||||
const QString branch = m_model->fullName(selected, true);
|
||||
return GitPlugin::client()->synchronousCherryPick(m_repository, branch);
|
||||
return GitClient::instance()->synchronousCherryPick(m_repository, branch);
|
||||
}
|
||||
|
||||
void BranchView::log(const QModelIndex &idx)
|
||||
{
|
||||
const QString branchName = m_model->fullName(idx, true);
|
||||
if (!branchName.isEmpty())
|
||||
GitPlugin::client()->log(m_repository, QString(), false, {branchName});
|
||||
GitClient::instance()->log(m_repository, QString(), false, {branchName});
|
||||
}
|
||||
|
||||
void BranchView::reflog(const QModelIndex &idx)
|
||||
{
|
||||
const QString branchName = m_model->fullName(idx, true);
|
||||
if (!branchName.isEmpty())
|
||||
GitPlugin::client()->reflog(m_repository, branchName);
|
||||
GitClient::instance()->reflog(m_repository, branchName);
|
||||
}
|
||||
|
||||
void BranchView::push()
|
||||
@@ -581,7 +581,7 @@ void BranchView::push()
|
||||
const QString remoteBranch = fullTargetName.mid(pos + 1);
|
||||
const QStringList pushArgs = {remoteName, localBranch + ':' + remoteBranch};
|
||||
|
||||
GitPlugin::client()->push(m_repository, pushArgs);
|
||||
GitClient::instance()->push(m_repository, pushArgs);
|
||||
}
|
||||
|
||||
BranchViewFactory::BranchViewFactory()
|
||||
|
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "changeselectiondialog.h"
|
||||
#include "logchangedialog.h"
|
||||
#include "gitplugin.h"
|
||||
#include "gitclient.h"
|
||||
#include "ui_changeselectiondialog.h"
|
||||
|
||||
@@ -57,12 +56,12 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Co
|
||||
QWidget *parent) :
|
||||
QDialog(parent), m_ui(new Ui::ChangeSelectionDialog)
|
||||
{
|
||||
m_gitExecutable = GitPlugin::client()->vcsBinary();
|
||||
m_gitExecutable = GitClient::instance()->vcsBinary();
|
||||
m_ui->setupUi(this);
|
||||
m_ui->workingDirectoryChooser->setExpectedKind(PathChooser::ExistingDirectory);
|
||||
m_ui->workingDirectoryChooser->setPromptDialogTitle(tr("Select Git Directory"));
|
||||
m_ui->workingDirectoryChooser->setPath(workingDirectory);
|
||||
m_gitEnvironment = GitPlugin::client()->processEnvironment();
|
||||
m_gitEnvironment = GitClient::instance()->processEnvironment();
|
||||
m_ui->changeNumberEdit->setFocus();
|
||||
m_ui->changeNumberEdit->selectAll();
|
||||
|
||||
@@ -203,7 +202,7 @@ void ChangeSelectionDialog::recalculateCompletion()
|
||||
if (workingDir.isEmpty())
|
||||
return;
|
||||
|
||||
GitClient *client = GitPlugin::client();
|
||||
GitClient *client = GitClient::instance();
|
||||
VcsBase::VcsCommand *command = client->asyncForEachRefCmd(
|
||||
workingDir, {"--format=%(refname:short)"});
|
||||
connect(this, &QObject::destroyed, command, &VcsBase::VcsCommand::abort);
|
||||
|
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "branchcombobox.h"
|
||||
#include "../gitplugin.h"
|
||||
#include "../gitclient.h"
|
||||
|
||||
using namespace Git::Internal;
|
||||
@@ -36,7 +35,7 @@ BranchComboBox::BranchComboBox(QWidget *parent) : QComboBox(parent)
|
||||
void BranchComboBox::init(const QString &repository)
|
||||
{
|
||||
m_repository = repository;
|
||||
QString currentBranch = GitPlugin::client()->synchronousCurrentLocalBranch(repository);
|
||||
QString currentBranch = GitClient::instance()->synchronousCurrentLocalBranch(repository);
|
||||
if (currentBranch.isEmpty()) {
|
||||
m_detached = true;
|
||||
currentBranch = "HEAD";
|
||||
@@ -44,7 +43,7 @@ void BranchComboBox::init(const QString &repository)
|
||||
}
|
||||
QString output;
|
||||
const QString branchPrefix("refs/heads/");
|
||||
if (!GitPlugin::client()->synchronousForEachRefCmd(
|
||||
if (!GitClient::instance()->synchronousForEachRefCmd(
|
||||
m_repository, {"--format=%(refname)", branchPrefix}, &output)) {
|
||||
return;
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "gerritmodel.h"
|
||||
#include "../gitplugin.h"
|
||||
#include "../gitclient.h"
|
||||
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
@@ -295,7 +294,7 @@ QueryContext::QueryContext(const QString &query,
|
||||
connect(&m_process, &QProcess::errorOccurred, this, &QueryContext::processError);
|
||||
connect(&m_watcher, &QFutureWatcherBase::canceled, this, &QueryContext::terminate);
|
||||
m_watcher.setFuture(m_progress.future());
|
||||
m_process.setProcessEnvironment(Git::Internal::GitPlugin::client()->processEnvironment());
|
||||
m_process.setProcessEnvironment(Git::Internal::GitClient::instance()->processEnvironment());
|
||||
m_progress.setProgressRange(0, 1);
|
||||
|
||||
m_timer.setInterval(timeOutMS);
|
||||
|
@@ -148,7 +148,7 @@ FetchContext::FetchContext(const QSharedPointer<GerritChange> &change,
|
||||
connect(&m_watcher, &QFutureWatcher<void>::canceled, this, &FetchContext::terminate);
|
||||
m_watcher.setFuture(m_progress.future());
|
||||
m_process.setWorkingDirectory(repository);
|
||||
m_process.setProcessEnvironment(GitPlugin::client()->processEnvironment());
|
||||
m_process.setProcessEnvironment(GitClient::instance()->processEnvironment());
|
||||
m_process.closeWriteChannel();
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ void FetchContext::show()
|
||||
{
|
||||
const QString title = QString::number(m_change->number) + '/'
|
||||
+ QString::number(m_change->currentPatchSet.patchSetNumber);
|
||||
GitPlugin::client()->show(m_repository, "FETCH_HEAD", title);
|
||||
GitClient::instance()->show(m_repository, "FETCH_HEAD", title);
|
||||
}
|
||||
|
||||
void FetchContext::cherryPick()
|
||||
@@ -248,12 +248,12 @@ void FetchContext::cherryPick()
|
||||
// Point user to errors.
|
||||
VcsBase::VcsOutputWindow::instance()->popup(IOutputPane::ModeSwitch
|
||||
| IOutputPane::WithFocus);
|
||||
GitPlugin::client()->synchronousCherryPick(m_repository, "FETCH_HEAD");
|
||||
GitClient::instance()->synchronousCherryPick(m_repository, "FETCH_HEAD");
|
||||
}
|
||||
|
||||
void FetchContext::checkout()
|
||||
{
|
||||
GitPlugin::client()->checkout(m_repository, "FETCH_HEAD");
|
||||
GitClient::instance()->checkout(m_repository, "FETCH_HEAD");
|
||||
}
|
||||
|
||||
void FetchContext::terminate()
|
||||
@@ -328,7 +328,7 @@ void GerritPlugin::push(const QString &topLevel)
|
||||
|
||||
dialog.storeTopic();
|
||||
m_reviewers = dialog.reviewers();
|
||||
GitPlugin::client()->push(topLevel, {dialog.selectedRemoteName(), dialog.pushTarget()});
|
||||
GitClient::instance()->push(topLevel, {dialog.selectedRemoteName(), dialog.pushTarget()});
|
||||
}
|
||||
|
||||
static QString currentRepository()
|
||||
@@ -375,19 +375,19 @@ void GerritPlugin::push()
|
||||
|
||||
Utils::FilePath GerritPlugin::gitBinDirectory()
|
||||
{
|
||||
return GitPlugin::client()->gitBinDirectory();
|
||||
return GitClient::instance()->gitBinDirectory();
|
||||
}
|
||||
|
||||
// Find the branch of a repository.
|
||||
QString GerritPlugin::branch(const QString &repository)
|
||||
{
|
||||
return GitPlugin::client()->synchronousCurrentLocalBranch(repository);
|
||||
return GitClient::instance()->synchronousCurrentLocalBranch(repository);
|
||||
}
|
||||
|
||||
void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
||||
{
|
||||
// Locate git.
|
||||
const Utils::FilePath git = GitPlugin::client()->vcsBinary();
|
||||
const Utils::FilePath git = GitClient::instance()->vcsBinary();
|
||||
if (git.isEmpty()) {
|
||||
VcsBase::VcsOutputWindow::appendError(tr("Git is not available."));
|
||||
return;
|
||||
@@ -400,7 +400,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
||||
|
||||
if (!repository.isEmpty()) {
|
||||
// Check if remote from a working dir is the same as remote from patch
|
||||
QMap<QString, QString> remotesList = GitPlugin::client()->synchronousRemotesList(repository);
|
||||
QMap<QString, QString> remotesList = GitClient::instance()->synchronousRemotesList(repository);
|
||||
if (!remotesList.isEmpty()) {
|
||||
const QStringList remotes = remotesList.values();
|
||||
for (QString remote : remotes) {
|
||||
@@ -413,7 +413,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
||||
}
|
||||
|
||||
if (!verifiedRepository) {
|
||||
const SubmoduleDataMap submodules = GitPlugin::client()->submoduleList(repository);
|
||||
const SubmoduleDataMap submodules = GitClient::instance()->submoduleList(repository);
|
||||
for (const SubmoduleData &submoduleData : submodules) {
|
||||
QString remote = submoduleData.url;
|
||||
if (remote.endsWith(".git"))
|
||||
|
@@ -27,7 +27,6 @@
|
||||
#include "ui_gerritpushdialog.h"
|
||||
#include "branchcombobox.h"
|
||||
|
||||
#include "../gitplugin.h"
|
||||
#include "../gitclient.h"
|
||||
#include "../gitconstants.h"
|
||||
|
||||
@@ -70,7 +69,7 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
|
||||
QString output;
|
||||
QString error;
|
||||
|
||||
if (!GitPlugin::client()->synchronousBranchCmd(
|
||||
if (!GitClient::instance()->synchronousBranchCmd(
|
||||
m_workingDir, {"-r", "--contains", earliestCommit + '^'}, &output, &error)) {
|
||||
return QString();
|
||||
}
|
||||
@@ -79,7 +78,7 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
|
||||
|
||||
QString remoteTrackingBranch;
|
||||
if (localBranch != "HEAD")
|
||||
remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch);
|
||||
remoteTrackingBranch = GitClient::instance()->synchronousTrackingBranch(m_workingDir, localBranch);
|
||||
|
||||
QString remoteBranch;
|
||||
for (const QString &reference : refs) {
|
||||
@@ -103,7 +102,7 @@ void GerritPushDialog::initRemoteBranches()
|
||||
const QString head = "/HEAD";
|
||||
|
||||
QString remotesPrefix("refs/remotes/");
|
||||
if (!GitPlugin::client()->synchronousForEachRefCmd(
|
||||
if (!GitClient::instance()->synchronousForEachRefCmd(
|
||||
m_workingDir, {"--format=%(refname)\t%(committerdate:raw)", remotesPrefix}, &output)) {
|
||||
return;
|
||||
}
|
||||
@@ -186,8 +185,8 @@ QString GerritPushDialog::calculateChangeRange(const QString &branch)
|
||||
QString number;
|
||||
QString error;
|
||||
|
||||
GitPlugin::client()->synchronousRevListCmd(m_workingDir, { remote + ".." + branch, "--count" },
|
||||
&number, &error);
|
||||
GitClient::instance()->synchronousRevListCmd(
|
||||
m_workingDir, { remote + ".." + branch, "--count" }, &number, &error);
|
||||
|
||||
number.chop(1);
|
||||
return number;
|
||||
@@ -303,8 +302,8 @@ QString GerritPushDialog::pushTarget() const
|
||||
void GerritPushDialog::storeTopic()
|
||||
{
|
||||
const QString branch = m_ui->localBranchComboBox->currentText();
|
||||
GitPlugin::client()->setConfigValue(m_workingDir, QString("branch.%1.topic").arg(branch),
|
||||
selectedTopic());
|
||||
GitClient::instance()->setConfigValue(
|
||||
m_workingDir, QString("branch.%1.topic").arg(branch), selectedTopic());
|
||||
}
|
||||
|
||||
void GerritPushDialog::setRemoteBranches(bool includeOld)
|
||||
@@ -316,7 +315,7 @@ void GerritPushDialog::setRemoteBranches(bool includeOld)
|
||||
const QString remoteName = selectedRemoteName();
|
||||
if (!m_remoteBranches.contains(remoteName)) {
|
||||
const QStringList remoteBranches =
|
||||
GitPlugin::client()->synchronousRepositoryBranches(remoteName, m_workingDir);
|
||||
GitClient::instance()->synchronousRepositoryBranches(remoteName, m_workingDir);
|
||||
for (const QString &branch : remoteBranches)
|
||||
m_remoteBranches.insertMulti(remoteName, qMakePair(branch, QDate()));
|
||||
if (remoteBranches.isEmpty()) {
|
||||
@@ -354,7 +353,7 @@ void GerritPushDialog::updateCommits(int index)
|
||||
{
|
||||
const QString branch = m_ui->localBranchComboBox->itemText(index);
|
||||
m_hasLocalCommits = m_ui->commitView->init(m_workingDir, branch, LogChangeWidget::Silent);
|
||||
QString topic = GitPlugin::client()->readConfigValue(
|
||||
QString topic = GitClient::instance()->readConfigValue(
|
||||
m_workingDir, QString("branch.%1.topic").arg(branch));
|
||||
if (!topic.isEmpty())
|
||||
m_ui->topicLineEdit->setText(topic);
|
||||
|
@@ -27,7 +27,6 @@
|
||||
#include "gerritparameters.h"
|
||||
#include "gerritserver.h"
|
||||
#include "../gitclient.h"
|
||||
#include "../gitplugin.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
@@ -104,7 +103,7 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload)
|
||||
m_remotes.clear();
|
||||
QString errorMessage; // Mute errors. We'll just fallback to the defaults
|
||||
const QMap<QString, QString> remotesList =
|
||||
Git::Internal::GitPlugin::client()->synchronousRemotesList(m_repository, &errorMessage);
|
||||
Git::Internal::GitClient::instance()->synchronousRemotesList(m_repository, &errorMessage);
|
||||
for (auto mapIt = remotesList.cbegin(), end = remotesList.cend(); mapIt != end; ++mapIt) {
|
||||
GerritServer server;
|
||||
if (!server.fillFromRemote(mapIt.value(), *m_parameters, forceReload))
|
||||
|
@@ -241,7 +241,7 @@ QStringList GerritServer::curlArguments() const
|
||||
|
||||
int GerritServer::testConnection()
|
||||
{
|
||||
static GitClient *const client = GitPlugin::client();
|
||||
static GitClient *const client = GitClient::instance();
|
||||
const QStringList arguments = curlArguments() << (url(RestUrl) + accountUrlC);
|
||||
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec(
|
||||
QString(), {curlBinary, arguments},
|
||||
@@ -333,7 +333,7 @@ bool GerritServer::resolveRoot()
|
||||
|
||||
void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
||||
{
|
||||
static GitClient *const client = GitPlugin::client();
|
||||
static GitClient *const client = GitClient::instance();
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
const QString fullVersionKey = "Gerrit/" + host + '/' + versionKey;
|
||||
version = settings->value(fullVersionKey).toString();
|
||||
|
@@ -106,6 +106,8 @@ using namespace VcsBase;
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
static GitClient *m_instance = nullptr;
|
||||
|
||||
// Suppress git diff warnings about "LF will be replaced by CRLF..." on Windows.
|
||||
static unsigned diffExecutionFlags()
|
||||
{
|
||||
@@ -300,7 +302,7 @@ void GitDiffEditorController::updateBranchList()
|
||||
return;
|
||||
|
||||
const QString workingDirectory = baseDirectory();
|
||||
VcsCommand *command = GitPlugin::client()->vcsExec(
|
||||
VcsCommand *command = m_instance->vcsExec(
|
||||
workingDirectory, {"branch", noColorOption, "-a", "--contains", revision}, nullptr,
|
||||
false, 0, workingDirectory);
|
||||
connect(command, &VcsCommand::stdOutText, this, [this](const QString &text) {
|
||||
@@ -375,7 +377,7 @@ QStringList GitDiffEditorController::addHeadWhenCommandInProgress() const
|
||||
// This is workaround for lack of support for merge commits and resolving conflicts,
|
||||
// we compare the current state of working tree to the HEAD of current branch
|
||||
// instead of showing unsupported combined diff format.
|
||||
GitClient::CommandInProgress commandInProgress = GitPlugin::client()->checkCommandInProgress(workingDirectory());
|
||||
GitClient::CommandInProgress commandInProgress = m_instance->checkCommandInProgress(workingDirectory());
|
||||
if (commandInProgress != GitClient::NoCommand)
|
||||
return {HEAD};
|
||||
return QStringList();
|
||||
@@ -478,7 +480,7 @@ public:
|
||||
setReloader([this] {
|
||||
m_state = GettingDescription;
|
||||
const QStringList args = {"show", "-s", noColorOption, showFormatC, m_id};
|
||||
runCommand({args}, GitPlugin::client()->encoding(workingDirectory(), "i18n.commitEncoding"));
|
||||
runCommand({args}, m_instance->encoding(workingDirectory(), "i18n.commitEncoding"));
|
||||
setStartupFile(VcsBase::source(this->document()));
|
||||
});
|
||||
}
|
||||
@@ -495,7 +497,7 @@ void ShowController::processCommandOutput(const QString &output)
|
||||
{
|
||||
QTC_ASSERT(m_state != Idle, return);
|
||||
if (m_state == GettingDescription) {
|
||||
setDescription(GitPlugin::client()->extendedShowDescription(workingDirectory(), output));
|
||||
setDescription(m_instance->extendedShowDescription(workingDirectory(), output));
|
||||
// stage 2
|
||||
m_state = GettingDiff;
|
||||
const QStringList args = {"show", "--format=format:", // omit header, already generated
|
||||
@@ -669,12 +671,11 @@ private:
|
||||
{
|
||||
// If interactive rebase editor window is closed, plugin is terminated
|
||||
// but referenced here when the command ends
|
||||
GitClient *client = GitPlugin::client();
|
||||
if (m_commit.isEmpty() && m_files.isEmpty()) {
|
||||
if (client->checkCommandInProgress(m_workingDirectory) == GitClient::NoCommand)
|
||||
client->endStashScope(m_workingDirectory);
|
||||
if (m_instance->checkCommandInProgress(m_workingDirectory) == GitClient::NoCommand)
|
||||
m_instance->endStashScope(m_workingDirectory);
|
||||
} else {
|
||||
client->handleMergeConflicts(m_workingDirectory, m_commit, m_files, m_abortCommand);
|
||||
m_instance->handleMergeConflicts(m_workingDirectory, m_commit, m_files, m_abortCommand);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,11 +764,17 @@ GitClient::GitClient(GitSettings *settings) : VcsBase::VcsBaseClientImpl(setting
|
||||
m_cachedGitVersion(0),
|
||||
m_disableEditor(false)
|
||||
{
|
||||
m_instance = this;
|
||||
m_gitQtcEditor = QString::fromLatin1("\"%1\" -client -block -pid %2")
|
||||
.arg(QCoreApplication::applicationFilePath())
|
||||
.arg(QCoreApplication::applicationPid());
|
||||
}
|
||||
|
||||
GitClient *GitClient::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
QString GitClient::findRepositoryForDirectory(const QString &directory) const
|
||||
{
|
||||
if (directory.isEmpty() || directory.endsWith("/.git") || directory.contains("/.git/"))
|
||||
@@ -3476,8 +3483,8 @@ bool GitClient::StashInfo::init(const QString &workingDirectory, const QString &
|
||||
m_pushAction = pushAction;
|
||||
QString errorMessage;
|
||||
QString statusOutput;
|
||||
switch (GitPlugin::client()->gitStatus(m_workingDir, StatusMode(NoUntracked | NoSubmodules),
|
||||
&statusOutput, &errorMessage)) {
|
||||
switch (m_instance->gitStatus(m_workingDir, StatusMode(NoUntracked | NoSubmodules),
|
||||
&statusOutput, &errorMessage)) {
|
||||
case GitClient::StatusChanged:
|
||||
if (m_flags & NoPrompt)
|
||||
executeStash(command, &errorMessage);
|
||||
@@ -3529,14 +3536,14 @@ void GitClient::StashInfo::stashPrompt(const QString &command, const QString &st
|
||||
msgBox.exec();
|
||||
|
||||
if (msgBox.clickedButton() == discardButton) {
|
||||
m_stashResult = GitPlugin::client()->synchronousReset(m_workingDir, QStringList(), errorMessage) ?
|
||||
m_stashResult = m_instance->synchronousReset(m_workingDir, QStringList(), errorMessage) ?
|
||||
StashUnchanged : StashFailed;
|
||||
} else if (msgBox.clickedButton() == ignoreButton) { // At your own risk, so.
|
||||
m_stashResult = NotStashed;
|
||||
} else if (msgBox.clickedButton() == cancelButton) {
|
||||
m_stashResult = StashCanceled;
|
||||
} else if (msgBox.clickedButton() == stashButton) {
|
||||
const bool result = GitPlugin::client()->executeSynchronousStash(
|
||||
const bool result = m_instance->executeSynchronousStash(
|
||||
m_workingDir, creatorStashMessage(command), false, errorMessage);
|
||||
m_stashResult = result ? StashUnchanged : StashFailed;
|
||||
} else if (msgBox.clickedButton() == stashAndPopButton) {
|
||||
@@ -3547,7 +3554,7 @@ void GitClient::StashInfo::stashPrompt(const QString &command, const QString &st
|
||||
void GitClient::StashInfo::executeStash(const QString &command, QString *errorMessage)
|
||||
{
|
||||
m_message = creatorStashMessage(command);
|
||||
if (!GitPlugin::client()->executeSynchronousStash(m_workingDir, m_message, false, errorMessage))
|
||||
if (!m_instance->executeSynchronousStash(m_workingDir, m_message, false, errorMessage))
|
||||
m_stashResult = StashFailed;
|
||||
else
|
||||
m_stashResult = Stashed;
|
||||
@@ -3570,12 +3577,12 @@ void GitClient::StashInfo::end()
|
||||
{
|
||||
if (m_stashResult == Stashed) {
|
||||
QString stashName;
|
||||
if (GitPlugin::client()->stashNameFromMessage(m_workingDir, m_message, &stashName))
|
||||
GitPlugin::client()->stashPop(m_workingDir, stashName);
|
||||
if (m_instance->stashNameFromMessage(m_workingDir, m_message, &stashName))
|
||||
m_instance->stashPop(m_workingDir, stashName);
|
||||
}
|
||||
|
||||
if (m_pushAction == NormalPush)
|
||||
GitPlugin::client()->push(m_workingDir);
|
||||
m_instance->push(m_workingDir);
|
||||
else if (m_pushAction == PushToGerrit)
|
||||
GitPlugin::gerritPush(m_workingDir);
|
||||
|
||||
|
@@ -139,6 +139,7 @@ public:
|
||||
};
|
||||
|
||||
explicit GitClient(GitSettings *settings);
|
||||
static GitClient *instance();
|
||||
|
||||
Utils::FilePath vcsBinary() const override;
|
||||
unsigned gitVersion(QString *errorMessage = nullptr) const;
|
||||
|
@@ -152,7 +152,7 @@ static QString sanitizeBlameOutput(const QString &b)
|
||||
if (b.isEmpty())
|
||||
return b;
|
||||
|
||||
const bool omitDate = GitPlugin::client()->settings().boolValue(
|
||||
const bool omitDate = GitClient::instance()->settings().boolValue(
|
||||
GitSettings::omitAnnotationDateKey);
|
||||
const QChar space(' ');
|
||||
const int parenPos = b.indexOf(')');
|
||||
@@ -231,7 +231,7 @@ void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert)
|
||||
if (revert)
|
||||
args << "--reverse";
|
||||
QString errorMessage;
|
||||
if (GitPlugin::client()->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) {
|
||||
if (GitClient::instance()->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) {
|
||||
if (errorMessage.isEmpty())
|
||||
VcsOutputWindow::append(tr("Chunk successfully staged"));
|
||||
else
|
||||
@@ -280,14 +280,14 @@ void GitEditorWidget::aboutToOpen(const QString &fileName, const QString &realFi
|
||||
const QString gitPath = fi.absolutePath();
|
||||
setSource(gitPath);
|
||||
textDocument()->setCodec(
|
||||
GitPlugin::client()->encoding(gitPath, "i18n.commitEncoding"));
|
||||
GitClient::instance()->encoding(gitPath, "i18n.commitEncoding"));
|
||||
}
|
||||
}
|
||||
|
||||
QString GitEditorWidget::decorateVersion(const QString &revision) const
|
||||
{
|
||||
// Format verbose, SHA1 being first token
|
||||
return GitPlugin::client()->synchronousShortDescription(sourceWorkingDirectory(), revision);
|
||||
return GitClient::instance()->synchronousShortDescription(sourceWorkingDirectory(), revision);
|
||||
}
|
||||
|
||||
QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision) const
|
||||
@@ -295,8 +295,8 @@ QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision)
|
||||
QStringList revisions;
|
||||
QString errorMessage;
|
||||
// Get the SHA1's of the file.
|
||||
if (!GitPlugin::client()->synchronousParentRevisions(sourceWorkingDirectory(),
|
||||
revision, &revisions, &errorMessage)) {
|
||||
if (!GitClient::instance()->synchronousParentRevisions(
|
||||
sourceWorkingDirectory(), revision, &revisions, &errorMessage)) {
|
||||
VcsOutputWindow::appendSilently(errorMessage);
|
||||
return QStringList();
|
||||
}
|
||||
@@ -305,32 +305,32 @@ QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision)
|
||||
|
||||
bool GitEditorWidget::isValidRevision(const QString &revision) const
|
||||
{
|
||||
return GitPlugin::client()->isValidRevision(revision);
|
||||
return GitClient::instance()->isValidRevision(revision);
|
||||
}
|
||||
|
||||
void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change, const QString &workingDir)
|
||||
{
|
||||
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), [workingDir, change] {
|
||||
GitPlugin::client()->synchronousCherryPick(workingDir, change);
|
||||
GitClient::instance()->synchronousCherryPick(workingDir, change);
|
||||
});
|
||||
menu->addAction(tr("Re&vert Change %1").arg(change), [workingDir, change] {
|
||||
GitPlugin::client()->synchronousRevert(workingDir, change);
|
||||
GitClient::instance()->synchronousRevert(workingDir, change);
|
||||
});
|
||||
menu->addAction(tr("C&heckout Change %1").arg(change), [workingDir, change] {
|
||||
GitPlugin::client()->checkout(workingDir, change);
|
||||
GitClient::instance()->checkout(workingDir, change);
|
||||
});
|
||||
connect(menu->addAction(tr("&Interactive Rebase from Change %1...").arg(change)),
|
||||
&QAction::triggered, [workingDir, change] {
|
||||
GitPlugin::startRebaseFromCommit(workingDir, change);
|
||||
});
|
||||
menu->addAction(tr("&Log for Change %1").arg(change), [workingDir, change] {
|
||||
GitPlugin::client()->log(workingDir, QString(), false, {change});
|
||||
GitClient::instance()->log(workingDir, QString(), false, {change});
|
||||
});
|
||||
menu->addAction(tr("Add &Tag for Change %1...").arg(change), [workingDir, change] {
|
||||
QString output;
|
||||
QString errorMessage;
|
||||
GitPlugin::client()->synchronousTagCmd(workingDir, QStringList(),
|
||||
&output, &errorMessage);
|
||||
GitClient::instance()->synchronousTagCmd(workingDir, QStringList(),
|
||||
&output, &errorMessage);
|
||||
|
||||
const QStringList tags = output.split('\n');
|
||||
BranchAddDialog dialog(tags, BranchAddDialog::Type::AddTag, Core::ICore::dialogParent());
|
||||
@@ -338,16 +338,16 @@ void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change, const
|
||||
if (dialog.exec() == QDialog::Rejected)
|
||||
return;
|
||||
|
||||
GitPlugin::client()->synchronousTagCmd(workingDir,
|
||||
{dialog.branchName(), change},
|
||||
&output, &errorMessage);
|
||||
GitClient::instance()->synchronousTagCmd(workingDir,
|
||||
{dialog.branchName(), change},
|
||||
&output, &errorMessage);
|
||||
VcsOutputWindow::append(output);
|
||||
if (!errorMessage.isEmpty())
|
||||
VcsOutputWindow::append(errorMessage, VcsOutputWindow::MessageStyle::Error);
|
||||
});
|
||||
|
||||
auto resetChange = [workingDir, change](const QByteArray &resetType) {
|
||||
GitPlugin::client()->reset(
|
||||
GitClient::instance()->reset(
|
||||
workingDir, QLatin1String("--" + resetType), change);
|
||||
};
|
||||
auto resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
|
||||
|
@@ -26,7 +26,6 @@
|
||||
#include "gitgrep.h"
|
||||
#include "gitclient.h"
|
||||
#include "gitconstants.h"
|
||||
#include "gitplugin.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
@@ -187,7 +186,7 @@ public:
|
||||
return QString(":!" + filter);
|
||||
});
|
||||
arguments << "--" << filterArgs << exclusionArgs;
|
||||
QScopedPointer<VcsCommand> command(GitPlugin::client()->createCommand(m_directory));
|
||||
QScopedPointer<VcsCommand> command(GitClient::instance()->createCommand(m_directory));
|
||||
command->addFlags(VcsCommand::SilentOutput | VcsCommand::SuppressFailMessage);
|
||||
command->setProgressiveOutput(true);
|
||||
QFutureWatcher<FileSearchResultList> watcher;
|
||||
@@ -195,7 +194,7 @@ public:
|
||||
connect(&watcher, &QFutureWatcher<FileSearchResultList>::canceled,
|
||||
command.data(), &VcsCommand::cancel);
|
||||
connect(command.data(), &VcsCommand::stdOutText, this, &GitGrepRunner::read);
|
||||
SynchronousProcessResponse resp = command->runCommand({GitPlugin::client()->vcsBinary(), arguments}, 0);
|
||||
SynchronousProcessResponse resp = command->runCommand({GitClient::instance()->vcsBinary(), arguments}, 0);
|
||||
switch (resp.result) {
|
||||
case SynchronousProcessResponse::TerminatedAbnormally:
|
||||
case SynchronousProcessResponse::StartFailed:
|
||||
|
@@ -1760,11 +1760,11 @@ void GitPluginPrivate::updateCurrentBranch()
|
||||
QObject *GitPlugin::remoteCommand(const QStringList &options, const QString &workingDirectory,
|
||||
const QStringList &)
|
||||
{
|
||||
if (!GitPlugin::client() || options.size() < 2)
|
||||
if (options.size() < 2)
|
||||
return nullptr;
|
||||
|
||||
if (options.first() == "-git-show")
|
||||
GitPlugin::client()->show(workingDirectory, options.at(1));
|
||||
dd->m_gitClient.show(workingDirectory, options.at(1));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@@ -88,8 +88,8 @@ CommitDataFetchResult CommitDataFetchResult::fetch(CommitType commitType, const
|
||||
CommitDataFetchResult result;
|
||||
result.commitData.commitType = commitType;
|
||||
QString commitTemplate;
|
||||
result.success = GitPlugin::client()->getCommitData(workingDirectory, &commitTemplate,
|
||||
result.commitData, &result.errorMessage);
|
||||
result.success = GitClient::instance()->getCommitData(
|
||||
workingDirectory, &commitTemplate, result.commitData, &result.errorMessage);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -202,15 +202,15 @@ void GitSubmitEditor::slotDiffSelected(const QList<int> &rows)
|
||||
}
|
||||
}
|
||||
if (!unstagedFiles.empty() || !stagedFiles.empty())
|
||||
GitPlugin::client()->diffFiles(m_workingDirectory, unstagedFiles, stagedFiles);
|
||||
GitClient::instance()->diffFiles(m_workingDirectory, unstagedFiles, stagedFiles);
|
||||
if (!unmergedFiles.empty())
|
||||
GitPlugin::client()->merge(m_workingDirectory, unmergedFiles);
|
||||
GitClient::instance()->merge(m_workingDirectory, unmergedFiles);
|
||||
}
|
||||
|
||||
void GitSubmitEditor::showCommit(const QString &commit)
|
||||
{
|
||||
if (!m_workingDirectory.isEmpty())
|
||||
GitPlugin::client()->show(m_workingDirectory, commit);
|
||||
GitClient::instance()->show(m_workingDirectory, commit);
|
||||
}
|
||||
|
||||
void GitSubmitEditor::updateFileModel()
|
||||
@@ -230,7 +230,7 @@ void GitSubmitEditor::updateFileModel()
|
||||
Core::ProgressManager::addTask(m_fetchWatcher.future(), tr("Refreshing Commit Data"),
|
||||
TASK_UPDATE_COMMIT);
|
||||
|
||||
GitPlugin::client()->addFuture(m_fetchWatcher.future());
|
||||
GitClient::instance()->addFuture(m_fetchWatcher.future());
|
||||
}
|
||||
|
||||
void GitSubmitEditor::forceUpdateFileModel()
|
||||
|
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "logchangedialog.h"
|
||||
#include "gitplugin.h"
|
||||
#include "gitclient.h"
|
||||
|
||||
#include <vcsbase/vcsoutputwindow.h>
|
||||
@@ -79,7 +78,7 @@ bool LogChangeWidget::init(const QString &repository, const QString &commit, Log
|
||||
return true;
|
||||
if (!(flags & Silent)) {
|
||||
VcsOutputWindow::appendError(
|
||||
GitPlugin::client()->msgNoCommits(flags & IncludeRemotes));
|
||||
GitClient::instance()->msgNoCommits(flags & IncludeRemotes));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -159,8 +158,10 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
|
||||
arguments << "--not" << "--remotes";
|
||||
arguments << "--";
|
||||
QString output;
|
||||
if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, nullptr, VcsCommand::NoOutput))
|
||||
if (!GitClient::instance()->synchronousLog(
|
||||
repository, arguments, &output, nullptr, VcsCommand::NoOutput)) {
|
||||
return false;
|
||||
}
|
||||
const QStringList lines = output.split('\n');
|
||||
for (const QString &line : lines) {
|
||||
const int colonPos = line.indexOf(':');
|
||||
@@ -211,8 +212,8 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) :
|
||||
m_resetTypeComboBox->addItem(tr("Hard"), "--hard");
|
||||
m_resetTypeComboBox->addItem(tr("Mixed"), "--mixed");
|
||||
m_resetTypeComboBox->addItem(tr("Soft"), "--soft");
|
||||
m_resetTypeComboBox->setCurrentIndex(GitPlugin::client()->settings().intValue(
|
||||
GitSettings::lastResetIndexKey));
|
||||
m_resetTypeComboBox->setCurrentIndex(
|
||||
GitClient::instance()->settings().intValue(GitSettings::lastResetIndexKey));
|
||||
popUpLayout->addWidget(m_resetTypeComboBox);
|
||||
popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
|
||||
}
|
||||
@@ -239,8 +240,8 @@ bool LogChangeDialog::runDialog(const QString &repository,
|
||||
|
||||
if (QDialog::exec() == QDialog::Accepted) {
|
||||
if (m_resetTypeComboBox) {
|
||||
GitPlugin::client()->settings().setValue(GitSettings::lastResetIndexKey,
|
||||
m_resetTypeComboBox->currentIndex());
|
||||
GitClient::instance()->settings().setValue(
|
||||
GitSettings::lastResetIndexKey, m_resetTypeComboBox->currentIndex());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
|
||||
m_process->setWorkingDirectory(workingDirectory);
|
||||
m_process->setProcessEnvironment(env);
|
||||
m_process->setProcessChannelMode(QProcess::MergedChannels);
|
||||
const Utils::FilePath binary = GitPlugin::client()->vcsBinary();
|
||||
const Utils::FilePath binary = GitClient::instance()->vcsBinary();
|
||||
VcsOutputWindow::appendCommand(workingDirectory, {binary, arguments});
|
||||
m_process->start(binary.toString(), arguments);
|
||||
if (m_process->waitForStarted()) {
|
||||
@@ -263,7 +263,7 @@ void MergeTool::done()
|
||||
VcsOutputWindow::appendError(tr("Merge tool process terminated with exit code %1")
|
||||
.arg(exitCode));
|
||||
}
|
||||
GitPlugin::client()->continueCommandIfNeeded(workingDirectory, exitCode == 0);
|
||||
GitClient::instance()->continueCommandIfNeeded(workingDirectory, exitCode == 0);
|
||||
GitPlugin::emitRepositoryChanged(workingDirectory);
|
||||
deleteLater();
|
||||
}
|
||||
|
@@ -203,7 +203,7 @@ void RemoteDialog::pushToRemote()
|
||||
|
||||
const int row = indexList.at(0).row();
|
||||
const QString remoteName = m_remoteModel->remoteName(row);
|
||||
GitPlugin::client()->push(m_remoteModel->workingDirectory(), {remoteName});
|
||||
GitClient::instance()->push(m_remoteModel->workingDirectory(), {remoteName});
|
||||
}
|
||||
|
||||
void RemoteDialog::fetchFromRemote()
|
||||
@@ -214,7 +214,7 @@ void RemoteDialog::fetchFromRemote()
|
||||
|
||||
int row = indexList.at(0).row();
|
||||
const QString remoteName = m_remoteModel->remoteName(row);
|
||||
GitPlugin::client()->fetch(m_remoteModel->workingDirectory(), remoteName);
|
||||
GitClient::instance()->fetch(m_remoteModel->workingDirectory(), remoteName);
|
||||
}
|
||||
|
||||
void RemoteDialog::updateButtonState()
|
||||
|
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "remotemodel.h"
|
||||
#include "gitplugin.h"
|
||||
#include "gitclient.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -55,7 +54,7 @@ bool RemoteModel::removeRemote(int row)
|
||||
{
|
||||
QString output;
|
||||
QString error;
|
||||
bool success = GitPlugin::client()->synchronousRemoteCmd(
|
||||
bool success = GitClient::instance()->synchronousRemoteCmd(
|
||||
m_workingDirectory, {"rm", remoteName(row)}, &output, &error);
|
||||
if (success)
|
||||
success = refresh(m_workingDirectory, &error);
|
||||
@@ -69,7 +68,7 @@ bool RemoteModel::addRemote(const QString &name, const QString &url)
|
||||
if (name.isEmpty() || url.isEmpty())
|
||||
return false;
|
||||
|
||||
bool success = GitPlugin::client()->synchronousRemoteCmd(
|
||||
bool success = GitClient::instance()->synchronousRemoteCmd(
|
||||
m_workingDirectory, {"add", name, url}, &output, &error);
|
||||
if (success)
|
||||
success = refresh(m_workingDirectory, &error);
|
||||
@@ -80,7 +79,7 @@ bool RemoteModel::renameRemote(const QString &oldName, const QString &newName)
|
||||
{
|
||||
QString output;
|
||||
QString error;
|
||||
bool success = GitPlugin::client()->synchronousRemoteCmd(
|
||||
bool success = GitClient::instance()->synchronousRemoteCmd(
|
||||
m_workingDirectory, {"rename", oldName, newName}, &output, &error);
|
||||
if (success)
|
||||
success = refresh(m_workingDirectory, &error);
|
||||
@@ -91,7 +90,7 @@ bool RemoteModel::updateUrl(const QString &name, const QString &newUrl)
|
||||
{
|
||||
QString output;
|
||||
QString error;
|
||||
bool success = GitPlugin::client()->synchronousRemoteCmd(
|
||||
bool success = GitClient::instance()->synchronousRemoteCmd(
|
||||
m_workingDirectory, {"set-url", name, newUrl}, &output, &error);
|
||||
if (success)
|
||||
success = refresh(m_workingDirectory, &error);
|
||||
@@ -186,7 +185,7 @@ bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage
|
||||
|
||||
// get list of remotes.
|
||||
QMap<QString,QString> remotesList
|
||||
= GitPlugin::client()->synchronousRemotesList(workingDirectory, errorMessage);
|
||||
= GitClient::instance()->synchronousRemotesList(workingDirectory, errorMessage);
|
||||
|
||||
beginResetModel();
|
||||
m_remotes.clear();
|
||||
|
@@ -161,7 +161,7 @@ void StashDialog::refresh(const QString &repository, bool force)
|
||||
m_model->setStashes(QList<Stash>());
|
||||
} else {
|
||||
QList<Stash> stashes;
|
||||
GitPlugin::client()->synchronousStashList(m_repository, &stashes);
|
||||
GitClient::instance()->synchronousStashList(m_repository, &stashes);
|
||||
m_model->setStashes(stashes);
|
||||
if (!stashes.isEmpty()) {
|
||||
for (int c = 0; c < ColumnCount; c++)
|
||||
@@ -177,7 +177,7 @@ void StashDialog::deleteAll()
|
||||
if (!ask(title, tr("Do you want to delete all stashes?")))
|
||||
return;
|
||||
QString errorMessage;
|
||||
if (GitPlugin::client()->synchronousStashRemove(m_repository, QString(), &errorMessage))
|
||||
if (GitClient::instance()->synchronousStashRemove(m_repository, QString(), &errorMessage))
|
||||
refresh(m_repository, true);
|
||||
else
|
||||
warning(title, errorMessage);
|
||||
@@ -194,7 +194,7 @@ void StashDialog::deleteSelection()
|
||||
QStringList errors;
|
||||
// Delete in reverse order as stashes rotate
|
||||
for (int r = rows.size() - 1; r >= 0; r--)
|
||||
if (!GitPlugin::client()->synchronousStashRemove(m_repository, m_model->at(rows.at(r)).name, &errorMessage))
|
||||
if (!GitClient::instance()->synchronousStashRemove(m_repository, m_model->at(rows.at(r)).name, &errorMessage))
|
||||
errors.push_back(errorMessage);
|
||||
refresh(m_repository, true);
|
||||
if (!errors.isEmpty())
|
||||
@@ -205,7 +205,7 @@ void StashDialog::showCurrent()
|
||||
{
|
||||
const int index = currentRow();
|
||||
QTC_ASSERT(index >= 0, return);
|
||||
GitPlugin::client()->show(m_repository, QString(m_model->at(index).name));
|
||||
GitClient::instance()->show(m_repository, QString(m_model->at(index).name));
|
||||
}
|
||||
|
||||
// Suggest Branch name to restore 'stash@{0}' -> 'stash0-date'
|
||||
@@ -266,7 +266,8 @@ bool StashDialog::promptForRestore(QString *stash,
|
||||
{
|
||||
const QString stashIn = *stash;
|
||||
bool modifiedPromptShown = false;
|
||||
switch (GitPlugin::client()->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules), nullptr, errorMessage)) {
|
||||
switch (GitClient::instance()->gitStatus(
|
||||
m_repository, StatusMode(NoUntracked | NoSubmodules), nullptr, errorMessage)) {
|
||||
case GitClient::StatusFailed:
|
||||
return false;
|
||||
case GitClient::StatusChanged: {
|
||||
@@ -274,13 +275,15 @@ bool StashDialog::promptForRestore(QString *stash,
|
||||
case ModifiedRepositoryCancel:
|
||||
return false;
|
||||
case ModifiedRepositoryStash:
|
||||
if (GitPlugin::client()->synchronousStash(m_repository, QString(), GitClient::StashPromptDescription).isEmpty())
|
||||
if (GitClient::instance()->synchronousStash(
|
||||
m_repository, QString(), GitClient::StashPromptDescription).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
*stash = nextStash(*stash); // Our stash id to be restored changed
|
||||
QTC_ASSERT(!stash->isEmpty(), return false);
|
||||
break;
|
||||
case ModifiedRepositoryDiscard:
|
||||
if (!GitPlugin::client()->synchronousReset(m_repository))
|
||||
if (!GitClient::instance()->synchronousReset(m_repository))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
@@ -317,7 +320,7 @@ void StashDialog::restoreCurrent()
|
||||
// Make sure repository is not modified, restore. The command will
|
||||
// output to window on success.
|
||||
if (promptForRestore(&name, nullptr, &errorMessage)
|
||||
&& GitPlugin::client()->synchronousStashRestore(m_repository, name)) {
|
||||
&& GitClient::instance()->synchronousStashRestore(m_repository, name)) {
|
||||
refresh(m_repository, true); // Might have stashed away local changes.
|
||||
} else if (!errorMessage.isEmpty()) {
|
||||
warning(msgRestoreFailedTitle(name), errorMessage);
|
||||
@@ -332,7 +335,7 @@ void StashDialog::restoreCurrentInBranch()
|
||||
QString branch;
|
||||
QString name = m_model->at(index).name;
|
||||
if (promptForRestore(&name, &branch, &errorMessage)
|
||||
&& GitPlugin::client()->synchronousStashRestore(m_repository, name, false, branch)) {
|
||||
&& GitClient::instance()->synchronousStashRestore(m_repository, name, false, branch)) {
|
||||
refresh(m_repository, true); // git deletes the stash, unfortunately.
|
||||
} else if (!errorMessage.isEmpty()) {
|
||||
warning(msgRestoreFailedTitle(name), errorMessage);
|
||||
|
Reference in New Issue
Block a user