From 2f41f359526c5452b981e002acd935fc3cec4014 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 14 Nov 2018 11:12:57 +0200 Subject: [PATCH] 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 --- src/libs/utils/shellcommand.cpp | 7 +++++-- src/libs/utils/shellcommand.h | 1 + src/plugins/git/gitclient.cpp | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libs/utils/shellcommand.cpp b/src/libs/utils/shellcommand.cpp index 92d97dc65b4..0d5be90996e 100644 --- a/src/libs/utils/shellcommand.cpp +++ b/src/libs/utils/shellcommand.cpp @@ -338,10 +338,13 @@ SynchronousProcessResponse ShellCommand::runCommand(const FileName &binary, if (!(d->m_flags & SuppressCommandLogging)) 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); - else + } else { response = runSynchronous(binary, arguments, proxy, timeoutS, dir, interpreter); + } if (!d->m_aborted) { // Success/Fail message in appropriate window? diff --git a/src/libs/utils/shellcommand.h b/src/libs/utils/shellcommand.h index c1bdb5a785d..22ff4a8df29 100644 --- a/src/libs/utils/shellcommand.h +++ b/src/libs/utils/shellcommand.h @@ -101,6 +101,7 @@ public: FullySynchronously = 0x80, // Suppress local event loop (in case UI actions are // triggered by file watchers). SilentOutput = 0x100, // Suppress user notifications about the output happening. + NoFullySync = 0x200, // Avoid fully synchronous execution even in UI thread. NoOutput = SuppressStdErr | SuppressFailMessage | SuppressCommandLogging }; diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index ad7cd7ca177..56577ffd8d2 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -2721,7 +2721,8 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory, arguments << "--signoff"; } - const SynchronousProcessResponse resp = vcsFullySynchronousExec(repositoryDirectory, arguments); + const SynchronousProcessResponse resp = vcsSynchronousExec(repositoryDirectory, arguments, + VcsCommand::NoFullySync); const QString stdErr = resp.stdErr(); if (resp.result == SynchronousProcessResponse::Finished) { VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount));