diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java b/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java index 2d6676b941be..d33261eeb2ac 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchWorker.java @@ -84,7 +84,7 @@ public final class GitBranchWorker { public void createNewTag(@NotNull final String name, @NotNull final String reference, @NotNull final List repositories) { for (GitRepository repository : repositories) { myGit.createNewTag(repository, name, null, reference); - repository.getRepositoryFiles().refresh(false); + repository.getRepositoryFiles().refresh(); } } diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java index 017d47c2889c..0b7d62f4b6de 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryFiles.java @@ -308,8 +308,24 @@ public class GitRepositoryFiles { return path.equals(myExcludePath); } - public void refresh(boolean async) { - VfsUtil.markDirtyAndRefresh(async, true, false, myMainDir, myWorktreeDir); + /** + * Refresh all .git repository files asynchronously and recursively. + * + * @see #refreshNonTrackedData() if you need the "main" data (branches, HEAD, etc.) to be updated synchronously. + */ + public void refresh() { + VfsUtil.markDirtyAndRefresh(true, true, false, myMainDir, myWorktreeDir); + } + + /** + * Refresh that part of .git repository files, which is not covered by {@link GitRepository#update()}, e.g. the {@code refs/tags/} dir. + * + * The call to this method should be probably be done together with a call to update(): thus all information will be updated, + * but some of it will be updated synchronously, the rest - asynchronously. + */ + public void refreshNonTrackedData() { + VirtualFile tagsDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(myRefsTagsPath); + VfsUtil.markDirtyAndRefresh(true, true, false, tagsDir); } @NotNull diff --git a/plugins/git4idea/src/git4idea/ui/GitTagDialog.java b/plugins/git4idea/src/git4idea/ui/GitTagDialog.java index 441f3b5216d6..2572a7704b41 100644 --- a/plugins/git4idea/src/git4idea/ui/GitTagDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitTagDialog.java @@ -214,7 +214,7 @@ public class GitTagDialog extends DialogWrapper { GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(getGitRoot()); if (repository != null) { - repository.getRepositoryFiles().refresh(true); + repository.getRepositoryFiles().refresh(); } else { LOG.error("No repository registered for root: " + getGitRoot()); diff --git a/plugins/git4idea/src/git4idea/update/GitFetcher.java b/plugins/git4idea/src/git4idea/update/GitFetcher.java index 131cfbdbbc24..a684f760c4a0 100644 --- a/plugins/git4idea/src/git4idea/update/GitFetcher.java +++ b/plugins/git4idea/src/git4idea/update/GitFetcher.java @@ -81,7 +81,8 @@ public class GitFetcher { public GitFetchResult fetch(@NotNull GitRepository repository) { // TODO need to have a fair compound result here GitFetchResult fetchResult = myFetchAll ? fetchAll(repository) : fetchCurrentRemote(repository); - repository.getRepositoryFiles().refresh(false); + repository.update(); + repository.getRepositoryFiles().refreshNonTrackedData(); return fetchResult; }