Git: Make commit a bit less synchronous

If gc.auto is configured, commit can trigger garbage collection, which
takes time. Avoid completely blocking the UI on this case, and at least
show the output of the commit command.

Change-Id: Id301c878c26599bbc363928a6770c04369a62f2f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2018-11-14 11:12:57 +02:00
committed by Orgad Shaneh
parent b8dcaa455e
commit 2f41f35952
3 changed files with 8 additions and 3 deletions

View File

@@ -338,10 +338,13 @@ SynchronousProcessResponse ShellCommand::runCommand(const FileName &binary,
if (!(d->m_flags & SuppressCommandLogging)) if (!(d->m_flags & SuppressCommandLogging))
proxy->appendCommand(dir, binary, arguments); proxy->appendCommand(dir, binary, arguments);
if (d->m_flags & FullySynchronously || QThread::currentThread() == QCoreApplication::instance()->thread()) if ((d->m_flags & FullySynchronously)
|| (!(d->m_flags & NoFullySync)
&& QThread::currentThread() == QCoreApplication::instance()->thread())) {
response = runFullySynchronous(binary, arguments, proxy, timeoutS, dir, interpreter); response = runFullySynchronous(binary, arguments, proxy, timeoutS, dir, interpreter);
else } else {
response = runSynchronous(binary, arguments, proxy, timeoutS, dir, interpreter); response = runSynchronous(binary, arguments, proxy, timeoutS, dir, interpreter);
}
if (!d->m_aborted) { if (!d->m_aborted) {
// Success/Fail message in appropriate window? // Success/Fail message in appropriate window?

View File

@@ -101,6 +101,7 @@ public:
FullySynchronously = 0x80, // Suppress local event loop (in case UI actions are FullySynchronously = 0x80, // Suppress local event loop (in case UI actions are
// triggered by file watchers). // triggered by file watchers).
SilentOutput = 0x100, // Suppress user notifications about the output happening. SilentOutput = 0x100, // Suppress user notifications about the output happening.
NoFullySync = 0x200, // Avoid fully synchronous execution even in UI thread.
NoOutput = SuppressStdErr | SuppressFailMessage | SuppressCommandLogging NoOutput = SuppressStdErr | SuppressFailMessage | SuppressCommandLogging
}; };

View File

@@ -2721,7 +2721,8 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
arguments << "--signoff"; arguments << "--signoff";
} }
const SynchronousProcessResponse resp = vcsFullySynchronousExec(repositoryDirectory, arguments); const SynchronousProcessResponse resp = vcsSynchronousExec(repositoryDirectory, arguments,
VcsCommand::NoFullySync);
const QString stdErr = resp.stdErr(); const QString stdErr = resp.stdErr();
if (resp.result == SynchronousProcessResponse::Finished) { if (resp.result == SynchronousProcessResponse::Finished) {
VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount)); VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount));