From d904edea8f241bbe2b6e2939ea4cd1a192d1dd94 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Mon, 24 Oct 2016 12:28:09 +0300 Subject: [PATCH] Update repository state before waiting for the VFS refresh It was initially intended to do so, but previously the VFS refresh was asynchronous, so the order of refresh() and update() methods was not important. However, in 32533a4 the VFS refresh became sync, thus update() became executed after the whole VFS refresh (which makes no sense). --- .../git4idea/src/git4idea/branch/GitCheckoutOperation.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java index 46cd668d83a6..aa08d59c007b 100644 --- a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java @@ -40,6 +40,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import static git4idea.util.GitUIUtil.code; +import static java.util.Arrays.stream; /** * Represents {@code git checkout} operation. @@ -281,11 +282,11 @@ class GitCheckoutOperation extends GitBranchOperation { } private void refresh(GitRepository... repositories) { + // repositories state will be auto-updated with the following VFS refresh => there is no need to call GitRepository#update() + // but we want repository state to be updated as soon as possible, without waiting for the whole VFS refresh to complete. + stream(repositories).forEach(GitRepository::update); for (GitRepository repository : repositories) { refreshRoot(repository); - // repository state will be auto-updated with this VFS refresh => in general there is no need to call GitRepository#update() - // but to avoid problems of the asynchronous refresh, let's force update the repository info. - repository.update(); } }