From ca188f4863c129aed2b1b84393937c633f6239f3 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Mon, 5 Jun 2017 19:29:16 +0300 Subject: [PATCH] Return Git root, not Git repository folder Follow-up to e6c8b18, which works incorrectly e.g. for worktrees. The issue found in IDEA-CR-21166 --- plugins/git4idea/src/git4idea/GitUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java index 038ac6e059b4..a6d53798ac1a 100644 --- a/plugins/git4idea/src/git4idea/GitUtil.java +++ b/plugins/git4idea/src/git4idea/GitUtil.java @@ -368,8 +368,9 @@ public class GitUtil { public static VirtualFile getGitRootOrNull(@NotNull final FilePath filePath) { File root = filePath.getIOFile(); while (root != null) { - File gitDir = findGitDir(root); - if (gitDir != null) return LocalFileSystem.getInstance().findFileByIoFile(root); + if (isGitRoot(root)) { + return LocalFileSystem.getInstance().findFileByIoFile(root); + } root = root.getParentFile(); } return null;