Git: Initialize GitClient on first access

This does not change the current timing of construction a lot as
the GerritPlugin may need it immediately in some cases, in any
case the gitGrep instance will need it.

There's nothing big going on at destruction time, so the prolonged
lifetime until really close to the end does not hurt.

The reason here is that this way we will avoid cases like in change
5e5b90a9a1.

Change-Id: I326d83c1a3d21114322ac6cce8d9e9b782faacdc
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2023-07-25 16:09:50 +02:00
parent 8d5897b8eb
commit 778a1d75ba
24 changed files with 255 additions and 280 deletions

View File

@@ -216,7 +216,7 @@ public:
showAction->setIcon(Utils::Icons::ZOOM.icon());
showAction->setToolTip(TextEditor::Tr::tr("Show Commit %1").arg(info.sha1.left(8)));
QObject::connect(showAction, &QAction::triggered, [info] {
GitClient::instance()->show(info.filePath, info.sha1);
gitClient().show(info.filePath, info.sha1);
});
return QList<QAction *>{copyToClipboardAction, showAction};
});
@@ -267,7 +267,7 @@ public:
bool vcsCreateRepository(const FilePath &directory) final;
void vcsAnnotate(const FilePath &filePath, int line) final;
void vcsDescribe(const FilePath &source, const QString &id) final { m_gitClient.show(source, id); };
void vcsDescribe(const FilePath &source, const QString &id) final { gitClient().show(source, id); }
QString vcsTopic(const FilePath &directory) final;
VcsCommand *createInitialCheckoutCommand(const QString &url,
@@ -290,9 +290,9 @@ public:
bool handleLink(const FilePath &workingDirectory, const QString &reference) final
{
if (reference.contains(".."))
GitClient::instance()->log(workingDirectory, {}, false, {reference});
gitClient().log(workingDirectory, {}, false, {reference});
else
GitClient::instance()->show(workingDirectory, reference);
gitClient().show(workingDirectory, reference);
return true;
}
@@ -422,7 +422,6 @@ public:
ParameterAction *m_applyCurrentFilePatchAction = nullptr;
Gerrit::Internal::GerritPlugin m_gerritPlugin;
GitClient m_gitClient;
QPointer<StashDialog> m_stashDialog;
BranchViewFactory m_branchViewFactory;
QPointer<RemoteDialog> m_remoteDialog;
@@ -438,7 +437,7 @@ public:
QMetaObject::Connection m_blameCursorPosConn;
QMetaObject::Connection m_documentChangedConn;
GitGrep gitGrep{&m_gitClient};
GitGrep gitGrep;
VcsEditorFactory svnLogEditorFactory {
&svnLogEditorParameters,
@@ -488,25 +487,20 @@ static GitPluginPrivate *dd = nullptr;
class GitTopicCache : public IVersionControl::TopicCache
{
public:
GitTopicCache(GitClient *client) :
m_client(client)
{ }
GitTopicCache() {}
protected:
FilePath trackFile(const FilePath &repository) override
{
const FilePath gitDir = m_client->findGitDirForRepository(repository);
const FilePath gitDir = gitClient().findGitDirForRepository(repository);
return gitDir.isEmpty() ? FilePath() : gitDir / "HEAD";
}
QString refreshTopic(const FilePath &repository) override
{
emit dd->repositoryChanged(repository);
return m_client->synchronousTopic(repository);
return gitClient().synchronousTopic(repository);
}
private:
GitClient *m_client;
};
GitPluginPrivate::~GitPluginPrivate()
@@ -547,11 +541,6 @@ bool GitPluginPrivate::isCommitEditorOpen() const
return !m_commitMessageFileName.isEmpty();
}
GitClient *GitPlugin::client()
{
return &dd->m_gitClient;
}
IVersionControl *GitPlugin::versionControl()
{
return dd;
@@ -670,7 +659,7 @@ QAction *GitPluginPrivate::createRepositoryAction(ActionContainer *ac, const QSt
{
auto cb = [this, func] {
QTC_ASSERT(currentState().hasTopLevel(), return);
(m_gitClient.*func)(currentState().topLevel());
(gitClient().*func)(currentState().topLevel());
};
// Set the member func as data and connect to GitClient method
return createRepositoryAction(ac, text, id, context, addToLocator, cb, keys);
@@ -701,12 +690,12 @@ GitPluginPrivate::GitPluginPrivate()
{
dd = this;
setTopicCache(new GitTopicCache(&m_gitClient));
setTopicCache(new GitTopicCache);
m_fileActions.reserve(10);
m_projectActions.reserve(10);
m_repositoryActions.reserve(50);
m_codec = GitClient::instance()->defaultCommitEncoding();
m_codec = gitClient().defaultCommitEncoding();
Context context(Constants::GIT_CONTEXT);
@@ -861,28 +850,28 @@ GitPluginPrivate::GitPluginPrivate()
};
m_abortMergeAction = createAction(Tr::tr("Abort Merge", "Avoid translating \"Merge\""), "Git.MergeAbort",
std::bind(&GitClient::synchronousMerge, &m_gitClient, _1, QString("--abort"), true));
std::bind(&GitClient::synchronousMerge, &gitClient(), _1, QString("--abort"), true));
m_abortRebaseAction = createAction(Tr::tr("Abort Rebase", "Avoid translating \"Rebase\""), "Git.RebaseAbort",
std::bind(&GitClient::rebase, &m_gitClient, _1, QString("--abort")));
std::bind(&GitClient::rebase, &gitClient(), _1, QString("--abort")));
m_continueRebaseAction = createAction(Tr::tr("Continue Rebase"), "Git.RebaseContinue",
std::bind(&GitClient::rebase, &m_gitClient, _1, QString("--continue")));
std::bind(&GitClient::rebase, &gitClient(), _1, QString("--continue")));
m_skipRebaseAction = createAction(Tr::tr("Skip Rebase"), "Git.RebaseSkip",
std::bind(&GitClient::rebase, &m_gitClient, _1, QString("--skip")));
std::bind(&GitClient::rebase, &gitClient(), _1, QString("--skip")));
m_abortCherryPickAction = createAction(Tr::tr("Abort Cherry Pick", "Avoid translating \"Cherry Pick\""), "Git.CherryPickAbort",
std::bind(&GitClient::synchronousCherryPick, &m_gitClient, _1, QString("--abort")));
std::bind(&GitClient::synchronousCherryPick, &gitClient(), _1, QString("--abort")));
m_continueCherryPickAction = createAction(Tr::tr("Continue Cherry Pick"), "Git.CherryPickContinue",
std::bind(&GitClient::cherryPick, &m_gitClient, _1, QString("--continue")));
std::bind(&GitClient::cherryPick, &gitClient(), _1, QString("--continue")));
m_abortRevertAction = createAction(Tr::tr("Abort Revert", "Avoid translating \"Revert\""), "Git.RevertAbort",
std::bind(&GitClient::synchronousRevert, &m_gitClient, _1, QString("--abort")));
std::bind(&GitClient::synchronousRevert, &gitClient(), _1, QString("--abort")));
m_continueRevertAction = createAction(Tr::tr("Continue Revert"), "Git.RevertContinue",
std::bind(&GitClient::revert, &m_gitClient, _1, QString("--continue")));
std::bind(&GitClient::revert, &gitClient(), _1, QString("--continue")));
// --------------
localRepositoryMenu->addSeparator(context);
@@ -1076,7 +1065,7 @@ void GitPluginPrivate::diffCurrentFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
m_gitClient.diffFile(state.currentFileTopLevel(), state.relativeCurrentFile());
gitClient().diffFile(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void GitPluginPrivate::diffCurrentProject()
@@ -1085,16 +1074,16 @@ void GitPluginPrivate::diffCurrentProject()
QTC_ASSERT(state.hasProject(), return);
const QString relativeProject = state.relativeCurrentProject();
if (relativeProject.isEmpty())
m_gitClient.diffRepository(state.currentProjectTopLevel());
gitClient().diffRepository(state.currentProjectTopLevel());
else
m_gitClient.diffProject(state.currentProjectTopLevel(), relativeProject);
gitClient().diffProject(state.currentProjectTopLevel(), relativeProject);
}
void GitPluginPrivate::logFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
m_gitClient.log(state.currentFileTopLevel(), state.relativeCurrentFile(), true);
gitClient().log(state.currentFileTopLevel(), state.relativeCurrentFile(), true);
}
void GitPluginPrivate::blameFile()
@@ -1132,7 +1121,7 @@ void GitPluginPrivate::blameFile()
const FilePath fileName = state.currentFile().canonicalPath();
FilePath topLevel;
VcsManager::findVersionControlForDirectory(fileName.parentDir(), &topLevel);
m_gitClient.annotate(topLevel, fileName.relativeChildPath(topLevel).toString(),
gitClient().annotate(topLevel, fileName.relativeChildPath(topLevel).toString(),
lineNumber, {}, extraOptions, firstLine);
}
@@ -1140,21 +1129,21 @@ void GitPluginPrivate::logProject()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return);
m_gitClient.log(state.currentProjectTopLevel(), state.relativeCurrentProject());
gitClient().log(state.currentProjectTopLevel(), state.relativeCurrentProject());
}
void GitPluginPrivate::logRepository()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient.log(state.topLevel());
gitClient().log(state.topLevel());
}
void GitPluginPrivate::reflogRepository()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient.reflog(state.topLevel());
gitClient().reflog(state.topLevel());
}
void GitPluginPrivate::undoFileChanges(bool revertStaging)
@@ -1166,7 +1155,7 @@ void GitPluginPrivate::undoFileChanges(bool revertStaging)
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
FileChangeBlocker fcb(state.currentFile());
m_gitClient.revertFiles({state.currentFile().toString()}, revertStaging);
gitClient().revertFiles({state.currentFile().toString()}, revertStaging);
}
class ResetItemDelegate : public LogItemDelegate
@@ -1208,7 +1197,7 @@ void GitPluginPrivate::resetRepository()
ResetItemDelegate delegate(dialog.widget());
dialog.setWindowTitle(Tr::tr("Undo Changes to %1").arg(topLevel.toUserOutput()));
if (dialog.runDialog(topLevel, {}, LogChangeWidget::IncludeRemotes))
m_gitClient.reset(topLevel, dialog.resetFlag(), dialog.commit());
gitClient().reset(topLevel, dialog.resetFlag(), dialog.commit());
}
void GitPluginPrivate::recoverDeletedFiles()
@@ -1217,7 +1206,7 @@ void GitPluginPrivate::recoverDeletedFiles()
return;
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient.recoverDeletedFiles(state.topLevel());
gitClient().recoverDeletedFiles(state.topLevel());
}
void GitPluginPrivate::startRebase()
@@ -1233,7 +1222,7 @@ void GitPluginPrivate::startRebaseFromCommit(const FilePath &workingDirectory, Q
{
if (!DocumentManager::saveAllModifiedDocuments())
return;
if (workingDirectory.isEmpty() || !m_gitClient.canRebase(workingDirectory))
if (workingDirectory.isEmpty() || !gitClient().canRebase(workingDirectory))
return;
if (commit.isEmpty()) {
@@ -1245,8 +1234,8 @@ void GitPluginPrivate::startRebaseFromCommit(const FilePath &workingDirectory, Q
commit = dialog.commit();
}
if (m_gitClient.beginStashScope(workingDirectory, "Rebase-i"))
m_gitClient.interactiveRebase(workingDirectory, commit, false);
if (gitClient().beginStashScope(workingDirectory, "Rebase-i"))
gitClient().interactiveRebase(workingDirectory, commit, false);
}
void GitPluginPrivate::startChangeRelatedAction(const Id &id)
@@ -1271,15 +1260,15 @@ void GitPluginPrivate::startChangeRelatedAction(const Id &id)
const int colon = change.indexOf(':');
if (colon > 0) {
const FilePath path = workingDirectory.resolvePath(change.mid(colon + 1));
m_gitClient.openShowEditor(workingDirectory, change.left(colon), path);
gitClient().openShowEditor(workingDirectory, change.left(colon), path);
} else {
m_gitClient.show(workingDirectory, change);
gitClient().show(workingDirectory, change);
}
return;
}
if (dialog.command() == Archive) {
m_gitClient.archive(workingDirectory, change);
gitClient().archive(workingDirectory, change);
return;
}
@@ -1288,13 +1277,13 @@ void GitPluginPrivate::startChangeRelatedAction(const Id &id)
switch (dialog.command()) {
case CherryPick:
m_gitClient.synchronousCherryPick(workingDirectory, change);
gitClient().synchronousCherryPick(workingDirectory, change);
break;
case Revert:
m_gitClient.synchronousRevert(workingDirectory, change);
gitClient().synchronousRevert(workingDirectory, change);
break;
case Checkout:
m_gitClient.checkout(workingDirectory, change);
gitClient().checkout(workingDirectory, change);
break;
default:
return;
@@ -1305,21 +1294,21 @@ void GitPluginPrivate::stageFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
m_gitClient.addFile(state.currentFileTopLevel(), state.relativeCurrentFile());
gitClient().addFile(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void GitPluginPrivate::unstageFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
m_gitClient.synchronousReset(state.currentFileTopLevel(), {state.relativeCurrentFile()});
gitClient().synchronousReset(state.currentFileTopLevel(), {state.relativeCurrentFile()});
}
void GitPluginPrivate::gitkForCurrentFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
m_gitClient.launchGitK(state.currentFileTopLevel(), state.relativeCurrentFile());
gitClient().launchGitK(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void GitPluginPrivate::gitkForCurrentFolder()
@@ -1330,7 +1319,7 @@ void GitPluginPrivate::gitkForCurrentFolder()
/*
* entire lower part of the code can be easily replaced with one line:
*
* m_gitClient.launchGitK(dir.currentFileDirectory(), ".");
* gitClient().launchGitK(dir.currentFileDirectory(), ".");
*
* However, there is a bug in gitk in version 1.7.9.5, and if you run above
* command, there will be no documents listed in lower right section.
@@ -1343,12 +1332,12 @@ void GitPluginPrivate::gitkForCurrentFolder()
*/
QDir dir(state.currentFileDirectory().toString());
if (QFileInfo(dir,".git").exists() || dir.cd(".git")) {
m_gitClient.launchGitK(state.currentFileDirectory());
gitClient().launchGitK(state.currentFileDirectory());
} else {
QString folderName = dir.absolutePath();
dir.cdUp();
folderName = folderName.remove(0, dir.absolutePath().length() + 1);
m_gitClient.launchGitK(FilePath::fromString(dir.absolutePath()), folderName);
gitClient().launchGitK(FilePath::fromString(dir.absolutePath()), folderName);
}
}
@@ -1356,14 +1345,14 @@ void GitPluginPrivate::gitGui()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient.launchGitGui(state.topLevel());
gitClient().launchGitGui(state.topLevel());
}
void GitPluginPrivate::gitBash()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient.launchGitBash(state.topLevel());
gitClient().launchGitBash(state.topLevel());
}
void GitPluginPrivate::startCommit(CommitType commitType)
@@ -1383,7 +1372,7 @@ void GitPluginPrivate::startCommit(CommitType commitType)
QString errorMessage, commitTemplate;
CommitData data(commitType);
if (!m_gitClient.getCommitData(state.topLevel(), &commitTemplate, data, &errorMessage)) {
if (!gitClient().getCommitData(state.topLevel(), &commitTemplate, data, &errorMessage)) {
VcsOutputWindow::appendError(errorMessage);
return;
}
@@ -1410,7 +1399,7 @@ void GitPluginPrivate::updateVersionWarning()
QPointer<IDocument> curDocument = EditorManager::currentDocument();
if (!curDocument)
return;
Utils::onResultReady(m_gitClient.gitVersion(), this, [curDocument](unsigned version) {
Utils::onResultReady(gitClient().gitVersion(), this, [curDocument](unsigned version) {
if (!curDocument || !version || version >= minimumRequiredVersion)
return;
InfoBar *infoBar = curDocument->infoBar();
@@ -1585,7 +1574,7 @@ void GitPluginPrivate::instantBlame()
const CommitInfo info = parseBlameOutput(output.split('\n'), filePath, m_author);
m_blameMark.reset(new BlameMark(filePath, line, info));
};
GitClient::instance()->vcsExecWithHandler(workingDirectory,
gitClient().vcsExecWithHandler(workingDirectory,
{"blame", "-p", "-L", lineString, "--", filePath.toString()},
this, commandHandler, RunFlags::NoOutput, m_codec);
}
@@ -1615,7 +1604,7 @@ bool GitPluginPrivate::refreshWorkingDirectory(const FilePath &workingDirectory)
const QString codecName = result.cleanedStdOut().trimmed();
codec = QTextCodec::codecForName(codecName.toUtf8());
} else {
codec = GitClient::instance()->defaultCommitEncoding();
codec = gitClient().defaultCommitEncoding();
}
if (m_codec != codec) {
@@ -1623,13 +1612,13 @@ bool GitPluginPrivate::refreshWorkingDirectory(const FilePath &workingDirectory)
forceInstantBlame();
}
};
GitClient::instance()->readConfigAsync(workingDirectory, {"config", "i18n.commitEncoding"},
gitClient().readConfigAsync(workingDirectory, {"config", "i18n.commitEncoding"},
commitCodecHandler);
const auto authorHandler = [this, workingDirectory](const CommandResult &result) {
if (result.result() == ProcessResult::FinishedWithSuccess) {
const QString authorInfo = result.cleanedStdOut().trimmed();
const Author author = GitClient::instance()->parseAuthor(authorInfo);
const Author author = gitClient().parseAuthor(authorInfo);
if (m_author != author) {
m_author = author;
@@ -1637,7 +1626,7 @@ bool GitPluginPrivate::refreshWorkingDirectory(const FilePath &workingDirectory)
}
}
};
GitClient::instance()->readConfigAsync(workingDirectory, {"var", "GIT_AUTHOR_IDENT"},
gitClient().readConfigAsync(workingDirectory, {"var", "GIT_AUTHOR_IDENT"},
authorHandler);
return true;
@@ -1693,7 +1682,7 @@ bool GitPluginPrivate::activateCommit()
if (!DocumentManager::saveDocument(editorDocument))
return false;
if (!m_gitClient.addAndCommit(m_submitRepository, editor->panelData(), commitType,
if (!gitClient().addAndCommit(m_submitRepository, editor->panelData(), commitType,
amendSHA1, m_commitMessageFileName, model)) {
editor->updateFileModel();
return false;
@@ -1701,15 +1690,15 @@ bool GitPluginPrivate::activateCommit()
}
cleanCommitMessageFile();
if (commitType == FixupCommit) {
if (!m_gitClient.beginStashScope(m_submitRepository, "Rebase-fixup",
if (!gitClient().beginStashScope(m_submitRepository, "Rebase-fixup",
NoPrompt, editor->panelData().pushAction)) {
return false;
}
m_gitClient.interactiveRebase(m_submitRepository, amendSHA1, true);
gitClient().interactiveRebase(m_submitRepository, amendSHA1, true);
} else {
m_gitClient.continueCommandIfNeeded(m_submitRepository);
gitClient().continueCommandIfNeeded(m_submitRepository);
if (editor->panelData().pushAction == NormalPush) {
m_gitClient.push(m_submitRepository);
gitClient().push(m_submitRepository);
} else if (editor->panelData().pushAction == PushToGerrit) {
connect(editor, &QObject::destroyed, this, &GitPluginPrivate::delayedPushToGerrit,
Qt::QueuedConnection);
@@ -1721,7 +1710,7 @@ bool GitPluginPrivate::activateCommit()
void GitPluginPrivate::fetch()
{
m_gitClient.fetch(currentState().topLevel(), {});
gitClient().fetch(currentState().topLevel(), {});
}
void GitPluginPrivate::pull()
@@ -1734,31 +1723,31 @@ void GitPluginPrivate::pull()
bool rebase = settings().pullRebase();
if (!rebase) {
QString currentBranch = m_gitClient.synchronousCurrentLocalBranch(topLevel);
QString currentBranch = gitClient().synchronousCurrentLocalBranch(topLevel);
if (!currentBranch.isEmpty()) {
currentBranch.prepend("branch.");
currentBranch.append(".rebase");
rebase = (m_gitClient.readConfigValue(topLevel, currentBranch) == "true");
rebase = (gitClient().readConfigValue(topLevel, currentBranch) == "true");
}
}
if (!m_gitClient.beginStashScope(topLevel, "Pull", rebase ? Default : AllowUnstashed))
if (!gitClient().beginStashScope(topLevel, "Pull", rebase ? Default : AllowUnstashed))
return;
m_gitClient.pull(topLevel, rebase);
gitClient().pull(topLevel, rebase);
}
void GitPluginPrivate::push()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient.push(state.topLevel());
gitClient().push(state.topLevel());
}
void GitPluginPrivate::startMergeTool()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient.merge(state.topLevel());
gitClient().merge(state.topLevel());
}
void GitPluginPrivate::cleanProject()
@@ -1782,7 +1771,7 @@ void GitPluginPrivate::cleanRepository(const FilePath &directory)
QStringList files;
QStringList ignoredFiles;
QApplication::setOverrideCursor(Qt::WaitCursor);
const bool gotFiles = m_gitClient.synchronousCleanList(directory, {}, &files, &ignoredFiles,
const bool gotFiles = gitClient().synchronousCleanList(directory, {}, &files, &ignoredFiles,
&errorMessage);
QApplication::restoreOverrideCursor();
@@ -1806,7 +1795,7 @@ void GitPluginPrivate::updateSubmodules()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
m_gitClient.updateSubmodulesIfNeeded(state.topLevel(), false);
gitClient().updateSubmodulesIfNeeded(state.topLevel(), false);
}
// If the file is modified in an editor, make sure it is saved.
@@ -1836,20 +1825,20 @@ void GitPluginPrivate::promptApplyPatch()
void GitPluginPrivate::applyPatch(const FilePath &workingDirectory, QString file)
{
// Ensure user has been notified about pending changes
if (!m_gitClient.beginStashScope(workingDirectory, "Apply-Patch", AllowUnstashed))
if (!gitClient().beginStashScope(workingDirectory, "Apply-Patch", AllowUnstashed))
return;
// Prompt for file
if (file.isEmpty()) {
const QString filter = Tr::tr("Patches (*.patch *.diff)");
file = QFileDialog::getOpenFileName(ICore::dialogParent(), Tr::tr("Choose Patch"), {}, filter);
if (file.isEmpty()) {
m_gitClient.endStashScope(workingDirectory);
gitClient().endStashScope(workingDirectory);
return;
}
}
// Run!
QString errorMessage;
if (m_gitClient.synchronousApplyPatch(workingDirectory, file, &errorMessage)) {
if (gitClient().synchronousApplyPatch(workingDirectory, file, &errorMessage)) {
if (errorMessage.isEmpty())
VcsOutputWindow::appendMessage(Tr::tr("Patch %1 successfully applied to %2")
.arg(file, workingDirectory.toUserOutput()));
@@ -1858,7 +1847,7 @@ void GitPluginPrivate::applyPatch(const FilePath &workingDirectory, QString file
} else {
VcsOutputWindow::appendError(errorMessage);
}
m_gitClient.endStashScope(workingDirectory);
gitClient().endStashScope(workingDirectory);
}
void GitPluginPrivate::stash(bool unstagedOnly)
@@ -1870,7 +1859,7 @@ void GitPluginPrivate::stash(bool unstagedOnly)
QTC_ASSERT(state.hasTopLevel(), return);
const FilePath topLevel = state.topLevel();
m_gitClient.executeSynchronousStash(topLevel, {}, unstagedOnly);
gitClient().executeSynchronousStash(topLevel, {}, unstagedOnly);
if (m_stashDialog)
m_stashDialog->refresh(topLevel, true);
}
@@ -1885,7 +1874,7 @@ void GitPluginPrivate::stashSnapshot()
// Prompt for description, restore immediately and keep on working.
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
const QString id = m_gitClient.synchronousStash(state.topLevel(), {},
const QString id = gitClient().synchronousStash(state.topLevel(), {},
GitClient::StashImmediateRestore | GitClient::StashPromptDescription);
if (!id.isEmpty() && m_stashDialog)
m_stashDialog->refresh(state.topLevel(), true);
@@ -1896,7 +1885,7 @@ void GitPluginPrivate::stashPop()
if (!DocumentManager::saveAllModifiedDocuments())
return;
const FilePath repository = currentState().topLevel();
m_gitClient.stashPop(repository);
gitClient().stashPop(repository);
if (m_stashDialog)
m_stashDialog->refresh(repository, true);
}
@@ -1970,7 +1959,7 @@ void GitPluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
repositoryAction->setEnabled(repositoryEnabled);
m_submoduleUpdateAction->setVisible(repositoryEnabled
&& !m_gitClient.submoduleList(state.topLevel()).isEmpty());
&& !gitClient().submoduleList(state.topLevel()).isEmpty());
updateContinueAndAbortCommands();
updateRepositoryBrowserAction();
@@ -1982,7 +1971,7 @@ void GitPluginPrivate::updateContinueAndAbortCommands()
{
if (currentState().hasTopLevel()) {
GitClient::CommandInProgress gitCommandInProgress =
m_gitClient.checkCommandInProgress(currentState().topLevel());
gitClient().checkCommandInProgress(currentState().topLevel());
m_mergeToolAction->setVisible(gitCommandInProgress != GitClient::NoCommand);
m_abortMergeAction->setVisible(gitCommandInProgress == GitClient::Merge);
@@ -2035,7 +2024,7 @@ QObject *GitPlugin::remoteCommand(const QStringList &options, const QString &wor
return nullptr;
if (options.first() == "-git-show")
dd->m_gitClient.show(FilePath::fromUserInput(workingDirectory), options.at(1));
gitClient().show(FilePath::fromUserInput(workingDirectory), options.at(1));
return nullptr;
}
@@ -2070,7 +2059,7 @@ bool GitPluginPrivate::isVcsFileOrDirectory(const FilePath &filePath) const
bool GitPluginPrivate::isConfigured() const
{
return !m_gitClient.vcsBinary().isEmpty();
return !gitClient().vcsBinary().isEmpty();
}
bool GitPluginPrivate::supportsOperation(Operation operation) const
@@ -2098,30 +2087,30 @@ bool GitPluginPrivate::vcsOpen(const FilePath & /*filePath*/)
bool GitPluginPrivate::vcsAdd(const FilePath &filePath)
{
return m_gitClient.synchronousAdd(filePath.parentDir(), {filePath.fileName()}, {"--intent-to-add"});
return gitClient().synchronousAdd(filePath.parentDir(), {filePath.fileName()}, {"--intent-to-add"});
}
bool GitPluginPrivate::vcsDelete(const FilePath &filePath)
{
return m_gitClient.synchronousDelete(filePath.absolutePath(), true, {filePath.fileName()});
return gitClient().synchronousDelete(filePath.absolutePath(), true, {filePath.fileName()});
}
bool GitPluginPrivate::vcsMove(const FilePath &from, const FilePath &to)
{
const QFileInfo fromInfo = from.toFileInfo();
const QFileInfo toInfo = to.toFileInfo();
return m_gitClient.synchronousMove(from.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
return gitClient().synchronousMove(from.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
}
bool GitPluginPrivate::vcsCreateRepository(const FilePath &directory)
{
return m_gitClient.synchronousInit(directory);
return gitClient().synchronousInit(directory);
}
QString GitPluginPrivate::vcsTopic(const FilePath &directory)
{
QString topic = IVersionControl::vcsTopic(directory);
const QString commandInProgress = m_gitClient.commandInProgressDescription(directory);
const QString commandInProgress = gitClient().commandInProgressDescription(directory);
if (!commandInProgress.isEmpty())
topic += " (" + commandInProgress + ')';
return topic;
@@ -2135,9 +2124,9 @@ VcsCommand *GitPluginPrivate::createInitialCheckoutCommand(const QString &url,
QStringList args = {"clone", "--progress"};
args << extraArgs << url << localName;
auto command = VcsBaseClient::createVcsCommand(baseDirectory, m_gitClient.processEnvironment());
auto command = VcsBaseClient::createVcsCommand(baseDirectory, gitClient().processEnvironment());
command->addFlags(RunFlags::SuppressStdErr);
command->addJob({m_gitClient.vcsBinary(), args}, -1);
command->addJob({gitClient().vcsBinary(), args}, -1);
return command;
}
@@ -2149,7 +2138,7 @@ GitPluginPrivate::RepoUrl GitPluginPrivate::getRepoUrl(const QString &location)
FilePaths GitPluginPrivate::additionalToolsPath() const
{
FilePaths res = settings().searchPathList();
const FilePath binaryPath = m_gitClient.gitBinDirectory();
const FilePath binaryPath = gitClient().gitBinDirectory();
if (!binaryPath.isEmpty() && !res.contains(binaryPath))
res << binaryPath;
return res;
@@ -2157,7 +2146,7 @@ FilePaths GitPluginPrivate::additionalToolsPath() const
bool GitPluginPrivate::managesDirectory(const FilePath &directory, FilePath *topLevel) const
{
const FilePath topLevelFound = m_gitClient.findRepositoryForDirectory(directory);
const FilePath topLevelFound = gitClient().findRepositoryForDirectory(directory);
if (topLevel)
*topLevel = topLevelFound;
return !topLevelFound.isEmpty();
@@ -2165,17 +2154,17 @@ bool GitPluginPrivate::managesDirectory(const FilePath &directory, FilePath *top
bool GitPluginPrivate::managesFile(const FilePath &workingDirectory, const QString &fileName) const
{
return m_gitClient.managesFile(workingDirectory, fileName);
return gitClient().managesFile(workingDirectory, fileName);
}
FilePaths GitPluginPrivate::unmanagedFiles(const FilePaths &filePaths) const
{
return m_gitClient.unmanagedFiles(filePaths);
return gitClient().unmanagedFiles(filePaths);
}
void GitPluginPrivate::vcsAnnotate(const FilePath &filePath, int line)
{
m_gitClient.annotate(filePath.absolutePath(), filePath.fileName(), line);
gitClient().annotate(filePath.absolutePath(), filePath.fileName(), line);
}
void GitPlugin::emitFilesChanged(const QStringList &l)