Git: Change pull to run asynchronously

Fixes: QTCREATORBUG-13279
Change-Id: Idee6e64e5eebe729e7c1d0e0135a1d8b464187b7
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2018-09-18 07:43:22 +03:00
committed by Orgad Shaneh
parent 641c9f7db9
commit 296ae92853
3 changed files with 16 additions and 15 deletions

View File

@@ -2863,7 +2863,7 @@ bool GitClient::executeAndHandleConflicts(const QString &workingDirectory,
return resp.result == SynchronousProcessResponse::Finished;
}
bool GitClient::synchronousPull(const QString &workingDirectory, bool rebase)
void GitClient::pull(const QString &workingDirectory, bool rebase)
{
QString abortCommand;
QStringList arguments = {"pull"};
@@ -2874,12 +2874,10 @@ bool GitClient::synchronousPull(const QString &workingDirectory, bool rebase)
abortCommand = "merge";
}
bool ok = executeAndHandleConflicts(workingDirectory, arguments, abortCommand);
if (ok)
updateSubmodulesIfNeeded(workingDirectory, true);
return ok;
VcsCommand *command = vcsExecAbortable(workingDirectory, arguments, rebase);
connect(command, &VcsCommand::success, this,
[this, workingDirectory] { updateSubmodulesIfNeeded(workingDirectory, true); },
Qt::QueuedConnection);
}
void GitClient::synchronousAbortCommand(const QString &workingDir, const QString &abortCommand)
@@ -3045,18 +3043,21 @@ void GitClient::revert(const QString &workingDirectory, const QString &argument)
// Stashing is handled prior to this call.
VcsCommand *GitClient::vcsExecAbortable(const QString &workingDirectory,
const QStringList &arguments,
bool createProgressParser)
bool isRebase)
{
QTC_ASSERT(!arguments.isEmpty(), return nullptr);
QString abortCommand = arguments.at(0);
// Git might request an editor, so this must be done asynchronously and without timeout
VcsCommand *command = createCommand(workingDirectory, nullptr, VcsWindowOutputBind);
command->setCookie(workingDirectory);
command->addFlags(VcsCommand::ShowSuccessMessage);
command->addJob(vcsBinary(), arguments, 0);
command->addFlags(VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage);
// For rebase, Git might request an editor (which means the process keeps running until the
// user closes it), so run without timeout.
command->addJob(vcsBinary(), arguments, isRebase ? 0 : command->defaultTimeoutS());
ConflictHandler::attachToCommand(command, abortCommand);
if (createProgressParser)
if (isRebase)
GitProgressParser::attachToCommand(command);
command->execute();

View File

@@ -126,7 +126,7 @@ public:
VcsBase::VcsCommand *vcsExecAbortable(const QString &workingDirectory,
const QStringList &arguments,
bool createProgressParser = false);
bool isRebase = false);
QString findRepositoryForDirectory(const QString &dir) const;
QString findGitDirForRepository(const QString &repositoryDir) const;
@@ -242,7 +242,7 @@ public:
bool isFastForwardMerge(const QString &workingDirectory, const QString &branch);
void fetch(const QString &workingDirectory, const QString &remote);
bool synchronousPull(const QString &workingDirectory, bool rebase);
void pull(const QString &workingDirectory, bool rebase);
void push(const QString &workingDirectory, const QStringList &pushArgs = QStringList());
bool synchronousMerge(const QString &workingDirectory, const QString &branch,
bool allowFastForward = true);

View File

@@ -1111,7 +1111,7 @@ void GitPlugin::pull()
if (!m_gitClient->beginStashScope(topLevel, "Pull", rebase ? Default : AllowUnstashed))
return;
m_gitClient->synchronousPull(topLevel, rebase);
m_gitClient->pull(topLevel, rebase);
}
void GitPlugin::push()