From 68d05e25a7a2490ddb56a889a620d6dcb2a03387 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 2 Aug 2012 20:59:25 +0400 Subject: [PATCH] [git] IDEA-89445 Update the IO-File of the FilePath to handle moves of the file (when VirtualFile is updated, but io-file is not) --- .../src/git4idea/history/GitHistoryProvider.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java b/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java index 541ae7f41bb8..5b90c14b07e3 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java @@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vcs.FilePathImpl; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.ContentRevision; import com.intellij.openapi.vcs.history.*; @@ -160,7 +161,7 @@ public class GitHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto partner.reportCreatedEmptySession(emptySession); final GitExecutableValidator validator = GitVcs.getInstance(myProject).getExecutableValidator(); try { - GitHistoryUtils.history(myProject, path, null, new Consumer() { + GitHistoryUtils.history(myProject, refreshPath(path), null, new Consumer() { public void consume(GitFileRevision gitFileRevision) { partner.acceptRevision(gitFileRevision); } @@ -177,8 +178,17 @@ public class GitHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto } /** - * {@inheritDoc} + * Refreshes the IO File inside this FilePath to let it survive moves. */ + @NotNull + private static FilePath refreshPath(@NotNull FilePath path) { + VirtualFile virtualFile = path.getVirtualFile(); + if (virtualFile == null) { + return path; + } + return new FilePathImpl(virtualFile); + } + public boolean supportsHistoryForDirectories() { return true; }